@@ -9,6 +9,7 @@ use poise::serenity_prelude::{
99 CreateInteractionResponseMessage ,
1010} ;
1111
12+ #[ allow( clippy:: unused_async) ]
1213async fn autocomplete_snippet < ' a > (
1314 ctx : Context < ' a > ,
1415 partial : & ' a str ,
@@ -40,7 +41,7 @@ pub async fn snippet(
4041 id : String ,
4142) -> Result < ( ) , Error > {
4243 // Lazily get snippet because this is a prefix command too.
43- if let Some ( snippet) = get_snippet_lazy ( & ctx, & id) . await {
44+ if let Some ( snippet) = get_snippet_lazy ( & ctx, & id) {
4445 let embed = snippet. embed ( ) ;
4546
4647 respond_embed ( & ctx, embed, false ) . await ;
@@ -78,6 +79,7 @@ pub async fn create_snippet(
7879 } ;
7980
8081 println ! ( "New snippet created '{}: {}'" , snippet. id, snippet. title) ;
82+
8183 let mut embed = snippet. embed ( ) ;
8284
8385 embed = embed. colour ( super :: OK_COLOUR ) ;
@@ -111,7 +113,7 @@ pub async fn edit_snippet(
111113 #[ description = "The snippet's title" ] title : Option < String > ,
112114 #[ description = "The snippet's content" ] content : Option < String > ,
113115) -> Result < ( ) , Error > {
114- match get_snippet_lazy ( & ctx, & id) . await {
116+ match get_snippet_lazy ( & ctx, & id) {
115117 Some ( mut snippet) => {
116118 if let Some ( title) = title {
117119 snippet. title = title;
@@ -134,7 +136,7 @@ pub async fn edit_snippet(
134136 None => {
135137 let title = & "Failed to edit snippet" ;
136138 let content = & & format ! ( "The snippet '{id}' does not exist" ) ;
137- respond_err ( & ctx, title, content) . await
139+ respond_err ( & ctx, title, content) . await ;
138140 }
139141 } ;
140142
@@ -149,14 +151,14 @@ pub async fn remove_snippet(
149151 #[ description = "The snippet's id" ]
150152 id : String ,
151153) -> Result < ( ) , Error > {
152- match get_snippet_lazy ( & ctx, & id) . await {
154+ match get_snippet_lazy ( & ctx, & id) {
153155 Some ( snippet) => {
154156 remove_snippet_confirm ( & ctx, & snippet) . await ?;
155157 }
156158 None => {
157159 let title = & "Failed to remove snippet" ;
158160 let content = & & format ! ( "The snippet '{id}' does not exist" ) ;
159- respond_err ( & ctx, title, content) . await
161+ respond_err ( & ctx, title, content) . await ;
160162 }
161163 }
162164
@@ -190,7 +192,7 @@ pub async fn list_snippets(ctx: Context<'_>) -> Result<(), Error> {
190192 . map ( |snippet| ( snippet. id . clone ( ) , snippet. title . clone ( ) , true ) )
191193 . collect :: < Vec < ( String , String , bool ) > > ( )
192194 . chunks ( 25 )
193- . map ( |chunk| chunk . to_vec ( ) )
195+ . map ( < [ ( String , String , bool ) ] > :: to_vec )
194196 . collect ( ) ;
195197
196198 super :: paginate_lists ( ctx, & pages, "Snippets" ) . await ?;
@@ -209,7 +211,7 @@ pub async fn export_snippet(
209211 #[ description = "The snippet's id" ]
210212 id : String ,
211213) -> Result < ( ) , Error > {
212- match get_snippet_lazy ( & ctx, & id) . await {
214+ match get_snippet_lazy ( & ctx, & id) {
213215 Some ( snippet) => {
214216 let attachment =
215217 CreateAttachment :: bytes ( snippet. content . replace ( '\n' , r"\n" ) , "snippet.txt" ) ;
@@ -221,7 +223,7 @@ pub async fn export_snippet(
221223 None => {
222224 let title = & "Failed to export snippet" ;
223225 let content = & & format ! ( "The snippet '{id}' does not exist" ) ;
224- respond_err ( & ctx, title, content) . await
226+ respond_err ( & ctx, title, content) . await ;
225227 }
226228 }
227229
@@ -239,7 +241,7 @@ impl Embeddable for Snippet {
239241}
240242
241243// Exact matches the snippet id and name.
242- async fn _get_snippet ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
244+ fn _get_snippet ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
243245 let data = ctx. data ( ) ;
244246 let rwlock_guard = data. state . read ( ) . unwrap ( ) ;
245247
@@ -251,7 +253,7 @@ async fn _get_snippet(ctx: &Context<'_>, id: &str) -> Option<Snippet> {
251253}
252254
253255// Matches the snippet by checking if its starts with the id and name.
254- async fn get_snippet_lazy ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
256+ fn get_snippet_lazy ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
255257 let data = ctx. data ( ) ;
256258 let rwlock_guard = data. state . read ( ) . unwrap ( ) ;
257259
@@ -262,7 +264,7 @@ async fn get_snippet_lazy(ctx: &Context<'_>, id: &str) -> Option<Snippet> {
262264 . cloned ( )
263265}
264266
265- async fn rm_snippet ( ctx : & Context < ' _ > , snippet : & Snippet ) {
267+ fn rm_snippet ( ctx : & Context < ' _ > , snippet : & Snippet ) {
266268 let data = ctx. data ( ) ;
267269 let mut rwlock_guard = data. state . write ( ) . unwrap ( ) ;
268270
@@ -281,8 +283,8 @@ async fn remove_snippet_confirm(ctx: &Context<'_>, snippet: &Snippet) -> Result<
281283 let snippet_embed = snippet. embed ( ) ;
282284
283285 let ctx_id = ctx. id ( ) ;
284- let delete_id = format ! ( "{}cancel" , ctx_id ) ;
285- let cancel_id = format ! ( "{}delete" , ctx_id ) ;
286+ let delete_id = format ! ( "{ctx_id }cancel" ) ;
287+ let cancel_id = format ! ( "{ctx_id }delete" ) ;
286288
287289 let components = serenity:: CreateActionRow :: Buttons ( vec ! [
288290 serenity:: CreateButton :: new( & cancel_id) . label( "Cancel" ) ,
@@ -322,7 +324,7 @@ async fn handle_delete(
322324 snippet : & Snippet ,
323325 interaction : serenity:: ComponentInteraction ,
324326) -> Result < ( ) , Error > {
325- rm_snippet ( ctx, snippet) . await ;
327+ rm_snippet ( ctx, snippet) ;
326328 interaction
327329 . create_response (
328330 ctx,
0 commit comments