#discord-bots
1 messages ยท Page 798 of 1
hmm
Which is faster (O(1)) and also much simpler
!d disnake.Guild.get_role || for reference
get_role(role_id, /)```
Returns a role with the given ID.
I need to learn to use the !d haha
same lmao
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
pseudocode is confusing to me
get_role(role_id, /)```
Returns a role with the given ID.
hehe
neat
it supports 41 packages/docs, nice
i was making a nuke channel command and i was just doing it incorrectly, i figured it out but what does the error its self mean? ive never seen it before
it should be the least confusing thing in the whole of coding
the point of pseudocode is you just do random shit to convey your point
Im not sure myself but if i could make an educated guess id say that a channel doesnt accept information in a json format???
If i were to guess maybe you're trying to store an object as a json?
pseudocode just explains what you're doing
json can only store primitive types unless you're employing pickling but I won't go into that
the thing is its hard to remember it
for me everuththing is hard to remember
bruh
that sounds plausible
hello guys, anybody knows whats the hours / days ? {'s': 1,'m':60}
shouldn't be, its a simple error
bot.guilds returns a list
u need a guild object to get the role
bot.guilds returns a list of ALL the guilds your bot is in,
message.guild will return the guild in which the message was sent
ah
also while defining role2 you uesd dguild, I'm assuming that's a typo
yeah fixed that
add_roles also really wrong
why you gotta look at old youtube videos
just supply it a list of roles or just 1 role
i already gave list i think
Hey guys if i post anything on my fb page can my discord bot give the link to that post in discord? Is it possible?
well
[role, role2]
you don't need the member's id as an argument
add_roles only takes one positional argument
message.author.add_roles(role)```
message.author.add_roles(random.choice([role1, role2]))

i hab a doubt
ask
no friggin way it worked โ ๏ธ
is there a event where we can find when a user starts
what's surprising about it
an activity
!d discord.on_member_update
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change:
โข nickname
โข roles
โข pending...
hmmm
idk i spent so long
wait that might not be it
oki
!d disnake.on_presence_update
disnake.on_presence_update(before, after)```
Called when a [`Member`](https://docs.disnake.dev/en/latest/api.html#disnake.Member "disnake.Member") updates their presence.
This is called when one or more of the following things change:
โข status
โข activity
This requires [`Intents.presences`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.presences "disnake.Intents.presences") and [`Intents.members`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.members "disnake.Intents.members") to be enabled...
im sorry for being annoying
TYSMM
this
its just that i've seen some videos and didn't really get around it
started learning how to make bot last night
no don't worry, you're just asking
!resources I recommend this btw
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
is it only possble through disnake
no
no
same thing on discord.py
!d discord.on_presence_update
discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their presence.
This is called when one or more of the following things change:
โข status
โข activity
This requires [`Intents.presences`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.presences "discord.Intents.presences") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled...
i shud probably use discord's docs lol
random.choice(guild.roles) will return a random role from a guild
yeah i worked my way through it
That's awesome!
now im trying to find a way to make sure that this command can't be used a second time
once the user has one of the roles from the list
or since it's a list of roles, you could go through each role in the list then check if that role is in the roles of the author, and if so don't use the command so
for role in list_of_roles:
if role in message.author.roles:
# code goes here to prevent the command from launching
that's not so necessary when you have two roles in the list, but when adding more, it's practical
if any(role in message.author.roles for role in role_list):

Or use the commands.has_any_role
that I what I was gonna ask but i guess it's pre answered
roles1 = set(list_of_roles)
roles2 = set(message.author.roles)
if roles2.intersection(roles1):
return
You can use sets here cause you know that the roles won't appear twice
And this would also be O(n) where N is the lowest set's element amount
oh they only have two roles
I get this traceback when I run channel.purge:
if l is None or l > 100:
TypeError: '>' not supported between instances of 'str' and 'int'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):```
code:
@commands.command()
@commands.has_role("System Admin")
async def clearall(self,ctx):
await self.bot.get_channel(938455981145329706).purge(limit="99")
Your passing a str to limit, you want to get rid of the double quotes
How do I crash my bot's discord?
?
like to stop my bot proccess
await bot.close()
thanks
!d discord.ext.commands.Bot.close
await close()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Closes the connection to Discord.
how should i do this
this presence update thingy aint workin for me
return
well ask
async def on_presence_update(member,before,after):
channelA = await bot.get_channel(938849319782588486)
print(before)
await asyncio.sleep(5)
print(after)```
never said member as argument
!d discord.on_presence_update
discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their presence.
This is called when one or more of the following things change:
โข status
โข activity
This requires [`Intents.presences`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.presences "discord.Intents.presences") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled...
not a problem
no
is there an error?
no error
This requires Intents.presences and Intents.members to be enabled...
This true?
everywhere?
just do intents = discord.Intents.all()
okk
and you did it in the dev portal
I don't see a reason for it to not work
hmm
I have having some trouble with tasks loop
@tasks.loop(seconds=3)
async def counting():
num = 0
print(num)
num+=1```
This should be looping every 3 seconds and printing the number
but its not doing anything
you started it?
yeah
where
counting.start()
can someone help me with d-components rq?
im bad at it ;-;
hm
3rd party library ๐
Just use discord.py master or some fork
Forgot to start the task
you are flaming me for what?
works now thank you
i asked a question so people will help me and not blame me
by the way your answer wasnt helpful
๐ฅฐ
how am I blaming or flaming you?
np
Hi there, sorry for intruding.
I was trying to add a functionality of my discord bot that is formatting messages into some colour.
Like this
[35mText
``` So I need to make up a mark-up syntax of some sort. (The above is with help of ANSI colour codes).
great
I'm not here to help someone specifically either, I just said what any general person here would.
hm
could you please check the channel pins, it has a good note about how to do it
The first one, by Krypton
Running
@tasks.loop(seconds=3)
async def counting():
num = 0
print(num)
num+=1
me = client.fetch_user(321675286108307456)
await me.send(f"{num}")```
is giving me an error
TypeError: can't send non-None value to a just-started coroutine
fetch_ methods need to be awaited
fuck
use get_
works now
If you don't have member cache, fetch once and store it to use again later
bro meh
use bot.get_user(id) or await bot.fetch_user(id) so if the user is not in the cache, you fetch it
on_presence_update aint working
if you fetch every 3 seconds you'll get ratelimited
Did you enable the intent?
i did
Its just a dummy code
all the ones
i am not running the loop every 3 seconds
anyone?
sry i never used d buttons in my life
i did
That'll only take long if you're doing other stuff first or have bad latency
it's maybe because of your internet connection depending on the time the bot takes to make the request to the discord Api and it edits the message
cant be i have another view and it works fine on that
Did you try adding a print() statement on first line to see if it even gets fired at all?
im just sending a response before that
yes
could your show more code for reference, atleast the function it is inside
i did ;-;
And presence intents
i need you guys help, my bot is growing very fast and will soon reach 100 servers, i currently host it on repl.it but I assume it will not perform well, is heroku better?
No
bruh
should i get a raspberry pi running?
why advert
yes
heroku's better and still not even close to enough
i am not advertising
im sry my braincells couldnt see the other words
Virtual Private Server
i dont wanna let my pc run 24/7
It's basically a pc in the cloud to put it very simply
ah
You don't need any device running to use a vps
great
But it does cost a few bucks per month
i see
dw i fixed it
Thanks, But my question was regarding designing an interface around this.
suppose someone commands my bot
format fore_red(back_gray(Sample Text))
Then how I can parse this.
But with a $3/month vps you can get pretty far in this beginning stage
dutchy it aint showing error thho
my bot has grown to 70 servers in 3 days exisiting
quite a success
Is that your command syntax?
no
thanks @slate swan
You could try GalaxyGate. Cheapest is $3/month which is enough for now and you can easily upgrade at any time
congrats on 70 m8
I'm not sure why. Can you try showing more of the file?
thanks!
I don't know actually what would be a good syntax that is both user-friendly and easy to parse.
thanks u too! :)
exactly
LMAO
bright mode
the fuck is this?
This what though?
how mobile status?
the normal API doesn't let you do this
Mobile status is a discord issue which officially isn't allowed but they're too lazy to fix
oof
Don't know if it violates TOS or not, it shouldn't since it's more of less just a visual thing
can i send the whole file
normal API
You telling me theres is an abnormal API?
Sure
dms?
Remove token tho
oki

๐ค Nah just what you're supposed to use
if they send the token by mistake, you gonna nuke the bot or smth? 
Duh, gonna make it send teletubby nudes everywhere
damn
hot
I remember lucas showing his token and not resetting it in a video, someone used it :lolol:
lucas ahh
that dood
cool tutorial
no hate pls
lmao, respects to the person who copied it
lmao
is there a way to know the status of someone? like to give a role if someone has the url of the server
should I incorporate in my bot?
!d discord.Member.status
property status: discord.enums.Status```
The memberโs overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
might be cool
lmao
The video was for hikari and one.of the helpers did it lmao
like the a, idk if u know what i'm saying
no comments
huhhh oh yeah
The name of the activity.
that should work if someone has the url?
hello guys, whats the problem?
@client.command(aliases=["Report"])
async def report(ctx,member:discord.Member,*,report=None):
report_channel = discord.utils.get(ctx.guild.channels, name = "reports")
if member is None:
return await ctx.send("Please include a user you want to report.")
if report is None:
return await ctx.send("Please include information about the report")
else:
embed=discord.Embed(title="Report", description=f"{ctx.author.mention} has reported {member}",color=0x34568B)
embed.set_thumbnail(url="")
embed.add_field(name="More Info:",value=f"{report}")
embed.set_footer(icon_url=ctx.author.avatar_url, text=f"React with the โ
if the situation has been dealt with.")
report_message= await report_channel.send(embed=embed)
await report_message.add_reacion('โ
')
await ctx.send(f"{ctx.author.mention} Your report has been sent to the staff team!")
try:
def check(reaction,user):
return user==ctx.author and str(reaction.emoji) in ["โ
"]
reaction, user=await client.wait_for("Reaction_add", timeout=604800,check=check)
if str(reaction.emoji) == "โ
":
await ctx.author.send("Your report has been looked into and dealt with. Thank you for reporting!")
except Exception as e:
print(e)
Error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
Wrong ping sorry, also you should use the api for your bot
BUt without using requests
It gives the activity they have in a string form, for example if I have "python is cool" , I get that string
ohh, okayy
You can use in to check if your string is inside that string
thank u :D
lmaooooo
hm anybody?
last.time I check your dark light project it was using requests.lol
yeahh, idk why aiohttp keeps terminating my bot
report_channel is None
How do you use it?
what?
as they've mentioned in their examples
report_channel returns None as it fails to grab the TextChannel object
usually it's better just to pass the channel id if it's just for one guild
ok i try it
async with aiohttp.ClientSession() as session:
res= await session.get("url")
``` something like this?
umm no, as far as I remember, it had two asyncs
get can work both ways
very helpful, thanks
well, that just depends how you use it
@maiden fable btw, command ideaaaa
for me I use this method and it works perfectly
hmm, I see
uhmm, I see I see, I'll try doing that rn
Mm sure, lmk if you get an issue
if not 1?
lmk?
Let me know
okii
???
lol
where or what
I don't understand the idea tbh
Discord tinder
Should i still use on_ready() or on_message?
so anybody know whats the problem with this code?
is there a way to check when someone updates this? (the a)
on_member_update probably
report_channel is None as they said
Oh hmm
yeaaa, thank you soooo much
also so, how do I get the status code?
otherwise my bot will just die out without any response ;-;
Response.status_code iirc
.status
doesnt work
aiohttp uses .status
oh yeah, thankss
I always confuse between them ๐ฉ
.status
Oh someone already answered
if I put this line:
@commands.has_any_role('BotMaster', 'Moderator')
in front of the class/cog declaration, only members with the roles BotMaster and Moderator will be able to use the commands in the cog, right? Or does it have to be in front of every command?
oh, that's why it didn't work, thanks!
ok so i make the bot create the "reports" channel but nothing sended. Code
@client.command(aliases=["Report"])
async def report(ctx,member:discord.Member,*,report=None):
guild=ctx.guild
report_channel = discord.utils.get(ctx.guild.channels, name = "reports")
if report_channel==None:
await guild.create_text_channel('reports')
else:
embed=discord.Embed(title="Report", description=f"{ctx.author.mention} has reported {member}",color=0x34568B)
embed.set_thumbnail(url="")
embed.add_field(name="More Info:",value=f"{report}")
embed.set_footer(icon_url=ctx.author.avatar_url, text=f"React with the โ
if the situation has been dealt with.")
report_message= await ctx.report_channel.send(embed=embed)
await report_message.add_reacion('โ
')
await ctx.send(f"{ctx.author.mention} Your report has been sent to the staff team!")
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
and I would like to ask how the bot could send the message there even if it was renamed? Right now, he's just doing another one.
You're doing ctx.report_channel.send
same error:discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
You're not setting the report_channel again after creating it
How can I do that?
x = await create()
Yes, but also use report_channel with the create line
can anyone see why this task isn't working? It just stopped setting the status one day and it's had lots of reloads since then but it's never come back```py
class Events(commands.Cog):
def init(self, bot):
self.bot = bot
self.statuses = []
self.status.start()
@tasks.loop(minutes = 5) # seconds = 10
async def status(self):
await self.bot.change_presence(activity = discord.Game(next(self.statuses)))
@status.before_loop
async def before_status(self):
await self.bot.wait_until_ready()
data = await self.bot.get_data(448405740797952010)
users = sum(await self.bot.comm.handler("user_count", self.bot.cluster_count))
self.statuses = cycle([f'/help | {self.bot.config.default_prefix}help', f'{self.bot.config.activity}', f'{data[13]} is the current count', f'RaidMode is {"Enabled" if data[14] is True else "Disabled"}', f'{data[15]} is the required age for new accounts when raidmode is enabled.', f'Latency: {round(self.bot.latency * 1000, 2)}ms.', f'CPU Usage: {psutil.cpu_percent(interval=None)}%', f'RAM Usage: {psutil.virtual_memory().percent}%', f'I can see {str(users)} users', f'Python Version: {platform.python_version()}', f'Discord.py Version: {discord.__version__}', 'I support slash commands', ])```
@slate swan
Remove the else line and unindent everything after it by 1
@bot.command()
async def vip(ctx):
if ctx.author.id == 626127081419571206:
a = ctx.guild.members
c = bot.get_channel(938873521952677891)
r = ctx.guild.get_role(938873620531392543)
for b in a:
if "/club" in b.activity.name:
await b.add_roles(r)
await c.send(f"Le he dado el rol vip a {b}. ")
else:
pass
else:
pass```
I'm trying to make a command to check if someone has a vanity url in status, if the user has the vanity it gives him the vip role. I get this traceback:
Ignoring exception in command vip:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 44, in vip
if "/club" in b.activity.name:
AttributeError: 'NoneType' object has no attribute 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'
if the user doesnt have any status then it isnt gonna have a name attribute
so add a conditional to check if the activity is none or not
@bot.command()
async def vip(ctx):
if ctx.author.id == 626127081419571206:
a = ctx.guild.members
c = bot.get_channel(938873521952677891)
r = ctx.guild.get_role(938873620531392543)
for b in a:
if b.activity is None:
pass
else:
if "/club" in b.activity.name:
await b.add_roles(r)
await c.send(f"Le he dado el rol vip a {b}. ")
else:
pass
else:
pass```
so like this?
tyyyyyyyy ๐ Thank you man.
use the is operator for bools
#First Way
if b.activity is None: pass
#Second Way
if not b.activity: pass

lmao
aaand I would like to ask how the bot could send the message there even if it was renamed? Right now, he's just doing another one.
okay, i'm going to try
It's better yes, but == None has the same result here
tnx!
Changing == None to is None here changes nothing
uhh, python gives a warning to use the is operator for checking Nones
ik ik
so if i rename the channel, the bot create new report channel.
Literally never had that warning 
I don't think python gives you that warning, that would be your linter
um yeah, PyLance did
It's still ideal to use is when checking None though
How can I make sure he doesn't make a new one and send it to the same channel? there are several servers with bots.
but, the thing is, it would ping the role but..it will ping the members who have that role
so, use an embed, and var.mention
grant_citizenship.mention should work
Yeah will use embed
Thanks. Let me give it a shot.
!d discord.AllowedMentions
class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)```
A class that represents what mentions are allowed in a message.
This class can be set during [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") initialisation to apply to every message sent. It can also be applied on a per message basis via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for more fine-grained control.
@slate swan sorry for ping, but there is a way to check the about me and also give the role?
About me is not accessible by the API yet
oh, F
How can the bot detect what role I have?
How do I make the bot do that I mean?
Fixed
good grief python is starting to feel like instinct rn
โ ๏ธ
Something ive found useful in my learning journey is creating things similar to each other but slightly different so i can essentially reuse code ive already written and just modify it for the new need and add in the new stuff required for that function. It helps me to understand what my previous code is actually doing without fully having to memorize how to do it every time
Relatable
When i approach something completely new i can take the parts i understand and cherry pick for things i know it will need and then just learn the new stuff in between. Learning music integration is a little daunting though
!d discord.AllowedMentions
What should i use for sending a embeded message to a channel
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if itโs within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
i need to learn to use the bot more lol, i was gonna type it out
import discord
from discord.ext import commands
class Citizenship(commands.Cog):
def __init__(self, bot):
self.bot = bot
@client.event
async def on_message(message):
guild = message.guild
if message.content == "citizenship":
#all citizenships citizenships
role1 = guild.get_role(938834958124978247)
role2 = guild.get_role(938834984515555458)
#
list_of_roles=[role1, role2]
citizenship=random.choice(list_of_roles)
#gce = grant citizenship embed
gce=discord.Embed(Title="Congratulations", description=f"You have been granted {citizenship.mention} citizenship")
if role1 in message.author.roles:
return await message.channel.send(f"Sorry you already have {role1.mention} citizenship")
elif role2 in message.author.roles:
return await message.channel.send(f"Sorry you already have {role2.mention} citizenship")
else:
await message.author.add_roles(citizenship)
await message.channel.send(embed=gce)
def setup(bot):
bot.add_cog(Citizenship(bot))
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Citizenship' raised an error: NameError: name 'client' is not defined
try changing client.event to bot.command
hmm
i dont fully get it but it seems like using bot.command is better to use than client.event because it causes issues with on_message
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Citizenship' raised an error: NameError: name 'bot' is not defined
this file is in a cog
next guess is an import error. i dont know much about cogs because that was my next step of learning
oof
you want on_message as an event, not a command
but inside a cog you use @commands.Cog.listener()
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Citizenship' raised an error: NameError: name 'bot' is not defined
and because async def on_message is inside a class you pass self as an arg
bot is not defined
replace @bot.command with @commands.Cog.listener()
because a) its in a cog, and b) on_message is an event not command
.
Thanks
How can I DM a user if I only have their ID?
Get/fetch the user
how tho
!d discord.ext.commands.Bot.fetch_user
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
thx
!d discord.DMChannel
class discord.DMChannel```
Represents a Discord direct message channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channelโs hash.
str(x) Returns a string representation of the channel
think you should be able to use this for creating a dm
who knows any command that need presence intents ๐คฆ๐พโโ๏ธ๐คฆ๐พโโ๏ธ need it really fast
Like things that use rich presence?
Is there a way to get all the badges a user has?
Like
for badge in user:
print(badge)```
a command that needs the intents?
you use <prefix>plays <game> and the bot searches everyone whose activity is that game

Wrong server
I do but it's the python server so we can't help you here
but to point you in the right direction, it's most likely a syntax error
you can get the ID of a role like so: role.id, but role has to be an instance of discord.Role object
could you explain with more detail sorry i couldn't understand
what is the command for getting owner's name?
async def role(ctx, role: discord.Role):
try:
await ctx.send(role.id)
except:
await ctx.send("Role is not found.")
@slate swan
if that's what you mean yes
thanks
Owner of the server?
yes
And to point out, .send() won't raise any error regarding role not being found, that's the RoleConverter's job
async def owner(ctx):
await ctx.send("The Owner is " + ctx.guild.owner.name)```
Can we not spoonfeed? Thanks
Thank you, much appreciated
No problem but refrain from spoonfeeding code in the future ๐
Yes this is a helping channel, not one where people can ask others to write code for them and they can copy and paste it
i found this template online, is the @tasks.loop a library or discord import?
async def changeStatus():
await client.change_presence(status=discord.Status.do_not_disturb, activity=discord.Activity(type=discord.ActivityType.playing, name=next(status)))```
i aint gonna copy
don't do that
Discord import
It's an extension, so technically part of discord.py, along with the discord.ext.commands extension
from discord.ext import tasks
Well spoonfeeding is a way of learning aswell
thank u
Not effectively
No, since they don't learn anything from copy pasting code
You can see the code and understand what it does and implement it in your own concept
Let's be honest most people aren't going to do that when they can fix their problem in 2 keystrokes and move on
And overtime that's only going to cause them more issues and they'll be back here with more questions since they copy pasted, and won't know what to do
Well that's what I did
But ofc not only. But when I got a piece of code I implemented in my own concept and try to understand it. Ofc not everyone does this.
No, which is why we should refrain from spoonfeeding code since 90% of people won't stop and thinking why or how something works if the solution is given to them in such an easy manner
ok, chef no problem
Thanks for your understanding ๐
sure
theoretically why do we have to help
cant we just spoonfeed and let them fall flat on their face
We could but then they'd be back here with more questions that could be avoided if they didn't copy paste
And then we have to deal with that
oop
send working code
๐ค Don't know how effectively it would work in practice. Either way understanding something is always better than taking what someone else said for granted
My bot has been rate-limited. What does that mean? My bot hasn't made more than 50 requests to the API, as far as I'm aware. Now when I try to run the bot again, it pops up with a "You are being rate-limited" screen. When can I run it again without the error?
Are you using replit?
your host prob got ip ratelimited
Yes.
F
Don't use it
Buy a VPS
Or use an old ass laptop
There is most likely a laptop that you might think is junk but would work fine for hosting
and where should that laptop come from
Parents or eBay
lmao
Raspberry pi is also an option
Is there a reason it is breaking now? It has worked fine for the past month.
can somone help me
What
ntg
ask?
What does that mean
nothing - ntg
Okay
the import worked but anyone know why the status part isnt working?
Make sure you actually start it
how old has ur py got 2 be 2 use discord.py intents
yea
py what?
python
dpy intents dont have any relation with your python version
how do you make it possible for several commands to be put in
one resonse commands
intents are new...?
like, send the same response with different commands?
i know how to make one of them but not multiple and have more than one work
!d discord.ext.commands.Command
class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.
These are not created manually, instead they are created via the decorator or functional interface.
If you know how to make one, just do that again a few more times, and change what each of them does
@ command decorators
def command():
do one thing
@ command decorators
def command2():
do something else
If that's what you mean
im seeing alot of:
WARNING:discord.http:http:We are being rate limited. Retrying in 11.70 seconds. Handled under the bucket "[redacted]:None:/channels/{channel_id}/messages/{message_id}"
from a long running task that updates some messages every 5 mins with a few second sleep between updates to each message, i didnt think that was too fast to hit a rate limit
Increase your time between requests, Discord isn't too clear about what exactly triggers the ratelimits
ok
how is it spaced
if i do one or two spaces it doesnt work
Learn python?
def command1():
| # stuff
|
|
|
def command2():
# stuff
oh three lines
If they're not on the same indent level, one function will be a nested function of another
ig
i made sure they are on the same level its just that I guess I wasnt putting enough lines between
The amount of lines in-between shouldn't matter
Though you should still try to stay consistent with those just for readability and organization
Then you probably did something wrong elsewhere
Can you send the code? I have a feeling you have everything currently in one file and using client.<...>
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('.info'):
await message.channel.send('info')
that was what it said
response altered though
You should use the commands extension
This is the old way of doing it and heavily outdated
Using the commands extension would solve that problem
ok
btw I was using repl.it if that makes any difference
website instead of downloading something
No it doesn't, but you should avoid using repl.it for anything other than quick and dirty testing
ok
replit is big sus
Agreed
my website is hosted on it๐ฌ
i just downloaded python win10
Glowstik's here, woah 
depending on what you coded it with, just use railway, vercel, or netlify
y e s
AWS also works, I've a Next.js app in production hosted on aws
I saw, its okay
but they're a bit more expensive
Rich people
File "c:\Users\jackr\Downloads\DUMP\REDX PUBLIC BOT\bot.py", line 51, in <module>
intents = discord.Intents.all()
AttributeError: module 'discord' has no attribute 'Intents'
PS C:\Users\jackr\Downloads\DUMP\REDX PUBLIC BOT>
But I think it's worth it since they have a bunch of other services that all integrate nicely
You're on an older d.py version most likely
can any1 how do i see
._.
nice command
๐คฆโโ๏ธ
what r u trying to do
https://github.com/Rapptz/discord.py instructions on how to update to 2.0 can be found here
do we have a disnake dev here
idk tryna decide value of x through discord ig?
and then it returns value via await
!d discord.commands.Bot.wait_for
What happened lol
No documentation found for the requested symbol.
well you using the input function to grab the data, so i suggest just adding an arg in the command itself to grab the persons "nambor"
shit
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
discord.ext
what is a good code editor
@slate swan
visual studio code (for python)
Yeah I realised
hmm
.
Nice name btw
You mean, 31 options?
Thanks
like right fkin now
well the max is 30 afaik
31 buttons?
25
what the fuck
ah
they want to create a select/dropdown with 31 options
Told you to use range?
yeah but the maximum amount of options is still 25
well you cant change the max...
Oh lol yeah
You cant
You don't
thats the neat part, ya cant
Bloody hell
any ideas on calendar picker then?
you can make two selects and like a button to filter through them
Not possible
How about a wait_for?
wait wtf are you doing
Unless you do some nasty un-user friendly stuff

aren't we like programmers
LMFAO
who make those
u
Lmaooo
just have the person enter their bday in an arg something like !setbday 12-1, it makes the code a lot simpler and more easy to use for the end user
Does dpy specify that we canโt make more than 25 options?
yo why is everyone just keep replying counter arguments to me, stop
Like in their code or is it discord?
disnake
its discord
throws an http error
lemme show it, wait
In our files?
I tried
discords api limits it to 25
Ah well
Thatโs shit
Api limit
tho in the source code, I couldn't find anything that said 25
How about two drop downs
weird af
Or something
Idk ๐คทโโ๏ธ
but it's okay 
since when was competing a thing
Discord's api would only pick up the first twenty five then?
thats what i recomended, with a button to swap between them so it doesnt look weird with two selects
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options: Must be between 1 and 25 in length.
Alrighty
they would only allow 25
Hm yeah, errors
big code is big annoying
unreadable code, much better
Frame it in your room and look at it 24/7 easy
y e s
It makes you look cool
it's like the dpy source code, nobody understands it
Y E S
dpy source code tbh its just very poorly developed tbh
Its understandable lol
Ignoring exception in command help:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 125, in help
embed = discord.Embed(title="**commands**", description="the prefix for this bot is `;`\n\n`cover` - sends a random project cover\n`discography` - sends gracie's discogrpahy\n`gif` - sends a random gif of gracie\n`img` - sends a random image of gracie\n`instagram` - sends gracie's instagram\n`intro` - sends introductory playlist\n`lyric` - sends random lyric\n`mv` - sends a random music video\n`ping` - send ping latency\n`project` - sends a random project\n`say` - sends what user says\n`startchain` - sends a lyric to start a chain\n`unreleased` - sends an unreleased song",color=0x2f3136)
AttributeError: 'Command' object has no attribute 'Embed'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'Embed'
wait that's not even it
theres a lot of old code and messy code conflicting each other
@bot.command()
async def help(ctx):
embed = discord.Embed(title="**commands**", description="the prefix for this bot is `;`\n\n`cover` - sends a random project cover\n`discography` - sends gracie's discogrpahy\n`gif` - sends a random gif of gracie\n`img` - sends a random image of gracie\n`instagram` - sends gracie's instagram\n`intro` - sends introductory playlist\n`lyric` - sends random lyric\n`mv` - sends a random music video\n`ping` - send ping latency\n`project` - sends a random project\n`say` - sends what user says\n`startchain` - sends a lyric to start a chain\n`unreleased` - sends an unreleased song",color=0x2f3136)
await ctx.send(embed=embed)
why did i get that error?
You probably have a variable named discord in your code
like this part more
You need to remove the default help command
Stop spamming
i did
We can see
iโm not
understandable but complicated to think about why you would do this
ohhh
nice
lol
i dont think having all your commands in a description is the best idea, maybe utilize tables/fields but as ash said, the issue could be that you have a variable in the same file called discord
I didn't see the error
I assumed it was an issue with the default help command
homie likes gracie
Is it possible to change Discord bot handle (the hashtag part #0001)
now I'm gonna make two dropdowns
Or discord is the name of a command* as the error said
i love gracie
i can tell
Gift your bot nitro and enjoy!
ez
Lol
client.remove_command('help')
their using bot
put this at the top of the script
i did this
client = commands.Bot(command_prefix="t!",help_command=None,intents=intents)
can you put two dropdowns to one message?
same
Ya'll look at the error or just start giving errors
neat
bro WHAT
ye
Check If discord is a command name
that code scares me ._.
Why do you have 2 bot instances
yeah it was
Also requests is blocking
i just changed it to server instead of discord
Use aiohttp
Good, did it work?
Why do you have both a client and a bot?
^^
yup
idk is it like i use only one?
y e s
commands.Bot is a subclass of discord.Client, which means it's a superset of discord.Client
Dude, you dont need 2 bot constructors
commands.Bot can do everything discord.Client can, but not vice-versa
Cool
You need to decide, depending on the complexity and use case of your bot, if you want to have commands.Bot or discord.Client
He has 2 Bot instances
is this cool or no i cant decide
Its clean
you may want to add a bit more info but its a good start
Is it possible to use the server avatar in the footer? if so, how?
You can use any image in the footer
!d discord.Embed.set_footer
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
my_uwu_bot_client = discord.Client(prefix="!")
@my_uwu_bot_client.command()
async def uwu(uwuContext):
await uwuContext.send("uwu")
icon_url kwarg
This scares me beyond anything
Ok
Lmaooo
you forgor adding uwuContext = commands.Context so the command can work
@sick birch
ong bro i just have a dumb issue rn
?
@commands.Cog.listener()
async def on_guild_emojis_update(self, guild, before, after):
async for t in guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.emoji_delete):
with open(channel_path, "r") as f:
config_channel = json.load(f)
try:
channel_config = config_channel[str(guild.id)]
channel_id = channel_config[0]
except:
pass
with open(enable_path, "r") as f:
enabled = json.load(f)
if not str(guild.id) in enabled:
return
with open(whitelist_path, "r") as f:
whitelisted = json.load(f)
if str(t.user.id) in whitelisted[str(guild.id)]:
return
remove_emoji = [r for r in before if r not in after]
for em2 in remove_emoji:
before_emoji = await em2.read()
if remove_emoji:
await guild.ban(t.user, reason="Anti-Nuke: Deleting Emojis")
try:
emoji_display = await guild.create_custom_emoji(name=em2.name, image=before_emoji)
if str(guild.id) in config_channel:
try:
log_channel = self.angel.get_channel(int(channel_id))
embed = discord.Embed(title=" Anti-Nuke ", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{t.user}`\nID: `{t.user.id}`\nPing: {t.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member deleted a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em2.name}`\nID: `{em2.id}`\n\n**__AFTER__**\n\nEmoji Name: `{emoji_display.name}`\nID: `{emoji_display.id}`\nEmoji: {emoji_display}\n\n**__ACTIONS__**\n\n Non-Trusted member has been banned out of the server!\n Emoji has been replaced! (If asset was found!)", color=discord.Color.from_rgb(black1, black2, black3))
await log_channel.send(embed=embed)
except:
pass
except:
pass
continue
async for i in guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.emoji_create):
with open(whitelist_path, "r") as f:
whitelisted = json.load(f)
if str(i.user.id) in whitelisted[str(guild.id)]:
return
add_emoji = [r for r in after if r not in before]
for em1 in add_emoji:
if add_emoji:
await guild.ban(i.user, reason="Anti-Nuke: Creating Emojis")
await em1.delete()
if str(guild.id) in config_channel:
try:
log_channel = self.angel.get_channel(int(channel_id))
embed = discord.Embed(title=" Anti-Nuke ", description=f"**EMOJI LOGS**\n\n**__NON TRUSTED MEMBER__**\n\nMember: `{i.user}`\nID: `{i.user.id}`\nPing: {i.user.mention}\n\n**__ABOUT__**\n\nNon-Trusted member uploaded a emoji!\n\n**__BEFORE__**\n\nEmoji Name: `{em1.name}`\nID: `{em1.id}`\n\n**__AFTER__**\n\nNone\n\n**__ACTIONS__**\n\n Non-Trusted member has been banned out of the server!\n Uploaded emoji has been deleted!", color=discord.Color.from_rgb(black1, black2, black3))
await log_channel.send(embed=embed)
except:
pass
well uwuContext is never defined...
the 2nd part of the code
is going to stop if the channel id is not in the guild id
how can i pass that?
you could do uwuContext : commands.Context also
!d discord.ext.commands.Bot your code is my living nightmare
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Do you know how functions work?
I don't think you do
how would i create a catch exception for this error (person used command incorrectlty) discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'avatar_url'
Dude
๐คฆ
I'm gonna have nightmares tonight smh
it should be changed to avatar.url; it was changed in dpy v2 alpha
@velvet tinsel
yes?
the 2nd part of the code
is going to stop if the channel id is not in the guild id
how can i pass that?
check that code
shit i just realized how dumb i was being :I i forgor the function is automatically called and the propper params are alr passed in
import disnake as discord
import discord as nextcord
import nextcord as disnake
from disnake.ext import commands
from discord.ext.commands import Bot
from nextcord.ext.commands import Intents
bot, client = Bot(command_prefix="uwu", intents=Intents.all())
@bot.event
async def on_ready():
await client.close()
client.start(nextcord.Generate_very_much_random_token)
why.
Lmao
||atleast you didnt use pycord||
||shit||
wait- i forgor the namespace change but we will never know what lib you installed
cuz pycords namespace is also discord
I wanna fucking die
I'll not comment on this and save you further humiliation
I wanna fucking murder myself
this time ik im right
Me too
pycord uses the discord namespace
I killed myself
does anyone know how to fix that bruh?
thats why you have to uninstall discord.py before you use pycord
can I too?
nc and dislash have their own
||lemme join||
huhhh, pycord sucks already
||Most welcome||
tyty
@velvet tinsel do u know how to fix?
even though I might 
looking into it
Beware Mina

TypeError: __init__() takes 2 positional arguments but 3 were given```how do I find out which __init__ did this to me
whats wrong again?
read the error
what
is stopping there's no channel in the guild id
so which one
there should be like something that says def __init__(...) on line x
thats because guild.id stores the guild id
use channel.id then
I didn't pass any positional argument to edit so that can't be it
and I only passed two to my own class
cuz like if a channel is not there it has to stop sending the logs messages not the LOOP
if channel == None: idk do something else?
nope
let's see your code
try:
channel_id = config_channel[str(guild.id)][0]
except:
pass
this will try to get the channel id
what are you trying to do specifically?
I sent the one line, but you prolly want something else so Imma send more sh
how do i continue it?
that doesnt answer the question :I
ik
well is there an error?
no
ok
it stops
i said it stops
await interaction.message.edit(content="Your birthday is...", view=View(Day(value, newOptions[0:15]), Day(value, newOptions[-(days-15):])))
class Day(ui.Select):
def __init__(self, month, options):
self.month = month
super().__init__(
placeholder=f"Choose your birthday...",
min_values=1,
max_values=1,
options=options
)
async def callback(self, interaction: disnake.MessageInteraction):
await interaction.response.defer()
await interaction.send(f"Your birthday is the {self.values[0]}st/nd/rd/th of {self.month}.")
class View(ui.View):
def __init__(self, menu):
super().__init__()
self.add_item(menu)
```what about this
put multiple print statements

you like that don ya
full error pls
no
sus
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ui\view.py", line 367, in _scheduled_task
await item.callback(interaction)
File "c:\botok\Clanbot\cogs\cogbirthday.py", line 70, in callback
await interaction.message.edit(content="Your birthday is...", view=(View(Day(self.values[0], newOptions[0:15]), Day(self.values[0], newOptions[-(days-15):]))))
TypeError: __init__() takes 2 positional arguments but 3 were given
oksir
@velvet tinsel
bitch
it's the Day __init__
woah
it says Day(self.values[0] and stuff
so that is stopping
ok lemme think
wait I edited that so it spares memory
how to mention user ```@client.command()
async def troll(ctx, *, member : discord.Member=None):
try:
userAvatarUrl = member.avatar_url # to check if user was mentioned
troll_message = await ctx.message.channel.send(f"Trolling {member}...")
except AttributeError:
error_em = discord.Embed(title=f"Error Using That Command", colour=0xFFFFFF)
error_em.add_field(name="Error:", value=f"Invalid/No User Mention", inline=False)
error_em.set_footer(text="https://github.com/zoaq1")
await ctx.message.channel.send(f"{ctx.message.author.mention}", embed=error_em)```
member.mention iirc
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ui\view.py", line 367, in _scheduled_task
await item.callback(interaction)
File "c:\botok\Clanbot\cogs\cogbirthday.py", line 71, in callback
await interaction.message.edit(content="Your birthday is...", view=View(Day(value, newOptions[0:15]), Day(value, newOptions[-(days-15):])))
TypeError: __init__() takes 2 positional arguments but 3 were given
i swear i tried that but it works now
but those are still only 2
m
maybe you need self.options = options? im literally guessing since your code is
crazy
anything?
This error means I don't have perms to use the command right?py ERROR:cogs.error_handler:Forbidden: 403 Forbidden (error code: 50013): Missing Permissions (In mentionable) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/moderation.py", line 179, in mentionable await role.edit(reason = f"{ctx.author} made {role.name} pingable.", mentionable = mentionable) File "/usr/local/lib/python3.8/dist-packages/discord/role.py", line 349, in edit data = await self._state.http.edit_role(self.guild.id, self.id, reason=reason, **payload) File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 248, in request raise Forbidden(r, data)
hhhh
ikr
what are you trying to do?
errrr
What do i use to just send a message to the server
ctx.send()
i mean here def on_message
the error says "Missing Permissions"... ill let you find out the rest on your own
@dry kelp i'm sorry, but I don't know. Try claiming a help channel in #โ๏ฝhow-to-get-help
class Day(ui.Select):
def __init__(self, month, options):
self.month = month
super().__init__(
placeholder=f"Choose your birthday...",
min_values=1,
max_values=1,
options=options
)
``` don't think I have to set self.options
on_message waits for a message right?
it does
it's message.channel.send() iirc
use this?
no
use what
k
lemme do it and see
tf does iirc mean
if i remember correctly; iirc
maybe in the Super do self.options=options instead of options=options?
bro what are you saying
I'm thinking I'm missing permissions, it would throw Bot missing permissions if the bot was missing them, right?
idfk
its options not self.options
I'm having sleep demons
something similar to day, yes
go to sleep




