Skip to content

Commit a61a836

Browse files
committed
added mentions
1 parent fba4228 commit a61a836

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

foodbot.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async def update_order_message(interaction):
4343
if current_order is None:
4444
content = "No active order."
4545
else:
46-
order_list = [f'{interaction.guild.get_member(user_id).name}: {", ".join(user_orders)}' for user_id, user_orders in current_order['items'].items()]
46+
order_list = [f'{interaction.guild.get_member(user_id).mention}: {", ".join(user_orders)}' for user_id, user_orders in current_order['items'].items()]
4747
content = (f'Order in progress by {current_order["username"]}\n \n'
4848
f'From: {current_order["place"]} \nOrder before: {current_order["time"]}\n \n'
4949
'Use "/addorder [order]" to order your food.\n' f'Current orders: \n' + '\n'.join(order_list))
@@ -53,6 +53,7 @@ async def update_order_message(interaction):
5353
else:
5454
await order_message.edit(content=content)
5555

56+
5657
@bot.event
5758
async def on_message(message):
5859
if isinstance(message.channel, disnake.TextChannel) and message.channel.name == allowed_channel_name and current_order is not None:
@@ -124,24 +125,28 @@ async def finalize_order(interaction: disnake.ApplicationCommandInteraction):
124125
# Backup the current order before finalizing
125126
last_order_backup = current_order.copy()
126127

127-
# Prepare the final order list message
128+
# Prepare the final order list message with mentions
128129
order_list = []
129130
for user_id, user_orders in current_order['items'].items():
130131
member = interaction.guild.get_member(user_id)
131132
if member:
132-
order_list.append(f'{member.name}: {", ".join(user_orders)}')
133+
order_list.append(f'{member.mention}: {", ".join(user_orders)}')
133134
else:
134135
order_list.append(f'Unknown User ({user_id}): {", ".join(user_orders)}')
135136

136137
# Send the final order list to the channel and save the message reference
137138
order_list_message = "The following order has been ended:\n" + '\n'.join(order_list)
138139
final_order_message = await interaction.channel.send(order_list_message)
139140

141+
# Send the finalized order as a DM to the user ending the order
142+
await interaction.user.send("Order finalized:\n" + '\n'.join(order_list))
143+
140144
# Clear the current order
141145
current_order = None
142146
await update_order_message(interaction)
143147
await interaction.response.send_message('Order finalized!', ephemeral=True)
144148

149+
145150
@bot.slash_command(name="restoreorder", description="Restore the last ended order if it was ended by mistake")
146151
async def restore_order(interaction: disnake.ApplicationCommandInteraction):
147152
if not is_allowed_channel(interaction):

0 commit comments

Comments
 (0)