#discord-bots
1 messages · Page 247 of 1
On github education do I need to be a student that a teacher teaches me how to use github?
no
nice
I've been trying to fix this for the past hour, please help.
Difficulties with this event:
@bot.event()
async def on_message_delete(message):
z = bot.get_channel()
embed = discord.Embed(title = f"{message.author}'s Message was Deleted", description = f"Deleted Message: {message.content}\nAuthor: {message.author.mention}\nLocation: {message.channel.mention}", colour=discord.Colour.red())
await z.send(embed=embed)
Receiving this Error Message:
Traceback (most recent call last):
File "main.py", line 41, in <module>
@bot.event()
TypeError: Client.event() missing 1 required positional argument: 'coro'
No () for the decorator
Oh, that worked, thanks.
only an hour i'm jealous

If your value is strictly Boolean then there's probably no need
If it can take the form of a different type of item (such as NoneType) then you should use is False
remove parantheses for the @bot.event
atleast you do find a fix
Hello, does anyone familiar with Nextcord.py?
ask your question
My code is supposed to send Welcome and Goodbye messages but no message shows up when a new member enters the server
https://paste.nextcord.dev/?id=1685471894947906
it should be member.guild without the paranthesis
Oh, I see. I will try without parenthesis
intents = nextcord.Intents.all() #allowing the bot to enter servers
intents.members = True
intents.message_content = True
also what's the point of this, you set it to all so all intents are enabled but then you set it to True again when it's already True
and intents does not allow your bot to enter servers
Oh, I forgot to remove that in my code
I’m still new to nextcord so I follow the docs and tutorials
You have any knowledge on dbs?
you should use sqlite since you're only making the leaderboard
aiosqlite is a good library to connect
Hi guys, I'm trying to make my bot, so I want some kinda word filter, and, actually I have code for that, but I want it to take words from txt file, but I don't know how to do that, can anyone assist?
good luck making a word filter
unless you actually have some better system other than just a word list anyone will be able to bypass it
I want to start with list
list will include different variations
I mean, I need to ban only one word, so list of words is enough for me
so, do u know how to deal with files ?
they could just put a special character in between them
bad.....word
as for your question you can just open the file and use readlines
and if you block bad.....word they can just use bad....1.word
I can't figure out how to make a Roblox verification system for my discord bot it's so hard ive been trying for 7 hours
how many items can I add for a dropdown menu (select menu)?
I don't play roblox, but what are you trying to verify
A Roblox account
Like they put a phrase that the bot generated in there about me
Snd when they say done
The bot checks
token verification?
!d discord.ui.Select
class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu with a list of custom options. This is represented to the user as a dropdown menu.
New in version 2.0.
is there a limit?
25 items
but the function does exactly the same, so its kinda useless
how?
Create two button objects inside your view's __init__ then set their callback to your wanted callback
And just add them to your view using view.add_item (or self)
!d discord.ui.View.add_item
add_item(item)```
Adds an item to the view.
This function returns the class instance to allow for fluent-style chaining.
so if I dont have a constructor, I will create one?
What constructor
__init__
You aren't subclassing the view?
what do you mean by this
class MyView(discord.ui.View): # <- 'MyView' is subclassing 'discord.ui.View'
...
Then you can just add the __init__ function to it
No
😮
^
depends on what you want to verify exactly
They use -verify "there Roblox username" the bot sends a random phrase and asks them to put in there Roblox about me and when the user says done it checks for the phrase in there about me if it finds it it says Great! And gives them the specified roles
Sure see ya there
no
if you don't say anything nobody can help
Well I’m confused on the db part?
what do you need a database for
for..?
When I use a command, it doesn't work, and there isn't any error message. Willing to go to DMs.
bot = commands.Bot(intents = intents, command_prefix=".")
bot.remove_command('help')
@bot.event
async def on_ready():
activity = discord.Game(name=".help", type=3)
await bot.change_presence(status=discord.Status.online, activity=activity)
print(f"Logged into {bot.user}")
print(f"Bot Id: {bot.user.id}")
@bot.command()
async def ping(ctx):
latency = round(bot.latency, 1)
await ctx.reply(f"Pong! {latency}ms")
Have you enabled the message_content intent
in the code or dev portal?
Both
This good?
intents.messages = True
Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:
• The message was sent by the client
• The message was sent in direct messages
• The message mentions the client
This applies to the following events...
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Anyone can help me in my roles code
https://paste.pythondiscord.com/totuvefabu
what's wrong with it
also you don't have any checks to stop anyone from giving themselves admin role
Wdym -_-
anyone can do !role admin and it'll give them the admin role?
How can I do like leave this first that code is not working so I have to fix it first ;-;
yes
"not working" doesn't say anything
Bro can you help me in this code this is really not working
again not working does not say anything
Huh nvm my English I am weak
Correct word then........?
show your error traceback
Wait
if you don't have any errors, explain what your code should be doing and what it actually does
Don't have any error there ;-;
It timeout specific members for specific time
explain what your code should be doing and what it actually does
also await member.edit(mute=False) does not exist
you have to use await member.timeout(None) and you can't sleep for long durations because your member will be stuck muted forever if your bot crashes or restarts
Unless they have a database and can restart the schedule
Oh ok
What?
It's basic persistent mute system
Why you type too slowly ;-;
I have something to do outside discord
Oh ok
Changed but nothing happened....
Your _convert_to_ function is outside the class
Oh
You know timeouts are handled by Discord and you don't need to un-timeout someone yourself, right?
Just like on the Discord UI, you specify the duration of the timeout and that's it, no need to remove the timeout yourself..
So no schedule restart, database is irrelevant, etc.
how do i use @bot.tree.command to describe an option because it is not like @app_commands
You also use @app_commands.describe
ok so I'm actually having the same problem but I've actually set up my bot with the proper intents lol
still didn't got the solution, if you can continue helping with this, ill be happy
import discord
from discord.ext import tasks, commands
def run_discord_bot():
TOKEN = '###'
intents = discord.Intents.default()
intents.message_content = True
global client
client = discord.Client(intents=intents)
bot = commands.Bot(command_prefix="!!", intents=intents)
@bot.command()
async def test(ctx):
await ctx.send(ctx)
client.run(TOKEN)
literally does not register command, I tried as a hybrid as well and no slash option appeared
I have debugging on the full bot and it was parsing as a normal message
bot intents are all toggled on in the dev portal
I about gave up
you need to create a slash command using its decorator
example:
@client.tree.command(name="logout", description="Logout from the account you are currently logged in to")
async def logout(interaction: discord.Interaction):
....
YouTube
I kinda thought they had to be separate ngl
discord.Client and discord.ext.commands.Bot
right?
You only need one
bruh
Use commands.Bot
And ^
client = commands.Bot(command_prefix="!!", intents=intents)
emojis = ['\N{WHITE HEAVY CHECK MARK}', "\N{BOMB}"]
@client.tree.command(name="test", description="say hello to everyone")
async def test(ctx):
await ctx.send("hola")
not right?
slash commands uses interactions instead of ctx
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
k bet ty
sorry I had tried reading discord py documentation and it was not helping lol
well I copied the sync line for line,
@client.command()
@commands.guild_only()
@commands.is_owner()
async def sync(
ctx: Context, guilds: Greedy[discord.Object], spec: Optional[Literal["~", "*", "^"]] = None) -> None:
if not guilds:
if spec == "~":
synced = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == "*":
ctx.bot.tree.copy_global_to(guild=ctx.guild)
synced = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == "^":
ctx.bot.tree.clear_commands(guild=ctx.guild)
await ctx.bot.tree.sync(guild=ctx.guild)
synced = []
else:
synced = await ctx.bot.tree.sync()
await ctx.send(
f"Synced {len(synced)} commands {'globally' if spec is None else 'to the current guild.'}"
)
return
ret = 0
for guild in guilds:
try:
await ctx.bot.tree.sync(guild=guild)
except discord.HTTPException:
pass
else:
ret += 1
await ctx.send(f"Synced the tree to {ret}/{len(guilds)}.")
Nothing when I run !!sync
intents = discord.Intents.default()
intents.message_content = True
global client
client = commands.Bot(command_prefix="!!", intents=intents)
What does this mean?
It means exactly what it says
Too many syncs
There is a ratelimit on syncing global commands which add commands. Updating commands (currently) has no ratelimit.
So 14 is the max?
it says 200 lol
Does disnake autosync commands in a smart way (ie only ones that are missing or not in code or with different signature) or bulk overwrites them every time
It stacks when you sync the commands
you could create a bunch of commands and sync them all at the same time, but if you sync them one by one it'll eventually stop you
if it makes you feel any better, I still can't figure out why my command won't sync 😭
it's past 5 am so I'm going to bed, but if anyone wants to offer advice I'll read it tomorrow ❤️
They all sync at once
but if you run sync each time you're exhausting your usage
Oh. So do I need to wait a day?
if your sync is in your "on_ready" section or similar where it's being run unnecessarily, I recommend moving it
you only wanna call sync when you need to
When you add a new command.
When you remove a command.
When a command's name or description changes.
When the callback's parameters change.
If you change a global to a guild command, or vice versa.
otherwise, it's pointless to run
Is there an event when a tree command changes?
So I can reduce the syncs
What
So I can reduce the syncs
Sigh
For example if I am editing an event and I run it’s gonna sync because it’s on the on_ready event
move it from the on ready
Where tho?
Just remove it
You should not blindingly sync automatically
Make a message command or something
Is there a event for a tree command change
you literally only need to run it when you make an edit/addition/removal, so just have a message command you can run in your server whenever you do one of those
Ohhhh ok thanks
ofc he listens to me who is not an expert 
How can I make a command for a dev only?
Thanks
don't quote me on that
I still can't figure out how to get my own sync to run
@naive briar any ideas lol
I dont know y but its blockes not words but all characters in the line
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
why doesnt my embed (!create_embed) work? No Error! Just nothing happends
https://paste.pythondiscord.com/yuropecupi
You aren't enabling the message_content intent, so, there's no wonder that it wouldn't work
Like this?:
https://paste.pythondiscord.com/uyadatebim
They said message_content
I said message_content very clearly
Did you do it in discord developer?
Wdym
Oh wait nvm
He is saying clearly message_content
There we go
Is there a way to make sure I dont get rate limited. I have a bot that has 5 commands that i was trying to make for a clan event, all my slash commands are synced globally i guesss but i really just need it to work in two seprate discords technically.
Still pretty new to coding in general so please be nice 🙂
mainly it querys a local DB, some of the commands pull images from a wiki for the embeds. I added another command just now that only querys the DB and it gave us:
discord.errors.HTTPException: 400 Bad Request (error code: 30034): Max number of daily application command creates has been reached (200)
Are you syncing the commands globally everytime you run your code?
You only need to sync them when you change the metadata of the command, not the underlying function code
Ok, so i guess i should pull that out of my code for when the bot turns on. we just started to host it on a friends homeserver, i think weve only restarted the bot a handful of times so i cant imagine we hit the 200 limit so quick.
we got the error when the bot was turning on.
I want to create a select menu
I have this
select = Select(
placeholder="Choose a color to apply it to your device",
options=[
discord.ButtonStyle(
label="Philippine Red",
value="d40f2b",
emoji=colors['d40f2b']['emoji']
)
]
)
but as I have many colors I was trying to do it like this without success
select = Select(
placeholder="Choose a color to apply it to your device",
options=[
for color in colors:
discord.ButtonStyle(
label=color[color]['name'],
value=color,
emoji=colors[color]['emoji']
)
]
)
any ideas?
Do you ever find yourself writing something like this?
>>> squares = []
>>> for n in range(5):
... squares.append(n ** 2)
[0, 1, 4, 9, 16]
Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:
>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]
List comprehensions also get an if clause:
>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]
For more info, see this pythonforbeginners.com post.
Thanks a lot!
its working!
how cool I cannot handle it
does anyone know how i would creste a channel once a modal has been submitted? I have this so far:
@bot.command()
async def test(ctx):
class MyView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="View Modal", style=discord.ButtonStyle.primary, custom_id="customid1")
async def button_callback1(self, button, interaction:discord.Interaction):
modal = WriteUserModal(title="Create a channel")
await interaction.response.send_modal(modal)
view = MyView()
await ctx.reply(view=view)```
Can json crash your bot?
How can I check the reactions of a message?
!d discord.Message.reactions
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
Yeah I have that error
what?
If json has lots of data can it crash?
what json? from a request? a file? wdym "crash"
Nvm
How would json crash bot?
Because too much data
when a user clicks Submit on a modal, how do i make the bot reply with something after that?
that would not crash your bot , i guess , loading data doesn't matter
Button?
no a modal
thx!
Hi guys , can loading a lot of data or loading a lot of data from a api crashes our discord bot , if yes , how to make it not?
You literally just answered someone else saying it wouldnt
It probably could if you run out of memory
does anyone know why when i click submit on my modal it always says, Something went wrong! Try again, but i get no errors
show your code
class StarterMM(Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
# add the questions:
self.add_item(InputText(label="Paste your Discord ID or Full Tag.", min_length=2, max_length=32, required=True, style=discord.InputTextStyle.short))
self.add_item(InputText(label="What's your problem", min_length=2, max_length=1000, required=True, style=discord.InputTextStyle.long))
async def callback(self, interaction2: discord.Interaction): # once the submit button is clicked..
user_id = self.children[0].value # thats the submitted answer to the 1st question
prob_text = self.children[1].value # thats the submitted answer to the 2nd question
async def on_submit(self, interaction: discord.Interaction):
await interaction.response.send_message(f"Creating ticket..", ephemeral=True)
guild = bot.get_guild(GUILD_ID)
await guild.create_text_channel(f"mm {interaction.user.name}")
async def on_error(self, interaction: discord.Interaction, error: Exception) -> None:
await interaction.response.send_message('Oops! Something went wrong.', ephemeral=True)
# Make sure we know what the error actually is
traceback.print_exception(type(error), error, error.__traceback__)```
what is all this stuff?
this doesn't exist
And why are you asking for the username lol, you can get that data
what do you mean it doesnt exist?
its not valid code? InputText isnt a thing, not is InputTextStyle, the callback method doesnt exist
yeah nah
I'm not going to argue with you
it still works though
It literally doesnt bruh
.
I thought i am wrong , so verifying if i am right
its worked on other projects though
It never has and never will
unless you're using some super obscure third-party library that no one has used before
this is with the exact same code and it works
show the code then
class MyModal(Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
daa = datetime.now(timezone(timedelta(hours=3))).strftime("%d-%m-%Y")
#self.add_item(InputText(label="Today's date in case you forgot..", required=False, style=discord.InputTextStyle.short, value=f"{daa}"))
self.add_item(InputText(label="Day in numbers", placeholder="Example: 15", max_length=2, required=True, style=discord.InputTextStyle.short))
self.add_item(InputText(label="Month in numbers", placeholder="Example: 3", max_length=2, required=True, style=discord.InputTextStyle.short))
self.add_item(InputText(label="Year in numbers", placeholder="Example: 2022", max_length=4, required=True, style=discord.InputTextStyle.short, value="2022"))
async def callback(self, interaction: discord.Interaction):
if interaction.user.id != ctx.author.id:
return await interaction.response.send_message(content="Only the user who ran the cmd can use this.", ephemeral=True)```
apparently thats how pycord named it
https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.InputText
yes
great naming
so it does exist
it also looks like your on_error parameters are in the wrong order
https://docs.pycord.dev/en/stable/api/ui_kit.html#discord.ui.Modal.on_error
on_error(error, interaction)```
🤮 _ _
Would've been helpful if you specified what library you were using-
mb, so do u know what the issue is?
^
Is there a reason to create commands.command commands as well? Or just slash commands
for private discord bots
for testing/debugging commands sure, or if you have something too advanced to be written in a slash command
What do you mean by "too advanced to be written in a slash command"?
like being able to use markdown formatting...
Oh I think I'm with you now. Like the !e command?
Lets say I have an interaction
and that interaction has a button
how can I know that the clicker is also the interaction's author?
(so that he is permitted to click the button)
There is something Like interaction_check i belive let me check docs
What lib do you use?
!d discord.ui.View.interaction_check
await interaction_check(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.
This is useful to override if, for example, you want to ensure that the interaction author is a given user.
The default implementation of this returns `True`.
Note
If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
Checking a message for reactions always returns nothing, even though the message does have reactions, the bot has admin priviledges and it doesn't recognise anyones reactions, even its own
Code: ```py
reactdict = {"\u0031\u20E3":1,"\u0032\u20E3":2,"\u0033\u20E3":3,"\u0034\u20E3":4,"\u0035\u20E3":5,
"\u0036\u20E3":6,"\u0037\u20E3":7,"\u0038\u20E3":8,"\u0039\u20E3":9,"\U0001F51F":10}
async def sendmessage(channel: TextChannel, starttime: time, duration: int): -> int
targettime = time(hour=(starttime.hour + duration), minute=starttime.minute)
# Send message
msg = await channel.send("How was your day?")
for react in reactdict.keys():
await msg.add_reaction(react)
# print(react)
while True:
await asyncio.sleep(5)
# Check reactions
await checkreaction(msg)
print(f"now: {datetime.now().time()}, target: {targettime}")
if datetime.now().time() > targettime:
break
# Things to do before quitting
print("quitting")
return 0
async def checkreaction(msg: Message):
print(f"reactions: {len(msg.reactions)}")
The bot successfully sends a messages and sends the reactions to its own message but can't check its reactions
but what do I do then?
it returns True
but how can I access the parent's interaction owner
show your code now
class SimpleView(discord.ui.View):
@discord.ui.button(label="Turn on", style=discord.ButtonStyle.success)
async def turn_on(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
await interaction.response.defer()
self.light_api.on = True
status, emoji = br.device_status_to_word(self.light_api.on)
self.embed.remove_field(3)
self.embed.add_field(name=f'{emoji} Status', value=f"_Light is currently {status}_", inline=False)
await self.message.edit(embed=self.embed)
@discord.ui.button(label="Turn off", style=discord.ButtonStyle.secondary)
async def turn_off(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
await interaction.response.defer()
print(button)
resp = await discord.ui.View.interaction_check(self, interaction)
print(resp)
print(interaction.user.id)
print(interaction.user)
self.light_api.on = False
status, emoji = br.device_status_to_word(self.light_api.on)
self.embed.remove_field(3)
self.embed.add_field(name=f'{emoji} Status', value=f"_Light is currently {status}_", inline=False)
await self.message.edit(embed=self.embed)
The turn_off function is what I am on right now
okay so you have a View subclass
now you need to override interaction_check method
somehow manage to get id of user that invoked the command to the view
and in the interaction_check
check if ids match
if you are stuck at any point lmk
somehow?
you can accept it in the constructor or something like that
let me see
i dont know exactly for which user you want to check
the one that invoked the command right?
lets say I am doing the /list command
I want to make sure, that only I will be permitted to use the buttons
I figured it out, no need to reply
okay so yeah you can pass the id in the constructor then
since you have the id in the command already
so the buttons has a sub-interaction?
yes but why does that matter now?
to understand how it works 😄
One option is to make the response ephemeral, so you don't have to worry about other users clicking the button at all.
thats also an idea
commands.Bot not commands.bot
Still what
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
thank you
400 Bad Request (error code: 30034): Max number of daily application command creates has been reached (200)
it's a bug with the discord api
Can Discord bots ever give bot commands to other bots? Or is it just part of how Discord works, that bots don’t listen to other bots
other bots can't trigger your bot's commands (and so you can't trigger their commands too)
They can't?
well if we're talking about application commands no; prefix commands maybe
Thought so
i fixed the code but i really don't understand what is this
go to the website where you generated the bot's token and activate priviledged intents
ik but i can't find it
alr
I am building a discord RPG, using Replit where people can create a profile and adventure etc. I want to connect to a database so their progress remains even when the bot gets restarted. Which db is recommended?
any db is ok but i would suggest postgres
I am reletively new in this, so the most friendly db
Thanks
Traceback (most recent call last):
File "/home/runner/Atomic/venv/lib/python3.10/site-packages/discord/ui/view.py", line 427, in _scheduled_task
await item.callback(interaction)
File "main.py", line 129, in my_callback
created_channels.append(channel.id)
NameError: name 'created_channels' is not defined
Whats this error?
there is no list by that name
above that line of code, create a list called created_channels and your code will most likely work
you try to do stuff on varriable that is not defined
!e ```py
myList.append(1)
@slate swan :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 1, in <module>
003 | myList.append(1)
004 | ^^^^^^
005 | NameError: name 'myList' is not defined
I keep getting this error when submitting a response to my modal and then it responding to the interaction, thing is, it works sometimes and it worked perfectly fine before, but now with the same code it's causing this problem
discord.ui.modal Ignoring exception in modal <emailinputmodal timeout=None children=1>:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.11/site-packages/discord/ui/modal.py", line 187, in scheduled_task
await self.on_submit(interaction)
File "/home/container/creator_bot.py", line 961, in on_submit
await interaction.response.send_message(embed=embed, ephemeral=True)
File "/home/container/.local/lib/python3.11/site-packages/discord/interactions.py", line 778, in send_message
await adapter.create_interaction_response(
File "/home/container/.local/lib/python3.11/site-packages/discord/webhook/async.py", line 219, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
The code for the modal: https://paste.pythondiscord.com/guqeyufuxo
If I spam it, it works after like 10 tries
Your spreadsheet operation takes longer than 3 seconds
interaction must be responded in 3 seconds so you first defer the interaction than follow up
Is the discord bug fixed?
Yes
Finally
you need to defer the interaction
Thank you very much!
Thank you as well 
Is there a better module than better_profanity?
ok I need help
idk if it's just not set up right, but I can't figure out how to sync a simple test command
😐
Why?
well idk if it's wrong or something but it just isn't working 🤷
A basic slash command example for discord.py v2.x. - slash_commands.py
I was already sent this and it wasn't helpful. Robin's helping me out atm and it's definitely a larger problem than just that
kipmud
it wasn't?
😰
well the initial problem was a conflict with my client.event on_message
but that was just hiding more problems
I will say, being sourced the proper resources is definitely the right idea, sometimes it's nice to actually be listened out first because that's like the third time someone's linked that for my problem and nobody actually talked it through with me for 12h
until Robin popped in
well there's not much i can do until you actually describe your problem and link your code
It's simple, don't access attributes that don't exist
How do I reply with the invite that was created?
@bot.command()
async def invite(ctx):
channel = ctx.channel
author = ctx.author
await channel.create_invite(reason=f"{author} created an invite for {channel}!", max_age=0, max_uses=0, temporary=False, unique=True)
await ctx.reply()
!d discord.Invite.url
property url```
A property that retrieves the invite URL.
@commands.has_permissions(create_instant_invite=True)
@commands.bot_has_permissions(create_instant_invite=True)
@bot.command()
async def invite(ctx: commands.Context) -> None:
invite = await ctx.channel.create_invite(reason=f"{ctx.author} created an invite.")
await ctx.reply(invite.url)
this is all you need
max_age=0, max_uses=0, temporary=False, unique=True
these are the defaults so you don't need to include them
thanks
@commands.has_permissions(create_instant_invite=True)
@commands.bot_has_permissions(create_instant_invite=True)
also this is optional but a lot of servers deny members the permission to create invites
This command always returns (when there aren't any boosters): "[ ]"
I've been troubleshooting this one for a few days.
@bot.command()
async def boosters(ctx):
subs = ctx.guild.premium_subscribers
if subs == None:
await ctx.reply("There aren't any boosters! :(")
else:
await ctx.reply(subs)
you can use if not subs: instead
ok
and by the way when there are boosters, you shouldn't send the list
?
it will return something like [<Member id=998070081709932654 name="mudkip">, ...]
let me give an example
ok
!e ```py
ignore, pretend this is the discord.Member class
class Member:
def init(self, name: str) -> None:
self.name = name
def __str__(self) -> str:
return f'<Member name="{self.name}">'
__repr__ = __str__
boosters = [Member("mudkip"), Member("littlebluefeline")]
print(boosters)
print([booster.name for booster in boosters])
print("\n".join(["- " + booster.name for booster in boosters]))
@smoky sinew :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | [<Member name="mudkip">, <Member name="littlebluefeline">]
002 | ['mudkip', 'littlebluefeline']
003 | - mudkip
004 | - littlebluefeline
see the difference between the 3 of these
yes
you can also just do str(booster) instead of booster.name to get their discriminator as well
what does webhook.remove_embed() do?
what is that
discord.py does not have that method
it is for webhooks
discord_webhooks
why are you using discord_webhooks?
are you talking about this library? this has not been updated in over 3 years
because i am doing stuff with webhooks?
i wanted to know what it did since it seems to not be working
i just searched the source code and it does not have that method
so i don't know where you got that from
discord.py has its own webhook support
i typed in webhook. into visual studio code and looked at the auto completes
yeah it seems the auto complete has remove_embed but only remove_embeds (with S) works
idk i was looking around and that was the first thing that i saw. i have already fixed my problem so it's fine
how would I define this (my friend coded it)
what is it supposed to do
and it would probably be better if you just asked your friend
fixed
now im js having db issues..
I can recommend you to switch to postgre (its less code & more efficient, also use supabase connection with it to manage the db tables. e.g. https://supabase.com/)
@smoky sinew Quick question, trying to do a moderation & configuration feature that uses one single webhook to send a message with (e.g. For Welcoming, Audit Log Changes, Moderation Commands such as timeouts, etc.) But for some reason when i try changing the avatar to the author's avatar, it says it can't do it due to it not passing as a string but its already a string? (Also its saying that im passing it at bytes, im lost right now & i kinda lost my brain functionality doing this)
"""Webhook configuration to set everything up"""
try:
check = await self.bot.db.fetchrow('SELECT * FROM Webhook WHERE Member = $1', ctx.author.id)
webhook = str(check['webhook']) if check else await ctx.channel.create_webhook(name=name)
async with ctx.typing():
webhook_obj = discord.Webhook.from_url(webhook, session=aiohttp.ClientSession())
avatar_url = str(ctx.author.display_avatar.url) if avatar is None else str(avatar)
await webhook_obj.edit(name=name, avatar=avatar_url) # type: ignore
await webhook_obj.send('Edited **username** & Avatar (Melaine Webhook Notification)')
if check:
await self.bot.db.execute('UPDATE Webhook SET Name = $1, Avatar = $2 WHERE Member = $3', name, avatar_url, ctx.author.id)
else:
await self.bot.db.execute('INSERT INTO Webhook (Member, Webhook, Name, Avatar) VALUES ($1, $2, $3, $4)', ctx.author.id, webhook, name, avatar_url)
embed = discord.Embed(
description=f"> {ctx.author.mention}: {'Updated' if check else 'Created'} **Webhook** with name **{name}** & Avatar **[Your Avatar]({avatar_url})**",
color=Complexion.get_color(self, color_name='success')
)
await ctx.send(embed=embed)```
no..?
first of all supabase is a firebase alternive
it has nothing to do with postgres itself
i know it has nothing to do with the error but its used alot for database collections & its efficient
supabase is easier to use imo tho, thats just me, and its less code
aiosqlite is buggy & it does not have alot of functionalities like postgre
supabase is a backend as a service, i don't see why you would use it for the database functionality alone when it's essentially just a wrapper around postgres
and i don't see why SQL would be less code than just using a document database
its easier to manage tables & create them if you really don't know what you're doing when you switch
even mongodb is easier since you don't have to manage schemas
if you ever switch to mongodb at that point, just use json its literally doing the same thing
i know, its a joke
also if you can't manage tables why not just use pgadmin and that way you don't have to lock yourself into supabase?
it was just a suggestion, there are other good alternatives rather than aiosqlite
btw, do you know whats going on here? lol
aiosqlite is only a library to connect to sqlite
i don't see why you would want them to switch
i know that, im saying theres other alternatives for the wrapper
why..???
i just dont like aiosqlite to begin with, and its a suggestion to switch from me
okay???
the opposite is true, avatar is bytes and avatar_url is a string
also why do you have webhooks in a database
wait wait, what?
how is aiosqlite buggy
it was alot of connection issues for me
so my bot** IS** replying to mentions when it should NOT...
i tried adding a conditional statement py if not bot.user.mentioned_in(ctx.message): in the code.. but the bot still replies on mentionss...
https://srcb.in/H3qbwVPZsr
the on_message (it is in main.py the above link):
https://srcb.in/65ihHfKw0y
use mention_author=False
I didn't know the context but I never encountered such problem
does author not mean the user???
it does mean the user, can i see more of the code to assist you?
this is the main.py i.e the whole code: https://srcb.in/H3qbwVPZsr
i have alot of issues with it, it just sucks to me imo, but after i switched to postgre with supabase, everything is perfect & more efficient
if by connection issues you mean "Database is locked" errors, those are usually related to poor management of connections/transactions which an alternative lib won't solve, but regardless there's asqlite you can use https://github.com/Rapptz/asqlite
also one question
asqlite has a connection pool feature that I didn't see in aiosqlite nor sqlite3
not sure about the difference between using a pool and manually connecting each time
last time i used asqlite it was before danny implemented pools, but it looks like it starts up X threaded connections as soon as you create the pool
you're code is rather vauge.. its all of the place, i can recommend you to switch to cogs aswell, and i believe the issue with you're code is here:
async def generate_response_in_thread(prompt):
temp_message = await message.channel.send("https://cdn.discordapp.com/attachments/1098579202883735602/1113519006444429413/editor-0.6s-47px.gif")
response = await generate_response(prompt)
message_history[author_id].append(f"\n{bot.user.name} : {response}")
chunks = split_response(response)
for chunk in chunks:
await message.reply(chunk)```
on the `for` function, you're not calling `mention_author=False`, the correct statement should be:
```py
for chunk in chunks:
await message.reply(chunk, mention_author=False)```
i can't read all of the code since its all over the place so i really do recommend you switch to cogs & make you're own seperate cogs to do this (e.g. Make you're very own cog for you're management & proccessing codes)
no
usually you use a pool if you're concerned about re-connecting too often or creating too many concurrent connections
this is an issue with the bot replying to other user's replies
i can't read the code its all over the place 👬
still no, it's nothing to do with replying
he said the issue is with the bot replying and mentioning users, right?
take a look at their actual problem and actually read their message, instead of just making "switch to x" statements
no, it's with the bot responding to messages when it's not supposed to
@wispy pasture why do you have this check? ```py
is_replied = message.reference and message.reference.resolved.author == bot.user
trying to find a dev team I have a vps
i see....
to check if the bot is replying to the same person who ased it to send a question
you're checking if the author of the message is replying to the bot though
so i did the opposite thing i meant to do??
i think so
the bot is still replying just not mentioning
what is your bot's expected behaviour?
when should it be replying
and when it should not
it should also be replying to users in the channel which is set using /toggleactive... ONLY
other than the channel set using /toggleactive the bot can not reply on MENTIONS only...
a reply is technically a mention
in other words: when a user replies to the generated image (/imagine) with anything.. such as "nice" "cool" the bot should not reply, but if the user is talking with the bot in the channel set using /toggleactive the bot should reply...
the bot should not reply on the embed...
see picture 1.. the bot should not reply here...
see picture 2... the bot should reply
it is replying is picture 2 tho?
this is pic 2
yes?
this is pic 1...
the bot did reply to the prompt in 2?
yes it did... which it should, cause thats the AI chat channel
but it should not reply to the pic embed it sends: cause thats the image generating cmd not the AI chat
is that channel the channel with ai chat toggled?
nope...
or is the channel in both pics same
different channels
you should probably check your active channels set or channels.txt to be sure
alright lemme check again
i just did... the id is not there... only the channel of AI chat is there
try logging is_active_channel being True or not
a;right
oh you are using or
I was being stupid all the time
so if any of the condition is met it will reply
maybe something like
if is_active_channel and (is_allowed_dm or contains_trigger_word or is_bot_mentioned or is_replied or bot_name_in_message):
thank you, me was being dum dum
@north kiln
now the bot wont work without being mentioned even in the active channel
You set it like so look at the conditions
From what I see your on_mesaage is only used for ai chat so if you want every message in active channels to act as a prompt then you don't need those conditions
Only checking the channel is enough
aha alright alright
if i'm understanding correctly you're not changing the length of ctx.member.roles in the loop
or i
I'm using it to filter the roles
How i do it?
how do I recreate this welcome image from mee6 bot putting words over photo with py code
!pip pillow use the pillow library
@client.tree.command(name="random-colour", description="sends a random colour")
async def randomcolour(interaction: discord.Interaction):
embed = discord.Embed(title="here is a random colour", color=discord.Color.random())
embed.add_field(name=f"")``` how can i send the colour name and hex
Something like that iirc
c = discord.Color.random()
print(c.r, c.g, c.b, c.value)
You'll get the integer representation of R, G & B and the overall integer value
Which you can convert to hex easily
thanks
also how can I check for an author's perm in an on_message event?
message.author.guild_permissionsmessage.channel.permissions_for(message.author)
All from a quick search in the documentation :)
thanks
Next time you can try searching your own as well ^-^
sorry
Not meaning it negatively, it's just good to search on your own sometimes, that way you learn and prepare yourself better for the future
👍
Alright
hi, why i cannot import discord.ui
what have you tried, and what's the error?
here
i dont know why
i have tried this one
import discord.ui
also the same error
What is your dpy version?
how to check
i want to make slash command in file test.py, i have my socket server in file named bot.py , and i want to send data to socket from test.py. could anyone tell me how can i do that?
what is the actual warning?
1.7.3
you need to update
how to update
pip install -U discord.py
ok tks
on cmd or in the cmd of file
cmd
right
still not work..
what command did you run
i've copied yours
what does pip show discord.py show the version as
here
ok, run pip -V and note the python interpreter version and path. Is it the same as the one VSC is using?
what should i do
now check which python interpreter you've set in vscode
click on that in the bottom bar and make sure it's path is the same
how...
here
not the same, how can i make it same
click the Global one, that's the one linked to your pip command
okay
The recommended one is a venv, are you using a venv for this project?
then you should use that, activate the venv and then install discord.py there
using the global interpreter is more of a bandaid fix
okay
MS Store Python 😨
pypypypypypy
Old code i found on one of my hhds, which were repositories i deleted at some point so i recreated them
I cant even remember writing it
what’s up?
enjoy ☺️
Funnily I also had it a few weeks ago
what disdata?
I also made discorddb because i forgot completely about disdata
?tag cogs
This is not a Modmail thread.
guys there is a documentery or something can i get info about cogs?
!d discord.ext.commands.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
thanks i was searching that
What library
I have a small code for a Discord bot, but I don't fully understand how to edit a webhook. I want to add new text to the existing text in field 3. Can you please advise me on how to do it
what is your expected result
its failed result
need to fix it. I don't understand how to do it.
can we use discord component anymore?
.
It's probably been like the 4th or 5th time just sending the image with "help" beneath it and that's it 
how can i do with pycharm
Here i am trying to check if the antinuke_setup is enabled
if it's false, return
But in my case it was true and still sending the error
for some reasons if database.antinuke_setup is still false even after being turned to true
issue fixed, using .save()
how do i make tax possible in python with precentages?
afk_list is not defined
ah wait it is my bad
More of a question for #1035199133436354600
this doesnt work for me for some reason im trying to change everyone's name to the argument name but it wont do it
Does the command get executed in the first place, e.g. what happens if you add a print("test") at the beginning of your command's code
Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
but why is that
Permissions are existing
no
bot doesn't have permission to change the server owner's nickname
or any role above it
also you have no permissions checks
i gave him the highest role in the server but he didnt change other members that has lower roles
maybe it errored and didn't finish
i have an isinstance at on_command_erorr
why not just use has_permissions and bot_has_permissions
If it tried to edit the first member and it didn't have permissions, it would entirely stop the loop
he does have permissions tho
but anyone could use the command
to set anyone's nickname
right....
just checked it on an alt and youre right, he doesnt replay with on_command_erorr
so what should i do
@commands.command(help="whitelist a member", usage="[member]", description="antinuke")
@commands.cooldown(1, 2, commands.BucketType.user)
@commands.has_permissions(administrator=True)
async def add(self, ctx: commands.Context, *, member: discord.Member=None):
if member is None: await self.commandhelp(ctx, "whitelist add")
async with ctx.bot.db.cursor() as cursor:
await cursor.execute("SELECT * FROM whitelist WHERE guild_id = {} AND user_id = {}".format(ctx.guild.id, member.id))
check = await cursor.fetchone()
if check is not None: return await ctx.reply(embed=discord.Embed(color=0x2B2D31, description=f" {ctx.author.mention}: This user is already whitelisted"), mention_author=False)
await cursor.execute("INSERT INTO whitelist VALUES (?,?)", (ctx.guild.id, member.id))
await self.bot.db.commit()
await ctx.reply(embed=discord.Embed(color=0x2B2D31, description=f" {ctx.author.mention}: Whitelisted {member.mention}"), mention_author=False)``` can someone help me fix an error with this code
2023-06-01 14:57:48 ERROR discord.client Ignoring exception in on_command_error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/ext/commands/core.py", line 229, in wrapped
ret = await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/drake/Desktop/deadbot/cogs/mod.py", line 163, in add
async with ctx.bot.db.cursor() as cursor:
^^^^^^^^^^
AttributeError: 'Bot' object has no attribute 'db'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "/Users/drake/Desktop/deadbot/cogs/events.py", line 25, in on_command_error
raise error
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1023, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/discord/ext/commands/core.py", line 238, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'db'```
The error says it all, Bot doesn't have a db attribute
Create a bot variable named db
and your SQL query is wrong i believe. (for inserting), i may be wrong im not too familiar with SQL
Or create your custom bot class with that attribute and set it accordingly
so py db = bot
no. thats making a variable not a class
i have self.bot in my class setup
Yeah it's more something like
INSERT INTO table(col1, col2) VALUES(val1, val2)
yeah i thought so
Unless you put all columns
Then you don't need to specify, it's just better to always specify to prevent ambiguity
I may js start using psql ppl keep telling me that
Take a look at classes in Python first, and some basic OOP as it's a knowledge you must have to use discord.py
i added, but still not working
class mod(commands.Cog):
def __init__(self, bot):
self.bot = bot```
That's not a custom bot class, no
nvm
for
idk as a db
it's manage_nicknames
where did you get change_nickname from
you also need bot_has_permissions
should I js stick w/ sqlite?
yes
takes argumants?
?
thats how you do it
now you removed has_permissions
no wait
so everyone can change the nicknames again
no i get Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
you don't need the aliases part either, you can just set your bot to case_insensitive=True
@commands.guild_only()
@commands.has_permissions(manage_nicknames=True)
@commands.bot_has_permissions(manage_nicknames=True)
@bot.command(description="Edits everyone's nickname in the current server.")
async def nickname(ctx: commands.Context, *, nickname: str) -> None:
for member in ctx.guild.members:
if (
ctx.guild.owner == member
or ctx.author.top_role <= member.top_role
or ctx.guild.me.top_role <= member.top_role
):
continue
await member.edit(nick=nickname)
you need to check if the member is above the bot
and the person trying to edit the nicknames
client_has_permissions and not bot_has_permissions
i put both
wrong
thanks for this!
client_has_permissions does not exist
oh ok.
only bot_has_permissions and has_permissions do
oh ok never new
@smoky sinew what does the two ors mean
to make sure the bot and the person running the command have permission to edit the person's nickname
got it
thanks!!!
@smoky sinewhow can i do it that only the owner of the server can do this command?
and how do i do the case sensitive?
!d discord.ext.commands.Bot check here
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
midkup could u help me with a issue?
my name is 6 letters 😭

Here i have this function that i'm calling in multiple commands
Basically a manager for all protection antinuke has
anyways, how could i get the guild.id inside of the database var ?
huh
@smoky sinew i replaced has_premissions to commands_is_owner() is it good?
no
that is owner of the bot
that's only for the bot owner
not server
class AntinukeSettings(Cog):
@slash_command()
@default_member_permissions(administrator=True)
@is_guild_owner()
async def antinuke(self, interaction: CommandInteraction):
guild_id = interaction.guild_id
database = await AntinukeConfig.get_or_none(guild_id=guild_id)
if not database:
logger.info(f"Creating antinuke config... for={guild_id}")
database = await AntinukeConfig.create(guild_id=guild_id)
logger.info("Created.")
async def set_prop(self, group: str, prop: str, toggle: bool):
logger.info(f"Trying to set {prop}...")
key = f'{group}_{prop.lower().replace(" ", "_")}'
database = await AntinukeConfig.get_or_none(guild_id=self.guild.id)
setattr(database, key, toggle)
logger.info("OK.")
oh 😦
here's an example of how i use the set_prop
where are you setting self.guild though
That's something i tried
inside of antinuke creating self.guild = guild
but that doesn't matter cause it didn't really work
u have to set it in your antinuke function like
self.guild_id =
not
guild_id =
is your bot for one server?
What i have to do is to get the guild id inside of the function
@dry kelp
yea doing this for fun
guild_id is the primary key in my model
that has nothing to do with what im trying to do
still it's bad to hardcode it to only work for one server
if you set your bot as private it would work
but it would be hard to transfer to other servers
but it causes issues when the bot is running on prod
and also when invoking command multiple times
why not just pass guild into the method
so why not add a new argument to set_prop
But in order to get_or_create i have to call the model using the primary key, to defer guilds
Because i don't need to do that
all i need is a function inside of the command, it's like a external that im calling
But the only problem is that i need to get the guild id
is it possible?
why not
from what i'm hearing
it sounds like you need to set a setting value for the current guild
Because to make my life easier i could just make this function inside of commands
But is not a good practice
you could do py @commands.has_permissions(administrator=True) which the command will only work for people with the admin perm and the owner already has it
that's not what i said to do
yeah that's the easiest way to do so
So look here is a thing that im thinking about
inside set_prop it will only be called if there's an existing guild id
it won't be called if there's not a existing guild id
So database will always be true
can't i fetch the guild id from model?
what is the group argument
So group will be protections
in this screenshot you pass 4 arguments
1 sec lemme explain
So look, here u can see this is anti_guild command
The items will be all possible securities for that certain command
So basically this is the group of "guild" protections
oh
Yeah it was made to make my life easier
So what do u think?
i am getting the error:
"discord.app_commands.errors.CommandAlreadyRegistered: Command 'help' already registered."
but i have this line:
client = commands.Bot(command_prefix='+', intents= discord.Intents.all(), help_command=None)
discord.app_commands.errors.CommandAlreadyRegistered
None
Error is: unterminated string literal
I don't think there's anything wrong with my string though?
embed = discord.Embed(title = f"{message.author}", description = f"Message from {message.author.mention} deleted in {message.channel.mention}.", colour=discord.Colour.red())
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
!traceback embed = discord.Embed(title = f"{message.author}", description = f"Message from {message.author.mention} deleted in {message.channel.mention}.", colour=discord.Colour.red())
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
you don't seem to know what a traceback is. he asks you to send it, not just put !traceback in front of your code 🤦♂️
I fixed it, I just changed it from double quotes: "str" to single quotes: 'str' (I probably had smart quotes: ”str”)
aight, then it seems like the code you showed us didn't match your actual code, as that shouldn't happen
I did copy and paste, so idk
those strange quotations happen on mobile or by copy pasting code from somewhere sometimes
ok
how can i make slash command...
A basic slash command example for discord.py v2.x. - slash_commands.py
i wrote this basic example
more examples are available here:
https://github.com/Rapptz/discord.py/tree/master/examples/app_commands
any error with sync...
what is the error
idont know but it can not run the bot.tree command
@bot.event
async def on_ready():
print('Bot is ready.')
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} command(s)")
except Exception as e:
print(e)
class TestMenuButton(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Join", style=discord.ButtonStyle.blurple)
async def test(self, interaction:discord.Interaction, Button: discord.ui.Button):
await interaction.channel.send(content="Joined")
@discord.ui.button(label="Start", style=discord.ButtonStyle.green)
async def start(self, interaction:discord.Interaction, Button: discord.ui.Button):
await interaction.channel.send(content="Started")
@bot.tree.command(name="Play")
async def Play(interaction: discord.Interaction):
await interaction.respond.send_message(content="Starting", view=TestMenuButton())
i'm not sure what that means
Is it just not printing?
cannot run at all
cannot run
I just want to create a command when it runs will have to button
What do you mean? How do you know it's not running? And what isn't running?
the tree command
What's the tree command? What about it?
creating the command that send message with 2 buttons
What about it?
just that, because it is my first step
say what you expect to happen and what is actually happening
I expect when I use the slash command name play, it will display the message with 2 button name Join and Start.
and what actually happens?
does the slash command appear in your command list?
and if so, are you able to run it or do errors appear in the terminal? does the buttons and message appear?
the bot can not run
here is my code
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
how do I identify if a slash command is used as a reply to a message? and how do I fetch the details about that message... such as the author of the message or the message content?
Slash commands responses do not reply to messages 😀
Since slash command itself is not one
oh yea right
i forgot
but how do I make work this in in normal prefixed commands?
You want to get a message the command replies to?
yes
ctx.message.reference.resolved
is it a if, else
oh i see
@discord.slash_command(name='mock', description='🐒 DoNt mOcK mE!')
async def mock(self, ctx: discord.ApplicationCommand):
test_str = ctx.message.reference
res = ""
for idx in range(len(test_str)):
if not idx % 2:
res = res + test_str[idx].upper()
else:
res = res + test_str[idx].lower()
await ctx.respond(res)
If no reply the reference will be None iirc
i tried smth like this
No man there's no message in slash commands
yea i think i can put that in a if, else...
yes yes
It will only work for prefix
hmmm
Instead you can just do message command lol
yep!
but then what do I pass in ctx argument?
like I have it as ctx:discord.ApplicationCommand
what do I replace it with?
no lmao
Then what is this
I heard pycord is like the worst out of dpy forks
But here's an example https://github.com/Pycord-Development/pycord/blob/master/examples/app_commands/context_menus.py
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/context_menus.py at master · Pycord-Development/pycord
iknow
pycord is shit
but its working for me so i don wanna touch it
one of the most important rules of programming... if it works dont touch it
Tbh that's rule of beginners and non-professionals
Does pycord auto sync slash commands 
The program needs to be
- working
- readable
- efficient
At least
Sometimes efficiency can be sacrificed for readability tho
real
Do you guys think that 2nd bot is ok ?
and wich utils / moderation commands should i add ?
(they are all functionnal, feel free to ask to see)
Why do people create second, third, fourth, etc. bots instead of focusing on one and then those bots just have the same commands as all bots have. Come on, be original 
The seconde was juste trash, its just a utility bot dude, not more
a private one, just to not be unoriginal and not just having mee6 

Look what other bots have, copy
i wanted to do a /code
And bots don't have RPC
So you can't have a RPC command
then do it duh
What
@discord.ui.button(label="Ban", style=discord.ButtonStyle.green, emoji=":hammer:")
async def ban_button(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message("Sunucudan yasaklandı")
await self.member.ban(reason="5 uyarı aldı")
AttributeError: 'Button' object has no attribute 'response' ```
I couldn't solve the error
wrong param order
it's supposed to be interaction that comes first
what should I use


