#discord-bots
1 messages · Page 1143 of 1
Returns an object responsible for handling responding to the interaction.
A response can only be done once. If secondary messages need to be sent, consider using followup instead.
what is Inter?
custom class? if yes, what does it subclass
no, just do create_channel.send('test') instead of message.channel.send("test")
disnake.ApplicationCommandInteraction
remove () from message.content
oh ic, so you type hinted with the interactionresponse, but it still highlights for interaction
yk what forget it :D
Interaction has channel and reponse too btw...
where can i find the slash docs? like for the slash commands
look for it in the docs of the library you use
I would like a bot to save status, username and activity data to a json file do you think this would be a good layout or do you have any improvement ideas?
this is my first time using json so if something is wrong with the format please tell me. 😄
{
"109238457190284375": {
"2022-07-04 16:30": {
"NAME": "User#1234",
"STATUS": "Offline",
"ACTIVITY": "None"
},
"2022-07-04 17:00": {
"NAME": "User#1234",
"STATUS": "Online",
"ACTIVITY": "Spotify"
}
},
"577817213575102464": {
"2022-07-04 15:12": {
"NAME": "User#1234",
"STATUS": "Offline",
"ACTIVITY": "None"
},
"2022-07-04 17:00": {
"NAME": "User#1234",
"STATUS": "Online",
"ACTIVITY": "None"
},
"2022-07-04 20:19": {
"NAME": "User#1234",
"STATUS": "Offline",
"ACTIVITY": "dnd"
},
"2022-07-04 22:15": {
"NAME": "User#1234",
"STATUS": "Offline",
"ACTIVITY": "None"
}
}
}
Depending on the size of the server and what changes you are tracking that will very quickly become a bottle-neck for reading/writing the file.
anyway to get this to play multiple different gifs? like maybe 5
hmm so you think json is not good for this?
At once? Or one after another
after another
like >>highfive then one gif then >>highfive again a different gif that highfives
best way is to pil append them all
or u could just use a for loop to edit the message attachment
It will completely depend on the scale, how often you update the file, and the performance you expect. This is a good application, in general, for a database such as sqlite3.
!d itertools.cycle
itertools.cycle(iterable)```
Make an iterator returning elements from the iterable and saving a copy of each. When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely. Roughly equivalent to:
```py
def cycle(iterable):
# cycle('ABCD') --> A B C D A B C D A B C D ...
saved = []
for element in iterable:
yield element
saved.append(element)
while saved:
for element in saved:
yield element
```...
everytime someone is changing statis activity or status
thanks
is someone able to help me setup a api? for sending images
Do button labels have a limit on how long they can be? is 36 chars too long? and what happens to buttons with long labels, does it splice a ... when it's too long or does it make the button longer? (dpy 2.0)
it will simply error out if the request posted was too long, and idk the limit
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
okay thanks Ashley
80 character limit, welcome
How can I delete a message if it contains a certain word?
Right now I have
async def on_message(message):
if str(message.channel) == "mod-log" and message.content == "test":
await message.channel.purge(limit=1)
But that only deletes it if its ONLY test ...
do await message.delete()
nextcord, but i cant find them
async def Geschlecht2(ctx):
channel = bot.get_channel(985970666643816498)
message = await channel.send('Was ist dein Geschlecht?(Weiblich)[Reagiere auf die nachricht]')
await message.add_reaction('♀️')
role = ctx.guild.get_role(992450008051875930)
await ctx.author.add_roles(role)
@bot.event
async def on_raw_reaction_add(reaction, user):
Channel = bot.get_channel(985970666643816498)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "♀️":
Role = discord.utils.get(user.server.roles, name="Weiblich")
await user.add_roles(Role)```
hi guys i have a problem, it only works for the first reaction how can i fix that?
thank you
import discord
from discord.utils import get
from discord.ext import commands
import os
import asyncio
discord_token = "..."
client = commands.Bot(command_prefix=";")
client.remove_command("help")
@client.event
async def on_ready():
print(f"The One and Only, THE {client.user} HAS JOINED")
#Kick
@client.command(name="kick", aliases=["Kick", "KICK"], description="Kicks the Specified User") #might change
@commands.has_permissions(manage_messages=True, manage_roles=True, kick_members=True, ban_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
if not member:
await ctx.send("Who do you want to kick?")
return
if member.guild_permissions.administrator:
await ctx.send("Mr {ctx.author.mention}, you can't softban an admin")
return
if member == ctx.author:
await ctx.send("Imagine trying to kick yourself! ***LOL***")
return # Add Extra things Later
else:
embed = discord.Embed(colour=0xFF0000)
embed.set_author(name=(f"User Kicked | {member}"), icon_url=member.avatar_url)
embed.add_field(name="User", value=(f"{member.mention}"), inline=True)
embed.add_field(name="Moderator", value=(f"{ctx.author.mention}"), inline=True)
embed.add_field(name="Reason", value=(f"{reason}"), inline=True)
embed2 = discord.Embed(description=(f"**You were kicked from {ctx.guild.name}... Noob**"), colour=0xFF0000)
embed2.add_field(name="Reason", value=(f"{reason}"), inline=True)
embed2.add_field(name="Moderator", value=(f"{ctx.author.name}"), inline=True)
await ctx.send(embed=embed)
await member.send(embed=embed2)
await member.kick(reason=reason)
client.run(discord_token)
So I have made this bot which kicks specified users, but the problem is that altho there is no problem and no error in the code(the bot is online in the server), the command doesnt seem to work at all. I have seen someone that has the same problem and reddit but I didnt find the solution there. Anyone know how to fix this problem?
Does the function get executed at all?
Like, if you try to kick yourself, will it show that message you put?
no
nothing
nothing appears at all
You may have a badly written global error handler
Well, I thought that was the entire program above
yeah but like i tested the same code a couple of days ago and it worked perfectly
Maybe message events are not getting dispatched
dk
i dont know why it suddenly stopped functioning
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot 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
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
1 sec ill c
nope
You don’t have them enabled?
My bot can run but don't reply anything.
It shows up it is online but if I input !$help, it doesn't show up anything.
The (token) here will be replaced by the real token.
This is my code:
import discord
#import io
import random
#import textwrap
#import urllib
#import aiohttp
#import datetime
#import os
from discord.ext import commands
from itertools import cycle
from webserver import keep_alive
client = commands.Bot(command_prefix = "!$", case_insensitive=True, help_command = None)
token = "(token)"
keep_alive()
@client.event
async def on_ready():
print('Ready, Set, Gooooooo')
await client.change_presence(activity=discord.Game(name="Your Server"))
@client.command()
async def help(ctx=None):
embed = discord.Embed(
title="Help Index",
description="Got lost? These might help you",
color=discord.Color.purple()
)
embed.add_field(name="Official Website", value="https://miracle-dev.netlify.app/", inline=True)
embed.add_field(name="List of commands", value="https://miracle-dev.netlify.app/commands.html", inline=True)
embed.add_field(name="Support Server", value="(invitelink)", inline=True)
await ctx.send(embed=embed)
client.run(token)
status = cycle(['Miracle', 'CreateByVio'])
It doesn't have any error code
hello
you leaked a whole ass token
maybe not the whole
reset your token on discord.com/developers
ik
and i replaced the token aswell
before ur message
anyways what's the matter
it wont work
like the bot wont come online
still it isnt working
well, is the token right?
yea
and after typing on_ready with an underscore, did you save the code, kill the terminal and run the code again?
Is there discord.User.ban and discord.User.unban ?
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
and discord.Guild.unban
ohh
discord.Guild.ban takes a user if you only have a discord.User object
yeah
first realisation then agreement
is this a "yes I did" or an "oh yes I will do it now"
In that case i would pass "discord.Member" instead of "User"
no you don't pass discord.Member, you call a method of a discord.Member object
i mean in my command function
@bot.tree.command(name="ban", description="Ban out a member.")
async def _ban(interaction : discord.Interaction,
member : discord.Member,
reason = None):
yeah sure
i want to know is setting reason to None means parameter reason is missing ?
TypeError: parameter 'reason' is missing a type annotation in callback '_ban'
None is not that its not defined, it just nothing in it
imagine it as saying theres nothing there vs there being nothing there
in a way
it's missing a type annotation
the : str part
could u help?
why is it indented
first ss it's not
that's why sending code in text is better
the error's also not related to the channel
i didn't put any : str if you mean i should put a type in that reason, i can put "Nothing" as a value right ?
the = None part works
but you need : str
because in slash commands discord has to tell you what it wants you to put there
reason = None : str
does discord.py support slash commands? i thought it didnt, it was gonna stop being supported because of it
reason: str = None
it does
See the pins, second one
send your error
your annotation is wrong lol
it would be reason: None | str = None
idk how to do it
learn
!d typing.Union
typing.Union```
Union type; `Union[X, Y]` is equivalent to `X | Y` and means either X or Y.
To define a union, use e.g. `Union[int, str]` or the shorthand `int | str`. Using that shorthand is recommended. Details...
im dumb
we wont teach you, more fix learning
looks cleaner imo
look at examples
did
ew
🔫
they all dont work
i would disagree ngl
operator over referencing a class
and either way Union wouldnt be the cleanest impl
!d typing.Optional
typing.Optional```
Optional type.
`Optional[X]` is equivalent to `X | None` (or `Union[X, None]`).
Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the `Optional` qualifier on its type annotation just because it is optional. For example:
```py
def foo(arg: int = 0) -> None:
...
``` On the other hand, if an explicit value of `None` is allowed, the use of `Optional` is appropriate, whether the argument is optional or not. For example...
how can i make it so the user can select a channel with an modal?
huh
Why does this not work? message.author gives me user instead of member for some reason.. No DM's, only Guild Messages
@bot.event
async def on_message(message):
if not message.author.guild_permissions.administrator:
# Error
Error: 'User' Object has no attribute 'guild_permissions'
the message is from a dm
hence why Message.author returned a User obj over a Member obj
what
Can I check if the message was sent in a channel instead of DM?
just check if guild is None
!d discord.Message.guild
The guild that the message belongs to, if applicable.
why if bot.ready
I still get 'User' Object has no attribute 'guild_permissions'
cuz you switched != and ==
it's a variable just ignore
you did
if no guild: do guild shit
if not*
what do you guys mean
dumbo code
exactly this
it's right?
if guild is not none -> if guild: do guild shit
you can use isinstance as well
just do the first check
you can if message.guild: do guild shit
and remove if bot.ready
also what's attachement_delete
prolly your own func
yea
it deletes an attachement after 15 minutes
but doesn't matter in this case
wait wth
@slate swan @cold sonnet
I got it now. It was because the on_message Event was triggered by the webhooks that were sent in our server. Since they can't be viewed as a member it gave me that error.
thats so funny to me, a webhook invoking a command😭💀
is there a way to check if a user has the phone number verified? 🤨 i know about .VerificationLevel but that's to check guild's one
Ares👁️👁️
Not a command, an Event
lol
zam, didn't see u in a while
didn't touched any code in months
and now i forgor
so about my question 
im not sure if you can, but you can check the email or 2fa
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
not sure if dpy handles it tho
i don't use dpy tho 🗿
disnake right?

already checked their docs and src :((
well tbh, i don't think so there's any valid way to check the phone number, i wanted to handle the interaction error it gives when you try to select an option from dropdown but the channel requires to have ur phone number verified
and if u don't yk, not even reacts won't work, but well, i guess i can live with that error since it doesn't affect the actual code
it seems like its not given ig
{
"id": "80351110224678912",
"username": "Nelly",
"discriminator": "1337",
"avatar": "8342729096ea3675442027381ff50dfe",
"verified": true,
"email": "nelly@discord.com",
"flags": 64,
"banner": "06c16474723fe537c283b8efa61a30c8",
"accent_color": 16711680,
"premium_type": 1,
"public_flags": 64
}
the example structure only shows a verified key
which is their email verification
Hi guys I’m new to the discord bot development world do you have any suggestions how to start the whole journey? I have no idea about discord bot token etc. I was just a normaln discord user for 4 years but now I decidet to became discord developer and if anyone can give me some tips where and how to start i would be really gratefull
how can i make it so it saves the given channels id in the file?
Are you making a txt for each guild for settings?
Do you have an intermediate knowledge of python?
Is it possible to have dropdowns inside of a modal or not currently ?
modals only support text input components as of now
though looking in discord developers server, i think its in the works
Yeah selects work but I’m pretty sure it’s undocumented as of now and stuff
I saw it be used in dpy server
?tag modal select in dpy server if u want
oh shit yeah it does work
now if only the text inputs could render discord markdown
thnx o_O
doesnt show up on iOS and android tho
is it only the canary version of discord on desktop that supports it?
oh uh thats unfortunate, think i gotta postpone my plans to add it then
i was hoping to migrate my tag commands to modals, but unfortunately i finished the prototype over a night only to find out that the input boxes dont autocomplete markdown tags and channel mentions, so i just scrapped it
anyone know?
he doesn't need to though it is recommended to use aiohttp in most cases
It's an async command.
ah
he should use aiohttp so you actually give the function to the event loop
blind eye
alr
aiohttp helps avoid async/await?
no its asynchronous
requests is blocking which is why you shouldn't use it
when dealing with asynchronous things
well i got another error list indices must be integers or slices, not str
ctx, *, ipaddr: str = '9.9.9.9'
its a string bro
you index them with ints
i did hold on i got this error
you tried to annotate the arg as an int but gave it a default value that isnt an int
so it had a conversion issue
Python is an interpreter but not an 🍎
?
Non ableist language makes it nearly impossible to self incriminate or say something sucks.
Therefore an apple
:( apples are smart ok
Anyone know how I use the userid of the user who uses a command?
!d discord.ext.commands.Context.author
Union[User, Member]: Returns the author associated with this context’s command. Shorthand for Message.author
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.id "discord.User.id")
Like in discord.py
The user’s unique ID.
^^^
im correct :))
so how would I mention the userid In discord.py?
you want to mention the user who invoked the command or?
@cold tide
Precisely
!d discord.Member.mention
property mention```
Returns a string that allows you to mention the member.
ctx.author.mention or interaction.user.mention
panda spoonfeeding today
Heh
i encourage people to learn and actually learn how to read a packages documentation ;))
you have a brain!?!?!?
no
i can play that game too
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
-goes ot
-says !ot
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
That's the way the cookie crumbles.
..Some other Modal..
async def callback(self, interaction: discord.Interaction):
password = self.children[0].value
if password==Actual_Password:
InputList=[]
for i in range(0,5):
InputList.append(self.children[i].value)
await interaction.response.send_modal(Feedback2(Value="New Hero"))
else:
embed = Embed(title=f"Password was found incorrect, Mr.{interaction.user.display_name}!",color=Colour.red())
await interaction.response.send_message(embed=embed)
class Feedback2(discord.ui.Modal):
def __init__(self, Value):
super().__init__(custom_id="Hero Add2", title="Hero Add Part 2")
self.add_item(five_Star_Ability)
self.add_item(WAR)
self.add_item(DEF)
self.add_item(CMD)
self.add_item(exclusive_Skill)
...some callback...
```
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {4, 5, 6, 7}.
hey how would i collect user info when they join a discord server
i thought about on_member-join() but i really dont know how to use it
Which line?
await interaction.response.send_modal(Feedback2(Value="New Hero"))
for example the date the joined
Can you send full exception? This isn't helping
Traceback (most recent call last):
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\modal.py", line 260, in dispatch
await value.callback(interaction)
File "e:\Python Projects\Top-War-Bot-Re\Input_Forms\Hero_Input.py", line 174, in callback
await interaction.response.send_modal(Feedback2(Value="New Hero1"))
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 901, in send_modal
await self._locked_response(
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 933, in _locked_response
await coro
File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 213, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In type: Value must be one of {4, 5, 6, 7}.
@bot.command()
async def dm(ctx, user: discord.User, *,message=None):
message=(f"Dm From {ctx.author.send}",message)
Can anyone help?
I can't use indentation here sadly.
You can just use on member join and use datetime.now and for user info, interaction.user
It doesn't show the user who triggered the cmd
@bot.command() async def dm(ctx, user: discord.User, *,message=None): message=(f"Dm From {ctx.author.send}",message)
what if i want to get like a user id
or are there a bunch of tutorials on that
on things like that i should say
interaction.user will give you the user object, you can get everything available from there.
i think you need to have Member intent enabled though.
making this ticket command it works great just wondering if there's anything i should add to make it better? that i could be missing
is interaction.user automated?
uh ?
like is it ran autmatically
or will they have to do something in discord
sending a message creating a event in someway
as you said earlier, on member join
@tough lance Sry for the ping, dont know if you are aware that i sent this...
ctx.user if its a user triggered function,i think.
(edit: if you want a single place to create tickets from,) you'll need a database to store your bot's ticket messages and have a listener to check reactions, otherwise after a restart, your bot wont know what messages it needs to look for
also tickets are usually private, so to set the permissions you'll need to provide an overwrites= kwarg to create_text_channel()
(ive written an example of overwrites earlier here <#discord-bots message>)
To my knowledge binary tree roots using pointers and numpy arrays is the hardest to implement in discord bots.
Luckily that’s an extremely low use case so knowing how to do that is not really important in the context of discord bots
thank you
Could someone help with this
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type
modals cannot respond with followup modals unfortunately
wait im dumb 😭
nevermind i got it hah
can you send embeds in dms?
or is that not possible cuz of self bots
How can we add permission to a command?
yes, you can
like where it would be only people with kick members can do the command
ah okay
slash commands or message commands?
I wanted to add that people will manager server can use the message command
but what command? is it a slash command or a message command? /command [...] or ?command [...]?
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
How do to with manager server permission?
I am getting error with that
you add the decorator to your command, and then set manage_guild to True
I typed manager_server
if the user that invoked the command doesn't have the permission that you added, it'll raise MissingPermissions
Oh 🥲
I have error handler
I'm trying to found out how I can only make certain roles access comands can anyone help? Couldn't find any source online.
https://stackoverflow.com/questions/54845875/how-do-i-check-if-a-user-has-a-specific-role-in-discord
First search result 💀
!d discord.ext.commands.has_roles
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
its a decorator
Just found the source but Thankyou!
if you're talking about the stackoverflow link its super outdated, the decorator part is correct tho.
Hi sarthak
hello 👋
can someone help me with my discord bot pls?
i want it to add reactions to its own message when sent but idk how to do it
Hey im making a discord bot but when i use this decorator it gives me this error code
@client.command()
async def displayembed():
pass
make a bot instance like
bot = commands.Bot(commands_prefix="!")
@bot.command()
async def displayembed():
pass
sparky edgy pfp
commands.Bot(...)
change it to @bot.command()
that didnt work either
show
huh?
.
bot.command()
😭
remove the discord. in the decorator
doesnt work either
no way
wait
show
naw i didnt try that it works
nice

You always hate my pfp
sparky show us what you made
oh sorry ;-; its my computers datetime
it doesnt update for some reason
i update it everytime i start
i gorn to repair it
but after somedays it starts again
👀 this shows that i havent started my pc from another 16 days
i was making a help command
hardcoded or subclassed
subclassed
nc
neat
try it
the paginator doesnt work
i havent did anything yet in that
just the choose command and category works
hikari-lightbulb has a built-in help command that is already paginated
oh :p
try making your own paginator
ye indeed
@commands.command(description="Sends help")
async def help(self,ctx : commands.Context,help=None):
if help is None:
await ctx.reply("** **",view=DropdownView(self.bot))
class Dropdown(disnake.ui.Select):
def __init__(self,bot : commands.Bot):
self.bot = bot
options = []
for cogs in self.bot.cogs:
options.append(disnake.SelectOption(label =cogs))
super().__init__(placeholder='Choose the category', min_values=1, max_values=1, options=options)
async def callback(self, interaction: disnake.Interaction):
abh = self.values[0]
a = self.bot.get_cog(abh)
em = disnake.Embed(title=abh,color=aqua)
sdf = []
for cmds in a.get_commands():
em.add_field(name=cmds.name,value=cmds.description)
sdf.append(cmds.name)
await interaction.response.edit_message(embed=em,view=paginator(self.bot,sdf))
class DropdownView(disnake.ui.View):
def __init__(self,bot:commands.Bot):
super().__init__()
self.add_item(Dropdown(bot))
class Dropdown2(disnake.ui.Select):
def __init__(self,bot : commands.Bot,lip : list):
self.bot = bot
options = []
for co in lip:
options.append(disnake.SelectOption(label=co))
super().__init__(placeholder='Choose the command', min_values=1, max_values=1, options=options)
No hardcode 😡
disnake
.
why you pass bot in the Dropdown
Guys any comamnd idea for me?
property client```
The client that is handling this interaction.
Note that [`AutoShardedClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient "discord.AutoShardedClient"), [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot"), and [`AutoShardedBot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.AutoShardedBot "discord.ext.commands.AutoShardedBot") are all subclasses of client.
ye ik
What bookmark?
Bookmark is on web browsers and books
@obtuse obsidian, please enable your DMs to receive the bookmark.
nice
Whats this?
Like i react 📌 to message it dm me?
make it accept replied, id or link of the message
how to send a modal?
!d discord.InteractionResponse.send_modal
await send_modal(modal, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a modal.
thx
And do i need confirm and cancel for bookmark?
with that too or by running the command
.bm hi
Your input was invalid: You must either provide a valid message to bookmark, or reply to one.
The lookup strategy for a message is as follows (in order):
- Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')
- Lookup by message ID (the message must be in the context channel)
- Lookup by message URL
Usage:```
.bookmark [target_message] [title=Bookmark]
whqt
.unbm
Oh cool
I'll make
it can also work with message ids
😳
take a snowflake arg
and th link of the message too
Reply thing is fine at start
it's easy though 😔 cant think of a hard command
i like how discord handles the snowflakes
And should i use raw reaction add or reaction add?
you can get User.created_at just by using the ID
how to respond to a modal interaction
!d discord.ui.Modal.on_submit
await on_submit(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Called when the modal is submitted.
weirdos
thx
async def callback(self, inter: discord.ModalInteraction):
Like i have comamnd called >pin and i have varible message in it and the message varible is seprate for every guild or global?
for the current channel it iz
I had a stroke reading that
Means the message varible is different for every channel?
varible
var good
let
there can be only one message with a ID
no
2 messages cannot have same ID
unique ids for every message that is
but they are binded with channels as per the API
ye every msg has its unq id
Bro i asking like i use >cm comand at same time will the variable different for every user?
i thought u saying only a single msg has a id
anyways
;-; ofcourse whatever they will provide
is there anyway to respond to a textinput in a modal
YOU DONT EVEN NEED A VARIABLE WYDYM
Oop caps
oh ic thx
u mean in the modal
!d discord.ui.Modal.values gives you all the inputs... , and am 20% sure this will not show the docs
No documentation found for the requested symbol.
yeah it does i printed the interaction.data and saw
async def callback(self, inter: discord.ModalInteraction):
for key, value in inter.text_values.items():
pass
u do like this
interaction.data best
there's no MOdalInteraction in dpy
its implemented by disnake
in disnake it is
oh
sad for discord.py
imagine not using self.values
its a modal
idk
f
how much commands per page?
paginator
suggest pls
6 at max
5 with inline False
hayyyy
5 is odd number
ye
so ew
6 is fine 3 both side
yes 3 both
💀
i dont have so many commands 💀
add aliases
ping, pong, latency, heartbeat_latency, roundtrip
💀 lol
just realised idh ping command
use words normal ppl understand
i have description tho
just make the bot answer in "my connection good" & "my connection bad"
yep
id say anyt above 50 is bad bcuz i get 18ms average 💀
but thats jst me, 50 aint bad still
i get an average of 50-70ms
cuz free host
which host
!!!
railway.app, it has buildstructure like heroku/nix/docker and you'll need a github repo
sarth can u pls teach me how do i host
How to get message to which we reply?
i have the azure credits which i got from github students on my acc, but i dont feel like using azure
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
Ok
on railway?
How to get GitHub student?
Ye I'm using those too but the pain of working with azure is not worth it honestly
It makes you want to die
i'd use digitalocean if i had a cc
Hetzner's CPX11 (Ashburn) has gotten me single digit pings at lowest with an average at 14-20ms
So basically I was getting the full server list through client.guilds and then passed client.guilds.name etc etc..
I also wanted thumbnail to be the server icon so i passed in client.guilds.icon.url and it surely returns the server icon as an thumbnail
But
For the servers which doesnt have a icon it just show the error NoneType object has no attribute url
How should I resolve it ??
client.guilds.name
thats not how python works my sir
you would have to do a list comprehension
!list-comp
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 statement:
>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]
For more info, see this pythonforbeginners.com post.
It worked for me tho....
;-;
alright, test it again and please lemme know if that works
anyways, you can have a check ```py
icon_url = Guild.icon.url if Guild.icon else None
Um yes.. it works and shows guild name guild ID guild owner guild owner ID thumbnail as the icon of the server
But
Only for the server which doesn't have an icon it shows the NoneType error
How to resolve that ??
Ooh ohk
There isn't any other ways right ??
Coz in js it would automatically return None for that icon
json doesnt use Asset objects
it provides the link, or none directly
Guild.icon in discord.py gives you a discord.Asset object or None
!d discord.Asset
class discord.Asset```
Represents a CDN asset on Discord.
str(x) Returns the URL of the CDN asset.
len(x) Returns the length of the CDN asset’s URL.
x == y Checks if the asset is equal to another asset.
x != y Checks if the asset is not equal to another asset.
hash(x) Returns the hash of the asset.
How to get id of bot's message?
Means the message that bot is going to send
why do you have self outside a class?
message = await send(...
message.id ```
pH k
How to fix this
@bot.command()
async def bm(ctx):
conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
embed = discord.Embed(title="bookmark", description="react to 📌 to get message to dm",color=discord.Color.green())
message = await ctx.send(embed=embed)
await message.add_reaction('📌')
id = message.id
reply is not defined, it's pretty self explanatory
?
have u copied this command from somewhere?
I just copied from a other command in my bot
I found my mistake
I forgot to define message reference
how to make so a button can only be pressed if you have a certain role?
so u forgot to copy the whole thing
yes
nvm fixed
@bot.command()
async def bm(ctx):
reply = ctx.message.reference
conten = (reply.cached_message or await ctx.fetch_message(reply.message_id)).content
embed = discord.Embed(title="bookmark", description="react to 📌 to get message to dm",color=discord.Color.green())
message = await ctx.send(embed=embed)
await message.add_reaction('📌')
id = message.id
@bot.event
async def on_raw_reaction_add(payload):
channel = await bot.fetch_channel(payload.channel_id)
message = payload.message_id
user = await bot.fetch_user(payload.user_id)
emoji = payload.emoji
if message == id and emoji == '📌':
await channel.send(conten)
Guys why this is not sending message
oh lol. I said that as a joke. i didn't excepted someone named nae-nae
can i make that a bot can use slash commands? (for disboard)
no
error what is
and that's a really bad way of making a bm command
How can I get the message content for a message I reply to?
for example if I do !msgcontent on this reply it would get the content of that message
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
Do you have an example?
@bot.command()
async def bm(ctx):
reply = ctx.message.reference
content = (reply.cached_message or await ctx.channel.fetch_message(reply.message_id)).content
!d discord.RawReactionActionEvent.emoji
The custom or unicode emoji being used.
so the content var here is the message content
of the message that was replied to if there was one
This returns a PartialEmoji object
So you're comparing a string with a class instance
If there wasn't a reply what would happen
it would raise an attribute error
if not ctx.message.reference:
logging.info("no replies for the message")
do uwu stuff here
uwu stuff 💀
me
Can't you just do if not reply:?
what
if you have issues then just look for the docs yourself
reply = ctx.message.reference
if not reply:
# do something
Would that be correct or not, Is what I meant mb
no
I mean
it wont raise any attribute error, I'm going out of my mind
yes it's right
I see
^
Wahts good way then
what if there was no message replied to, it will raise an error
But why it not working yet
it's ctx.channel.fetch_message
oh wait nvm
what's the error
Yo, I just bought a Discord bot course on Udemy, I've downloading the libraries and stuff she's explained but I'm getting the error ModuleNotFoundError: No module named 'discord' When Running my bot
Code:
import discord
client = discord.Client()
client.run("token")
pip install discord.py
Thanks
maybe py -m pip install discord.py
Alright
It downloaded something, Same error code No moudule named discord
I am getting a error message "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases."
For how much?
20$
hi ares long time no see
good morning ashley
how much coffee do you think you can get with 20 bucks
We have pounds here 😔 , that's almost 17 pounds.
can buy 11 coffees 😔
30 here
coffe
Hi zeffo
same here didn't see any of you in a while
Bri'ish

smh
I'm moving to wherever, that rubble shit is cheap
Hello there, it's been More than one day but my Bot global slash commands are not updated in other servers.
It's in 1000+ servers. So it is not possible for every servers to re invite the bot agin
no option
Servers problem imo, if they need slash commands then they should reinvite the bot
tbh, at first i had warning messages about switching to slash then gradually i removed all prefix ones and fully switched
So can we send mass messages in all the servers? Is it not against discord tos?
He means like warning embed field when using command
Okay Yeah that works!
yeah
mass messages damn
shouldn't discord automatically grant the application.commands scope to verified bots
You specify it when generating invite link or configuring bot invite button
i think it might be the case, ik i also asked about this in discord dev server
no like, for the servers your bot is already in
Someone told me that slash commands will become global after one hour
only if you have the application commands permission too
Granted scopes cannot be changed by something automatically afaik
and it normally doesn't take an hr now :walk:
:walk:
:walk:
don't blame me, my nitro expired but discord still shows custom emojis on my suggestions
So only option is to reinvite the Bot in every server smh
it's like a scope migration
I haven't ever heard about it
All bots added to the server before March have the commands scope
So basically all bots that didn't have the scope before it was invented got it automatically from what I understand
Do you have MM/DD/YYYY date format or smth
imagine using mods
for some reason 🗿 discord moment, i am a normal person using DDMMYYYY but on discord it's formatted the american way
Weird
oh, the lang is set on english, US, that's probably the case
i sent almost 5 months ago an email to discord support about moving a verified app to a team then they did answer few days ago, it was just clyde and they auto closed the ticked without even helping me whatsoever lmao
discord moment
how do i make my bot reply to any dm with a given prompt from config? And i also need it to be toggable
I am out me not able to understand how to make
pog
do anyone know how much time I should wait to be unbanned from discord.py requests?
Why was you banned?
idkk sooo my movie's gonna start anyways
What movie
I updated the code alot of times I guess
Ig not good reason
thor love and thunder?
so
dynamic, you can see the time in the error
let me see
Is it rate limit error?
cant find or doesnt say
yes, temporary banned
send the complete traceback
Are you using repl.it 
Hey @summer flume!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
yes
Solution 1: type “kill 1” in the terminal, solution 2: don’t use repl.it (free package anyway)
ok I will try
it works, thanks
Np
Solution 2 is better
True
mes = message.content
if mes.startswith("-google"):
searchContent = ""
text = str(message.content).split(' ')
for i in range(2, len(text)):
searchContent = searchContent + text[i]
for j in search(searchContent, tld="co.in", num=1, stop=1, pause=2):
await message.channel.send(j)
Typeerror: coroutine object is not iterable.
in the second for loop
Full trace back
wwhat
!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.
oh
i fixed it but it gave another error
search() got an unexpected arguement 'tld'
Full traceback and code
I’m not Houdini, work with me here
search doesn't take a tld argument
The only time someone’s about me section is true
Hi all, I was wondering if anyone can help advise.
I am trying to build an embedded multi reaction role post similar to what I currently have through MEE6, but I am not sure what else I need to think about in order to get it to work.
I am not looking for anyone to rewrite my code to a working state, but I would love some guidance in to what I should look into next in order to get it working (and post the message to a specific channel) the code itself is; https://paste.pythondiscord.com/bowawepofe
The Bot does come online after implementing this code, so I can only assume I am missing bits to get it to post this and allow itself to add 1 reaction to the post so users have an emoji to go off, and then I can shut off the MEE6 stuff eventually.
Cheers.
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
!d discord.on_raw_reaction_add
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Read these
So I guess I will need to create 2 more bot events and some how point these to my current code cheers.
Once a message is sent with reactions you simply need to store the message id in a variable and run a few checks in a on_raw_reaction_add event
Much appreciated, I'll first figure out how to get the embed actually posted (and it stays permanently) then figure the on_raw_reaction_add event part with a variable pointing to the correct message id, thank you. 🙂 💪🏻
Sending it once will keep it permanently unless deleted
How can I make it so my bot sends a Embed with a button below to select channels? And then save that channel selected? Nextcord
Use discord.py 2.0
Otherwise https://github.com/nextcord/nextcord/blob/master/examples/views/dropdown.py (for stinky nextcord)
A Python wrapper for the Discord API forked from discord.py - nextcord/dropdown.py at master · nextcord/nextcord
and how can i make it so it shows all channels to select? And then save the selected one?
!d discord.Guild.channels
property channels```
A list of channels that belongs to this guild.
property text_channels```
A list of text channels that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
For only text channels
This one also returns voice channels and catagories
my_mod_role = interaction.guild.get_role(995338615058079794)
overwrites = {
interaction.guild.default_role: nextcord.PermissionOverwrite(read_messages=False),
interaction.user: nextcord.PermissionOverwrite(read_messages=True),
my_mod_role: nextcord.PermissionOverwrite(read_messages=True)
}
channel = await interaction.guild.create_text_channel(f"{interaction.user.name}{interaction.user.discriminator} ticket", overwrites=overwrites)
tickembed = nextcord.Embed(description=f"**Created Ticket:** {channel.mention}", color=nextcord.Color.blurple())
await interaction.response.send_message(embed = tickembed, ephemeral=True)
supportEmbed = nextcord.Embed(title = "Support Ticket!", description="**TEST**", color=nextcord.Color.blurple())
await channel.send(f"{interaction.user.mention}", embed = supportEmbed, view=view)```
How can I get the interaction.User from here which is within a select dropdown class and then use it in the code below. I dont know how to do this because they are in different classes. If i add in the interaction.User in the code below it reads of the person who clicked it in my case it will be staff but I want this ticket to be locked for the person who clicked the dropdown from above.
```@nextcord.ui.button(label=":lock:", style=nextcord.ButtonStyle.primary)
async def lock(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
my_mod_role = interaction.guild.get_role(995338615058079794)
embed = nextcord.Embed(description="**:lock: Locked the ticket**", color=nextcord.Color.blurple())
await interaction.response.send_message(embed=embed)
overwrites = {
<interaction.user>: nextcord.PermissionOverwrite(read_messages=True, send_messages=False),
my_mod_role: nextcord.PermissionOverwrite(read_messages=True, send_messages=True)
}
await interaction.channel.edit(overwrites=overwrites)```
Don’t use nextcord is the best option
dont answer if you dont know
if you are wanting to get the author of an interaction: interaction.user
It isn’t very clear what you are trying to do
basically i want a button that when you press it refrains the user who made the ticket from talking but can only see the chat
aa nvm idk how to explain
Make a button that changes the authors channel permissions to be read only
optimally you'll need the view in your ticket to have related information like the user stored in a database
for a non-persistent view the easy way would be to add a user_id parameter to your view's init which your lock button can reference

What is the point of all this discordpy forks 😭😭😭
to do something better/different than danny?
And what do they do different
not give up in the middle of the day and keep developing good shit 
afaik most of the forks spawned because danny discontinued dpy 2.0
but then he came back after seeing none of us were able to decide on one fork
waiting in the shadows to keep the economy going 
democracy heh
What a lad
slash/application commands primarily right now
hello
men
async def Geschlecht2(ctx):
channel = bot.get_channel(985970666643816498)
message = await channel.send('Was ist dein Geschlecht?(Weiblich)[Reagiere auf die nachricht]')
await message.add_reaction('♀️')
role = ctx.guild.get_role(992450008051875930)
await ctx.author.add_roles(role)
@bot.event
async def on_raw_reaction_add(reaction, user):
Channel = bot.get_channel(985970666643816498)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "♀️":
Role = discord.utils.get(user.server.roles, name="Weiblich")
await user.add_roles(Role)
hi guys i have a problem, it only works for the first reaction how can i fix that?
Doesn’t dpy 2.0 have them rn anyway
I never said it didn't
Fair
Reaction intents need to be enabled
how can i do that?
!d discord.Intents.reactions
Whether guild and direct message reaction related events are enabled.
This is a shortcut to set or get both guild_reactions and dm_reactions.
This corresponds to the following events...
how would it look alike in my code?
intents.reactions = True
client = commands.Bot(command_prefix=',', intents=intents)```
I’m on mobile sorry it took a while 😭
what I for my part wonder the most is why people actively dicourage the use of a discord.py fork, like why? a monopoly is almost always bad
why would u say sorry? u are still helpful thank you :)
The forks make it harder for devs to communicate as there are so many different ones, anyway at least it’s not discord.js
you could make the same argument then for react, vue, next, and so one
just use hikari
to have your lock button know what user it should update the permissions for, you can add a user_id parameter to your view: ```py
class TicketControls(discord.ui.View):
def init(self, user_id: int):
super().init(timeout=None)
self.user_id = user_id
# lock button can update the channel permissions as follows:
# overwrites = {discord.Object(self.user_id): discord.PermissionOverwrite(...),
# ...}``` but also if you want the view to keep working across restarts you'll need to store both the message and user id in your database, that way you can re-create the views whenever your bot first starts: ```py
during setup_hook() or somewhere similar, add the persistent views
async for message_id, user_id in database.query('SELECT message_id, user_id FROM ticket'):
view = TicketControls(user_id)
bot.add_view(view, message_id=message_id)``` if the persistency stuff is new to you, see the add_view() documentation: https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.add_view
and an example on persistent views: https://github.com/Rapptz/discord.py/blob/master/examples/views/persistent.py
alot of people have, you're living under a rock or something
jk, it's lesser known, but that doesn't mean any less
Looks pretty solid, it’s a nice competitor
yah, and it's made so that you can choose between different command handlers or make your own easily
It looks more complicated though
discord.py is made to be friendly to users new to the library
so comparing those 2, hikari is/feels "more complicated"
once you get used to it, you get used to it
You can say that about literally anything though
ofc u can
I want my bot to find a channel named fivem-servers and then send a message in there if it was found but it didnt send a message into the channel and there was no error
channel.send
Ctx is a context object
Ctx.send just sends to the channel where the command was ran
But it also didnt do that
async def Geschlecht2(ctx):
channel = bot.get_channel(988526792602177636)
message = await channel.send('Was ist dein Geschlecht?(Weiblich)[Reagiere auf die nachricht]')
await message.add_reaction('♀️')
role = ctx.guild.get_role(992450008051875930)
await ctx.author.add_roles(role)
@bot.event
async def on_reaction_add(reaction, user):
Channel = bot.get_channel(988526792602177636)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "♀️":
Role = nextcord.utils.get(user.guild.roles, name="Weiblich")
await user.add_roles(Role)
@bot.command()
async def Geschlecht3(ctx):
channel = bot.get_channel(988526792602177636)
message = await channel.send('Was ist dein Geschlecht?(Divers)[Reagiere auf die nachricht]')
await message.add_reaction('🌈')
role = ctx.guild.get_role(992450074665811968)
await ctx.author.add_roles(role)
@bot.event
async def on_reaction_add(reaction, user):
Channel = bot.get_channel(988526792602177636)
if reaction.message.channel.id != Channel.id:
return
if reaction.emoji == "🌈":
Role = nextcord.utils.get(user.guild.roles, name="Divers")
await user.add_roles(Role)``` hi guys i have something really really weird, idk why but only geschlecht3 is working and geschlecht2 isnt. idk why, i double checked everything but it still wont work do u guys have an idea?
Is it registering the command?
yes
Try using the example i posted instead of your code
Also make sure it’s actually getting a channel
the @bot.event decorator only allows one handler to be assigned to each event, but you're trying to assign two at once
not sure if you intend for the reactions to only work for a certain period of time, but if so then a better method would be bot.wait_for(event)
^ an example of wait_for
what, i want that it will work always, btw thanks
oh so persistent reaction roles
uh, yeah btw i didnt use it cuz it was kinda complicated im sry
forgot you were the same one that asked about it lol
lol
yes
you could hardcode the message id into your reaction roles and use a single listener for it, rather than having commands to send new messages to react to
Seen as you'll just get blasted for using any other library than their preference, I'll dm you the nextcord server invite
dynamically created messages would otherwise require a database to store those messages in
thank you :)
uh, okay i never used listen but ill try.
example of hardcoding the message: py @bot.listen('on_raw_reaction_add') async def my_reaction_roles(payload): if payload.message_id != 995689664864342046: return elif payload.emoji == '🌈': await payload.member.add_roles(...)
also on_raw_reaction_add / on_raw_reaction_remove will always work after your bot restarts since they dont rely on message cache, but its a bit more inconvenient to work with
Hello, i have this error with my code, but i don't know how to resolve it because the indentation is good ```python
import discord
from discord.ext import commands
import aiosqlite
import datetime
import asyncio
class Warn(commands.Cog):
def init(self, bot):
self.bot = bot
bot.db = await aiosqlite.connect("warnData.db")
await asyncio.sleep(3)
async with bot.db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS warn(user INTEGER, guild INTEGER, reason TEXT, time INTEGER)")
await bot.db.commit()
async def addwarn(self, ctx, reason, user):
async with self.bot.db.cursor() as cursor:
await cursor.execute("INSERT INTO warnDATA (user, guild, reason, time) VALUES (?, ?, ?, ?)'",(user.id, ctx.guild.id, reason, int(datetime.datetime.now().timestamp())))
await self.bot.db.commit()
def setup(bot):
bot.add_cog(Warn(bot))
okay
thanks
Await is outside an async function
you can't await inside a normal function
i might need to learn python again
how i am suppose to do so ?
startup functions 🚀
Not even a transparent background smh
lmao
async def initialize(self):
await self.bot.wait_until_ready()
await self.bot.db.execute()
``` something like that would be good ?
which allows me to use nitro emojis without nitro
don't connect to the db in the __init__ method. Preferably you connect to the db just before the bot starts and then you make the connection a bot variables, or else you can make an async function then call it in the __init__ using asyncio.run
Delete rn
oh
ok
discord doesn't take action just for using it
you want to define self.bot.db inside that func, since you can't get an async in the def init
smash
I’ve had my fair share of bans
you must be doing something sus then, discord doesn't ban just for using bd
ok i do that thanks
so you admit to repeated violation of the discord TOS 
I mean it wasn’t my account getting banned 👀
!d discord.ButtonStyle.url
@bot.event
async def on_raw_reaction_add(payload):
if payload.user_id != bot.user.id and payload.emoji == "🗑️":
delet_this = await bot.fetch_message(payload.message_id)
await delet_this.delete()
I uh. I don't understand why it's not going through the if.
ya
help
dont use the decorator
how do i add it to my class
just do view.add_item(Button(style=discord.ButtonStyle.url, url='...')
ok ty
if you are subclassing discord.ui.View replace view with self
I did enable them but it still doesnt work
@bot.command()
async def flip(ctx):
results = ['Tails','Head']
rr = random.choice(rr)
await ctx.channel.send("Flipping a coin 🪙", delete_after=0.9)
async with ctx.typing():
time.sleep(0.8)
await ctx.send(f"You got {rr}!")
async with ctx.typing():
TabError: inconsistent use of spaces or tabs
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
also, use asyncio.sleep instead of time.sleep
is it in seconds
i believe so
i did the exact same thing in other command and it worked
same intents
that second gap looks larger to me 🤷♂️
the thing is u used 4 spaces to indent the block of code above async with ... then u use 3 spaces to indent the async with, so add a space before it and you should be fine and try to keep it consistent
still doesn't work even after i made it equal
okay
it worked
slash commands....do dpy got it or any othr module to be imported?
yes dpy does have, for more info check this message out
#discord-bots message
hello. the bot that i'm developing (with discord.py) has a database. Regarding consistency checks (after restart) with e.g. guilds that the bot is no longer connected to or deleted channels whose ids where stored in db, what's the best event handler to use so I can take the data received from Discord and then do all necessary operations? I was considering to use on_ready event, since it's called after receive all information from discord, but this consistency check needs to be before the bot execute some commands that it might receive. ```python
a silly example:
async def on_ready(self):
await db.consistency_check(self.guilds)
or should I disabled all commands and after this enable?
you shouldn't use on_ready for such things, use setup_hook its made for that
but after setup_hook is called, the bot already has all information about the guilds that it is connected to?
this is a reply
im pretty sure it does, lemme check
this is a send
k nvm it doesn't
ohh
oh ok
you can use on_connect
im dumb, thanks
oh right. but how do I make sure that no command is executed before those check operations?
just set each command as disabled?
commands shouldn't execute before that
ahhh ok. thanks
hello 👋
How can we help you
That didnt help bruh
which event
ah do you have a process_commands
what is that
it processes commands
How do i use it
it got trigger
@lilac mica please repost without slurs
What slur
bad words
a lot of the words in your "bad" list
It's for my moderation features
I know, replace them with different dummy words before posting on this server
Oh
something like "fuck" is fine though
I wanna fuck
any more questions, DM @novel apex
Damn.
It's not a slur it's just an olld idiom
meaning "something important that was not disclosed"
I kinda agree with lemon
you yourself are writing code that puts it in a "bad" list though so remove it and other similar slurs before posting next time.
I think that "something" That wasnt disclosed is potentially a badword, I think that's why the op is deleting that message.
u will be banned
I see
dont
you should move on, the things you had in that message was offensive, if you believe it or not
great
bro
I don't think it was
let me show u something
what was the message
What message
Imagine swearing 🤬
mods do swear
move on!!
Should i install pycharm ide or visual studio for writing my code ?
To where
Neovim

