@@ -332,11 +332,12 @@ impl EventHandler for EvHandler {
332
332
. insert ( message. author . id , message. author . name . clone ( ) ) ;
333
333
334
334
let converted_message = DiscordMessage {
335
- content : message. content . clone ( ) ,
335
+ ctx : & ctx,
336
+ message : & message,
336
337
attachments : converted_attachments. iter ( ) . map ( |x| x as _ ) . collect ( ) ,
337
338
author : DiscordAuthor {
338
339
id : message. author . id . get ( ) ,
339
- name : message. author . name ,
340
+ name : & message. author . name ,
340
341
ctx : & ctx,
341
342
} ,
342
343
} ;
@@ -360,14 +361,24 @@ struct NicknameCache(HashMap<SerenityUserId, String>);
360
361
struct IsBotCache ( HashMap < SerenityUserId , bool > ) ;
361
362
362
363
struct DiscordMessage < ' a > {
363
- content : String ,
364
+ ctx : & ' a SerenityContext ,
365
+ message : & ' a SerenityMessage ,
364
366
attachments : Vec < & ' a dyn Attachment > ,
365
367
author : DiscordAuthor < ' a > ,
366
368
}
367
369
370
+ #[ async_trait]
368
371
impl Message for DiscordMessage < ' _ > {
372
+ async fn reply ( & self , text : & str ) -> Result < ( ) > {
373
+ self . message
374
+ . reply_ping ( & self . ctx . http , text)
375
+ . await
376
+ . context ( "failed to reply with discord feature" ) ?;
377
+ Ok ( ( ) )
378
+ }
379
+
369
380
fn content ( & self ) -> & str {
370
- & self . content
381
+ & self . message . content
371
382
}
372
383
373
384
fn attachments ( & self ) -> & [ & dyn Attachment ] {
@@ -382,7 +393,7 @@ impl Message for DiscordMessage<'_> {
382
393
struct DiscordAuthor < ' a > {
383
394
id : u64 ,
384
395
#[ allow( unused) ]
385
- name : String ,
396
+ name : & ' a str ,
386
397
ctx : & ' a SerenityContext ,
387
398
}
388
399
@@ -393,7 +404,7 @@ impl<'a> User for DiscordAuthor<'a> {
393
404
}
394
405
395
406
fn name ( & self ) -> & str {
396
- & self . name
407
+ self . name
397
408
}
398
409
399
410
async fn dm ( & self , msg : SendMessage < ' _ > ) -> Result < ( ) > {
0 commit comments