Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 356f258

Browse files
committed
Made some changes to the comments
1 parent b7b492c commit 356f258

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

projects/Discord Bot/main.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
# The list below is a list that contains all the responses the bot can randomly choose from for the "ask" command
1313
# Scroll down to see the "ask" command's functionality
14-
# It is recommended to make this list in a different .txt file or .py file and then importing it to this main.py
15-
# file but for the sake of simplicity, I have added this list here only in the main bot file.
1614

1715
responses_list = ["It is certain",
1816
"It is decidedly so",
@@ -63,23 +61,13 @@ async def ask(ctx: commands.Context, *, question: str):
6361

6462
# Note:- If we don't put a ( * ) before the question paramter, the bot will only take the first word from the user
6563
# input. For example: Running the command like this:- "!ask how are you?"
66-
# The bot will read that command as:- "how". To avoid this, we add an asterisk( * ) before the question parameter
67-
# so the bot will read the command as "how are you?".
64+
# The bot will read that command as:- "how"
6865

6966
await ctx.reply(f"{ctx.author.mention} asks: **{question}**\nMy reply: **{random.choice(responses_list)}**")
7067

71-
# the ctx object has an attribute called "reply" which will reply to the user's message when the user uses to command
72-
# prefix along with the command name. And the rest of the code is self explanatory. The "\n" basically makes it so
73-
# that the rest of the code after that "\n" will be printed in a new line. So ultimately, running this command
74-
# on discord will look like this:-
75-
76-
# lets say user asks the bot "how are you". So the user will send: "!ask how are you".
77-
# the bot will reply with "{user's discord id mention} asks: how are you"
78-
# "My reply: {a random response from the responses list}"
79-
8068
# There's one last thing to do now.. which is handling error. As we can see, the "ask" commands needs a question
8169
# parameter.. but what if the user just uses the command and never provide the bot with the question parameter?
82-
# This situation will through an error called "MissingRequiredArgument". In order to avoid this, we can locally
70+
# This situation will throw an error called "MissingRequiredArgument". In order to avoid this, we can locally
8371
# create a error handler for this "ask" command. You can also use a try and except block to catch the error.
8472

8573
@ask.error

0 commit comments

Comments
 (0)