@@ -29,7 +29,7 @@ async def on_raw_reaction_add(payload):
29
29
message = await channel .fetch_message (payload .message_id )
30
30
31
31
# Create a new inbox item using async
32
- item = InboxItem (
32
+ await InboxItem . objects . acreate (
33
33
message_id = str (message .id ),
34
34
channel_id = str (payload .channel_id ),
35
35
channel_name = f"#{ channel .name } " ,
@@ -38,7 +38,6 @@ async def on_raw_reaction_add(payload):
38
38
author = str (message .author .name ),
39
39
content = message .content ,
40
40
)
41
- await item .asave ()
42
41
43
42
44
43
@bot .event
@@ -55,17 +54,27 @@ async def on_raw_reaction_remove(payload):
55
54
56
55
@bot .command ()
57
56
async def inbox (ctx ):
58
- """Display a user's inbox items"""
57
+ """
58
+ Displays the content of the inbox for the user that calls the command.
59
+
60
+ Each message is saved with user_id (which is a discord id), and here we can
61
+ filter out all those messages depending on who called the command.
62
+
63
+ It retuns all tracked messages, starting from the one most recently saved
64
+ (a message that was most recently tagged with inbox emoji, not the message
65
+ that was most recently sent).
66
+ """
59
67
user_id = str (ctx .message .author .id )
60
68
inbox_items = InboxItem .objects .filter (user_id = user_id ).order_by ("-created_at" )
61
69
62
- msg = "Currently tracking the following messages:\n "
63
70
64
71
# Use async query
65
72
if not await inbox_items .aexists ():
66
73
await ctx .send ("Your inbox is empty." )
67
74
return
68
75
76
+ msg = "Currently tracking the following messages:\n "
77
+
69
78
async for item in inbox_items :
70
79
msg += "* " + item .summary () + "\n "
71
80
0 commit comments