@@ -6,6 +6,7 @@ use crate::{
66use :: serenity:: futures:: { Stream , StreamExt } ;
77use poise:: serenity_prelude:: { futures, CreateAttachment , CreateEmbed } ;
88
9+ #[ allow( clippy:: unused_async) ]
910async fn autocomplete_snippet < ' a > (
1011 ctx : Context < ' a > ,
1112 partial : & ' a str ,
@@ -39,7 +40,7 @@ pub async fn snippet(
3940 id : String ,
4041) -> Result < ( ) , Error > {
4142 // Lazily get snippet because this is a prefix command too.
42- if let Some ( snippet) = get_snippet_lazy ( & ctx, & id) . await {
43+ if let Some ( snippet) = get_snippet_lazy ( & ctx, & id) {
4344 let embed = snippet. embed ( ) ;
4445
4546 respond_embed ( & ctx, embed, false ) . await ;
@@ -80,7 +81,7 @@ pub async fn create_snippet(
8081 rwlock_guard. snippets . push ( snippet. clone ( ) ) ;
8182
8283 rwlock_guard. snippets = rwlock_guard. snippets . clone ( ) ;
83- println ! ( "New snippet created '{}: {}'" , id , title ) ;
84+ println ! ( "New snippet created '{id }: {title }'" ) ;
8485 rwlock_guard. write ( ) ;
8586
8687 let mut embed = snippet. embed ( ) ;
@@ -112,7 +113,7 @@ pub async fn edit_snippet(
112113 #[ description = "The snippet's title" ] title : Option < String > ,
113114 #[ description = "The snippet's content" ] content : Option < String > ,
114115) -> Result < ( ) , Error > {
115- match get_snippet_lazy ( & ctx, & id) . await {
116+ match get_snippet_lazy ( & ctx, & id) {
116117 Some ( mut snippet) => {
117118 if let Some ( title) = title {
118119 snippet. title = title;
@@ -135,7 +136,7 @@ pub async fn edit_snippet(
135136 None => {
136137 let title = & "Failed to edit snippet" ;
137138 let content = & & format ! ( "The snippet '{id}' does not exist" ) ;
138- respond_err ( & ctx, title, content) . await
139+ respond_err ( & ctx, title, content) . await ;
139140 }
140141 } ;
141142
@@ -150,17 +151,17 @@ pub async fn remove_snippet(
150151 #[ description = "The snippet's id" ]
151152 id : String ,
152153) -> Result < ( ) , Error > {
153- match get_snippet_lazy ( & ctx, & id) . await {
154+ match get_snippet_lazy ( & ctx, & id) {
154155 Some ( snippet) => {
155- rm_snippet ( & ctx, & snippet) . await ;
156+ rm_snippet ( & ctx, & snippet) ;
156157 let title = & "Snippet successfully removed" ;
157158 let content = & & format ! ( "Removed snippet '{}: {}'" , snippet. id, snippet. title) ;
158159 respond_ok ( & ctx, title, content) . await ;
159160 }
160161 None => {
161162 let title = & "Failed to remove snippet" ;
162163 let content = & & format ! ( "The snippet '{id}' does not exist" ) ;
163- respond_err ( & ctx, title, content) . await
164+ respond_err ( & ctx, title, content) . await ;
164165 }
165166 }
166167
@@ -194,7 +195,7 @@ pub async fn list_snippets(ctx: Context<'_>) -> Result<(), Error> {
194195 . map ( |snippet| ( snippet. id . clone ( ) , snippet. title . clone ( ) , true ) )
195196 . collect :: < Vec < ( String , String , bool ) > > ( )
196197 . chunks ( 25 )
197- . map ( |chunk| chunk . to_vec ( ) )
198+ . map ( < [ ( String , String , bool ) ] > :: to_vec )
198199 . collect ( ) ;
199200
200201 super :: paginate_lists ( ctx, & pages, "Snippets" ) . await ?;
@@ -213,10 +214,10 @@ pub async fn export_snippet(
213214 #[ description = "The snippet's id" ]
214215 id : String ,
215216) -> Result < ( ) , Error > {
216- match get_snippet_lazy ( & ctx, & id) . await {
217+ match get_snippet_lazy ( & ctx, & id) {
217218 Some ( snippet) => {
218219 let attachment = CreateAttachment :: bytes (
219- format ! ( "{}" , & snippet. content. replace( '\n' , r"\n" ) ) ,
220+ snippet. content . replace ( '\n' , r"\n" ) . to_string ( ) ,
220221 "snippet.txt" ,
221222 ) ;
222223 let message = poise:: CreateReply :: default ( )
@@ -227,7 +228,7 @@ pub async fn export_snippet(
227228 None => {
228229 let title = & "Failed to export snippet" ;
229230 let content = & & format ! ( "The snippet '{id}' does not exist" ) ;
230- respond_err ( & ctx, title, content) . await
231+ respond_err ( & ctx, title, content) . await ;
231232 }
232233 }
233234
@@ -245,7 +246,7 @@ impl Embeddable for Snippet {
245246}
246247
247248// Exact matches the snippet id and name.
248- async fn _get_snippet ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
249+ fn _get_snippet ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
249250 let data = ctx. data ( ) ;
250251 let rwlock_guard = data. state . read ( ) . unwrap ( ) ;
251252
@@ -257,7 +258,7 @@ async fn _get_snippet(ctx: &Context<'_>, id: &str) -> Option<Snippet> {
257258}
258259
259260// Matches the snippet by checking if its starts with the id and name.
260- async fn get_snippet_lazy ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
261+ fn get_snippet_lazy ( ctx : & Context < ' _ > , id : & str ) -> Option < Snippet > {
261262 let data = ctx. data ( ) ;
262263 let rwlock_guard = data. state . read ( ) . unwrap ( ) ;
263264
@@ -268,7 +269,7 @@ async fn get_snippet_lazy(ctx: &Context<'_>, id: &str) -> Option<Snippet> {
268269 . cloned ( )
269270}
270271
271- async fn rm_snippet ( ctx : & Context < ' _ > , snippet : & Snippet ) {
272+ fn rm_snippet ( ctx : & Context < ' _ > , snippet : & Snippet ) {
272273 let data = ctx. data ( ) ;
273274 let mut rwlock_guard = data. state . write ( ) . unwrap ( ) ;
274275
0 commit comments