Skip to content

Commit ae8416a

Browse files
committed
using OS to check if file is there
1 parent 6003197 commit ae8416a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bot/context_menus.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import nextcord
44
from nextcord import Message, Interaction
55
from nextcord.ext import commands
6+
import os
67

78
from bot.bot import bot
89
from shared.config import EMPLOYMENT_CHANNEL_ID, SHOWCASE_CHANNEL_ID, HELP_FORUM_CHANNEL_ID, STAFF_ROLES
@@ -116,8 +117,15 @@ async def how_to_use_slash_command(self, interaction: Interaction, message: Mess
116117
message (Message): The message where the command was invoked.
117118
"""
118119
message_content = "To use a slash command, type a forward-slash \"/\" in the chat bar and a list of commands will appear. Click on the one you want to use. For more information visit https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ."
119-
file = nextcord.File("../images/slashcommand.png", filename="slashcommand.png")
120-
await interaction.response.send_message(content=message_content, file=file)
120+
121+
# Check if the file exists before trying to send it
122+
123+
file_path = "../images/slashcommand.png"
124+
if os.path.exists(file_path):
125+
file = nextcord.File(file_path, filename="slashcommand.png")
126+
await interaction.response.send_message(content=message_content, file=file)
127+
else:
128+
await interaction.response.send_message(content=message_content)
121129

122130

123131
def setup(bot):

0 commit comments

Comments
 (0)