#discord-bots
1 messages · Page 814 of 1
not this specifically
their tos is bs
because their api is PUBLIC
discord api doesnt make sense in general
then don't waste your time ranting about it 🤷
ur acting as if ur gonna get sued for searching up how many messages someone has sent
its not that big of a deal
discord has way bigger things to worry about
this convo is making me cringe hard
thanks for worrying about their little things then, you win!
tyvm got it working now
👍
yes i am big winner
you haven't even contributed anything and your saying it's cringe
so is there any downsides to a task like this? someone mentioned something about rip limit rate?
i figured it should be fine. only about 600 members and only runs every 5 hours
im contributing by watching isnt that enough for you?
no
sorry master
"programing" 💀
you're pretty ok at that rate
" " 💀
ok sweet. well ty for all the help
" " 💀
guys stop
Faced this issue - when the user has a default avatar, user.avatar is None and I need the avatar.url. To avoid attribute error I can just do
url = getattr(user.avatar, 'url', 'deafult_url')```
But what would `default_url` be?
!d discord.Member.display_avatar
property display_avatar: discord.asset.Asset```
Returns the member’s display avatar.
For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.
New in version 2.0.
Yes
Ignoring exception in command play:
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\GUDDU\Desktop\Program\Projects with my friends\music_bot.py", line 41, in play
source = FFmpegPCMAudio(filename)
NameError: name 'FFmpegPCMAudio' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\lib\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: NameError: name 'FFmpegPCMAudio' is not defined
ffmpeg error help me
i tried installing ffmpeg using pip
that also didnt help
what should i do now
import it
!d discord.FFmpegPCMAudio
class discord.FFmpegPCMAudio(source, *, executable='ffmpeg', pipe=False, stderr=None, before_options=None, options=None)```
An audio source from FFmpeg (or AVConv).
This launches a sub-process to a specific input file given.
Warning
You must have the ffmpeg or avconv executable in your path environment variable in order for this to work.
the ffmpeg?
ok wait
yeah cannot understand what's wrong
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'FFmpegPCMAudio' is not defined

check your imports
what is the command how to get all of the channels in a server?
!d discord.Guild.channels
property channels: List[GuildChannel]```
A list of channels that belongs to this guild.
thanks
What does custom_id do in buttons? (Nextcord)
@wr_team.sub_command(name="add_team", description="Crea un nuovo team", guild_ids=[865691556736008213])
async def add_team(self, ctx: ApplicationCommandInteraction, name: str, members_id: str,
leader: Member, coleaders_id: Optional[str] = None,
channel: Optional[VoiceChannel] = None):
members_id = members_id.split()
print(members_id)
coleaders_id = coleaders_id.split() if coleaders_id is not None else None
if all(member.startswith("<@") for member in members_id):
members: List[Member] = [ctx.guild.get_member(int(member[3:-2])) for member in members_id]
if all(coleader.startswith("<@") for coleader in coleaders_id):
coleaders: Optional[List[Member]] = [ctx.guild.get_member(int(coleader[3:-2])) for coleader in coleaders_id] if \
coleaders_id is not None else None
else:
coleaders = None
team = Team(name=name, guild=ctx.guild.id, users=[member.id for member in members], leader=leader.id,
coleader=[coleader.id for coleader in coleaders]if coleaders is not None else None, voice_channel = channel)
So, I wrote all of this, just want to check if it has some sense or I'm drunk. coleaders_id and members_id are a list of mentions saved as string cuz i can't get a list of members as parameter using slash commands
it gives the button a custom id
What does that do?
I have no idea, check ddocs maybe
for persistent views
?
property persistent_views: Sequence[discord.ui.view.View]```
A sequence of persistent views added to the client.
New in version 2.0.
i mean for discord its for persistent views im not sure if its the same for nextcord i assume yes
since its a fork if not im not sure
It's the same for all forks if they didn't update the UI code
yeah im not sure because i havent checked there src code
What are persistent views?
a view thats stuck with the bot so when it resets it you can still use buttons
so it wont fail the interaction
loll
I need to train my brain to recognize its you based on any dog sitting being your pfp instead of one specific thing
im not sure i havent used them but theres a tutorial in dpy git
Okeh, thanks
😭 lmaooo
just read my name
yw
Pictures are the first thing i notice and look for. They are more distinct at first glance. Also do you know much about discord bot databases? I think there is an asynchronous one typically used in bots but i forget its name and how it differs from other databases
how do i make the bot delete all channels without asking for a argument?
depends on what youre trying to store it in?
what
sqlite uses a file which you can use aiosqlite if youre using pg use asyncpg i think it was the name of the bridge
idk seems sus
It would be used to store stuff like a date time and message contents to remind a person in the future
sqlite uses a file to store data maybe that can interest you?
Didnt know sqlite was async
nah its not
aiosqlite is the async bridge of it tho
stuff like that are used for nuke bots which is against tos which we cant help with that here
Oh, im at least familiar with sqlite i think ill check out aiosqlite just in case it sounds like the one im thinking of
!pypi aiosqlite
pretty easy all you need to know is sql
ah okay but i assure you i am not intersted in destroying someones work
I dont see any reason for a bot needing to do something like that when a delete server button does essentially that
idk im not sure if i should help with such a question which can easily be against the rules
no no its okay
It ehrs too much on rule 5 territory for me
not myself but everyone here its a sensitive topic
ye thanks anyway
can i just ask that how do u get all the channels in a guild?
i hope thats not against tos
!d discord.Guild.channels bruv
property channels: List[GuildChannel]```
A list of channels that belongs to this guild.
your os couldnt open the source lol
i tried that but im new to it to i cant understand that website
ctx.guild.channels
thank you very much
If I was in the vas code I was download the font and link a path
Id suggest learning and familiarizing yourself with the docs. It will be your bible when making bots
repl
Dont use repl
seems like it couldnt open the img ig

It's just a bridge so the core stuff remains the same
Did you import has_permission?
it is inside discord.py package...
It’s not only @urban notch_permisson
Try using like this
@commands.has_permissions(manage_messages=True)
he can just import from discord.ext.commands import has_permission, then he can use it like this
then it underlines commands.
And import permissons from discord
and then shows an error thing
Do it like this
from discord import permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
see? it is not a check
Try just to do that
did you import commands?
How much do you know python?
from discord.ext import commands
GL
thanks ill need it
Then study python first, you can't develope discord bots in python without knowing python
embed.add_field(name=f"Message Sent by {message.author} Deleted in #{message.channel}", value=f"Message : {message.content}", inline=True)
``` not pinging the channel
you need to know what a class is, what is a parameter, what is a method, what is a coroutine, what are arguments and so go on
bro you can't tell him everything, is like it is you who are developin the bot 😆
so.. he SHOULDNT help me?
You need to put him on the line with bot= commands.Bot(command_prefix”your_sign”)
I just help him
it's not like that
He can help you, but he can't literally tell you what you have to do
how are you supposed to learn like this?
He need to learn
like this
yes, need to learn python
Lol right
No no
discord.py doesn't have discord.Bot(), which library are you using?
So sure? xD
i am using discord.py
Yeah I'm pretty confident discord.py doesn't have discord.Bot lol
Cz it doesn't
First, do what I told you at first time.
From discord.ext import commands
After, delete the first line here and sty only the second.
After, change at the line instead command_prefix”#” -> command_prefix=“#”
Guys, literally he has to learn python xD
embed.add_field(name=f"Message Sent by {message.author} Deleted in #{message.channel}", value=f"Message : {message.content}", inline=True)
``` not pinging the channel
message.channel.mention
Lol you right
But let’s help him right now so he can start working
Without knowing how to read the docs? XD
That’s really a problem
@halcyon bison u good?
i already did from discord.ext import commands
no point in attempting to code a bot when you have no experience w python whatsoever
you're always going to encounter errors and a result you'll come back to this channel everyday seeking help
then ill seek help until i get some 😎
it's best to start w the beginners manual before starting on something way beyond your level
i did all thi
this
Bro it s not like we don t want to help you
bro
Is it possible to make sure that when a participant is banned, his messages are not deleted?
i just explain you step by step
But you re tryin to use some methods without even importing the class / method you want to use
vc channel join event?
While you can definitely learn discord.py by struggling through and learning python as you go, I can promise you that reading up on some core concepts first (see https://www.pythondiscord.com/resources/) will help you enormously with the process :P
he can try but it'll get complicated when people refer to certain functions in python
vc channel join event? discord.py
i remember you when i first joined
Is like riding a car without the driving license
i do that all the time
no i dont im kidding
Is it possible to make sure that when a participant is banned, his messages are not deleted?
!d discord.Guild.ban
There is something written in the docs about that, check it
!d discord.Member.ban
await ban(*, delete_message_days=1, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
Okay
Oh sorry, wrong reply, didn t noticed lol
@commands.command(aliases=['w'])
async def uis(self,ctx,*,user: discord.User = None):
if user == None:
user = ctx.author
await ctx.send(f"{user.banner}")```
i'm getting output as None even if user has a banner
Why are you gettin' all the parameters given even if you take only one user?
id suggest if not user: or if user is None:
Minor fix xD
that part doesn't have a issue it's working fine in other commands tho
i know it doesn't but i suggest if not user: or if user is None: over if user == None:
okay
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.0.value: This field is required
``` what does this mean
It's just PEP syntax, it works comparing to None but it is better using not variable or variable is None or variable is not None or just if variable
variables in if statement returns True if they are not None / empty, otherwise False
looks like you didn't provide a value(body) of field
if variable checks if the variable value is a truthy value
if not variable checks if the variable value is a falsy value (and im pretty sure None is a falsy value)
as i said, True or False if they are not None / empty
i want to host my bot is there any website for free?
o ye
if variables are boolean then it is taken their value
means?
show your code for embed
i have a emty string here
empty*
U can't have a empty string
okay
Use an invis char instead
well there are empty lists/ tuples/ dictionaries/ sets, they all returns None
syntax?/
Just Google it
** **
should do the trick
okay
those are empty so they return false, i thought 0 was the only empty thing sorry i misunderstood
free hosts are not recommended
ya i need i remove value and it show error
TypeError: add_field() missing 1 required keyword-only argument: 'value'
not sure if 0 taken as int is considered as empty
ok
i mean doing print(int(1)+int(0)) does nothing
!e
a = 0
print(True if a else False)
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
False
embed.add_field(name=f"{member.name} Joined {after.channel.name}", value="** **", inline=True)
interesting
uh
even the return code is falsy 🤯
embed.add_field(name=f"{member.name} Joined {after.channel.name}", value="\u1cbc", inline=True)
!e ```py
print(bool([]))
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
False
This is the same as mine but who would ever remember that unicode.
empty lists
empty container datatypes returns false as their boolean value ig
all working good but 1 issue
.
read docs
you need to get the user first using get_user
!d discord.User.banner
property banner: Optional[discord.asset.Asset]```
Returns the user’s banner asset, if available.
New in version 2.0.
Note
This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
Read this note.
help I am not able to find anything

Lol you didn't provide a lot of information here
if nothing is sent and no error provides it means that the len of temp is greater than 0
now you're just splittin' the first element of the string line D_D
you're like doin this:
!e
str_1 = "abcd"
print(str_1.split()[0])
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
abcd
how can i create same command as normal command and slash command in nextcord since slash use interaction and normal command use context so i no longer can do ```py
async def call(self, ctx, arg):
# do stuff
@commands.command()
async def command(self, ctx, arg):
await call(ctx, arg)
@nextcord.slash_command(name="command")
async def _command(self, interaction, arg):
await call(ctx, arg)
if your file is not empty then you will not find any line with a len of 0, so your code in the if block will not even execute
!e
str_1 = ["abcd", "efg"]
for lines in str_1:
if len(lines)==0:
print("found nothing")
@placid skiff :warning: Your eval job has completed with return code 0.
[No output]
see?
channelslogs = bot.get_channel(927193880116473906)
not getting channel for some reason
i tryed channelslogs.send("hi")
Are you calling this in a command?
ofc not
Then where
1 colom
What
how i tell u
Send the code
I'm aware. Which is why I'm asking you where you're calling the function
with open(add_path, "r") as f:
bypass = json.load(f)
if len(guild.members) < 100:
if guild.id in str(bypass):
return
await guild.leave()
return
use string
for guild id?
what is bypass
list
Then why are you making it a string
with open(add_path, "r") as f:
bypass = json.load(f)
if len(guild.members) < 100:
if guild.id in int(bypass):
return
await guild.leave()
return
this?
bypass is a list
of numbers
Of strings
string has number
yes
So? You can't call int on a list
i called it somehow
No lol
for member in AFK_PPL:
user = bot.get_user(AFK_PPL[0])
AFK_PPL have ids of members
its a list and
?/

calling or adding?
calling here
terminal need both int or both str
.I
I
V
channelslogs = bot.get_channel(927193880116473906)
@bot.listen()
async def on_message_delete(message):
@vocal snow
HELO>
The unban command does not unban a member by id, it does not write anything to the console. Why?
show code.
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475)
async def unban(ctx, *, member, reason="Отсутствует"):
emb=discord.Embed(title="Разбан пользователя", description="**__Информация:__**", color=discord.Color.from_rgb(0, 255, 0), timestamp=ctx.message.created_at)
emb.set_footer(text="© Все права защищены The Greatest", icon_url=ctx.author.avatar_url)
emb.add_field(name="**Участник:**", value=f"**{member.name}** ({member.mention})", inline=False)
emb.add_field(name="**ID:**", value=f"**{member.id}**", inline=False)
emb.add_field(name="**Разбанил:**", value=f"**{ctx.author.name}**", inline=False)
emb.add_field(name="**Причина:**", value=f"{reason}", inline=False)
await ctx.reply(embed=emb)
member is a string here
So im creating a purge command and i want to set it so that theres no limit to how many messages it can delete. how do i do that?
check purge method in the docs
i have used the docs but cant really understand how to
and you can only have one keyword-only argument, not two (the last one will always use the default value passed to it)
it is not that hard lol D_D
i meant i am not able to understand from the docs like how to read from the docs
its kinda confusing sorry
don't pass the limit
🤔
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
Reason remove?
what?
thanks
Limit is an Optional parameter, it means that it can be set to None
ohh ok thanks so much
I am using nextcord to build a timeout command and even though it executes the ctx.send part the thing is not working for some reason here is the code
Hey @brittle axle!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
ok
Hey @brittle axle!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
can you purge messages from a discord bots dm?
Only messages from bot itself
how to do that
ive tried it many times
from the bots message history but i cant seem to be able to do it
I forgor lemme check
okay thanks
yes but only the bot's messages
and you would use a check for that
i mean to do that
check?
purge takes a check parameter to make sure what messages to purge
ah
??
use history and delete messages one by one
I don't remember the name of the class
i tried to do that but cant seem to be able to do that
!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
Ok check the methods of this @ashen locust
okay thanks
async for message in DMChannel.history(range_of_messages):
if message.author==Bot.user:
await message.delete()
``` is the only way
thanks so much
thanks for pointing that out, exenifix :3
Np
gain = 25
for i in gain:
this seems to bring up all sorts of errors, can loops not work when using discord.py?
You can't iterate an integer?
don't think so
you can iterate only in an iterable like a list, tuple or string
thanks both of u
Maybe you meant
for i in range(gain)```
how can i do this then?
AHHH thank you :D
Anyone needs a normal time converter that uses regex
At least I think I made it to be normal
@slate swan im really sorry if im disturbing you but it says "DMChannel" not defined
aiosqlite hurts my brain im really tempted to use json for my economy since it's easier
Here's a time converter that uses regex in case anybody would need proper time conversion.
from datetime import timedelta
from re import search
from discord.ext.commands import Converter
class TimeConverter(Converter):
async def convert(self, _, arg: str) -> timedelta:
arg = arg.lower().replace(" ", "") # lower the string and remove spaces
values = {"days": 0, "hours": 0, "minutes": 0, "seconds": 0}
for k in values.copy():
try:
value = search("\d+" + k[0], arg).group() # search for a number that stands next to a certain letter
values[k] = int(value.replace(k[0], "")) # extract the number
except:
pass # if the number wasn't found, just leave it with the default value - 0
return timedelta(**values)```
It will convert any string like `1d2h3m4s` to a timedelta:
```py
"5h" -> timedelta(hours=5)
"1d30m" -> timedelta(days=1, minutes=30)
#some non typical examples
"6m4h" -> timedelta(hours=4, minutes=6)
"10days 50minutes" -> timedelta(days=10, minutes=50)```
As you can see it doesn't care about the order and full names and works in any case.
oops not here
Imho asyncpg is easier than aiosqlite
But requires knowledge of postgres
yeah i don't know what that is either, what's the easiest database to learn
SQLite
for a discord economy
But in terms of library the aiosqlite is aids if you ask me
oh yeah coz im a beginner, and I got json quite easily
Json is easy of course lol
It is similar to common dict
And database is a different data structure
Which is way more complicated
But faster and better overall
you can try using classes and then using pickle to save the objects
The json can't be used for storing large amount of data
For god's sake don't
that's why I'm trying to learn aiosqlite
lol if you have to save list of things you can't rely on sqlite
it's so hard
Postgres has arrays + you can store it as a string and split
Postgres. Not sqlite
When I was a beginner I was using pickle and it turned into hell eventually
what's a short tutorial that explains aiosqlite quite easily
Sqlite second method
and ok, i'll store a string, what if those are strings of int? or those are strings of member id's?
Easy
I have to take them, split them and then convert them any time i want to access a member
i'll just save the object in a binary file and then load it when it is needed
And if you have like 1k of those files?
what's the problem with that?
Even 100 would be an issue
why? xD
why not
because it is a mess
tell me why D_D
how so?
Ok lemme tell you
i had no issues so far
dmchannel there signifies the class, you need to use you own instance
!d discord.User.dm_channel
property dm_channel: Optional[DMChannel]```
Returns the channel associated with this user if it exists.
If this returns `None`, you can create a DM channel by calling the [`create_dm()`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.create_dm "discord.User.create_dm") coroutine function.
Idk the message says success but the user wont get timedout
or takin it from the context if he has it
i fixed that error but it says "int object has no attribute _state"
show code
how would i put a custom emoji in a dropdown/select menu
So I created classes for user, member, and guild data. Each class had its own file that was put into some directory and it all was working fine until some weird stuff started happening, so basically I accidentally added wrong method to the class and everything got corrupted.
Disadvantages of using pickle "database" so far:
- many files != good
- updating data structure is complicated (you would have to overwrite every file)
- any mistake = corruption
When i click the dropdown the dropdown doesn't pop up.. But when i remove custom emoji it works
@placid skiff
what?
history(limit=10)```
uh helllo?
Try printing the converted time
ohh]
Well, in pickle docs it is said that saving classes has some limitations, saving member discord object is not suggested
ok
ill try that
i'm saving just custom objects
Also it might have issues with loading classes from different modules
Personally I parse data from the database to an object and use it
it is more easy to get information from a list of int saved into an object instead of gettin a list of alnum string saved into a database
Can't show you my implementation unfortunately because the repo is closed source
I agree but once again, it may turn into pure hell one beautiful moment
well that could be the reason why your files got corrupted
I saved my custom objects, not the members
It contains weakrefs that are not serialisable
@vale wing
in the end, I'm not saying that using pickle doesn't have any trouble, you have to pay more attention on it of course, but you can do a lot of process in an easiest way
@vale wing the time conversion got printed out but the user was not timed out there were no errors on the terminal either
what should i do?
And what the time conversion was?
i put 60 seconds and it printed out 60
lemme try 1 minute
nvm it worked with 1m thank you for the help man
@bot.command(name="sell")
async def sell(ctx, mineral=str, amount=int):
global dirt, iron, stone, coins
if mineral == "dirt":
code code code
else:
await ctx.send("This is not a mineral")
when i run this and type sell dirt 5 it says 'this is not a mineral'
someone jnows how can i pase the member avatar on a pillow?
i have image and the pillow paste text on it
https://sourceb.in/w7aXsAQN5VOkay this is my filetree and I have a function called timestamps_av in my info.py file but when I do from .info import timestamps_av,fromcogs .info import timestamps_av or from info import timestamps_avin events.py it errors telling me it can't find it
Anyone know how to do so?
i wanna also pase avatar on it
can anyone help
Wrong typehinting
async def sell(ctx, mineral: str, amount: int)```
the right one ^
By adding = after an argument you set a default value for it
@heavy belfry check this out
https://docs.python.org/3/tutorial/controlflow.html#more-on-defining-functions
ah, thank you, this will be really helpful :D
what?
You can’t delete messages that aren’t yours.
Unless it’s in a guild and the bot has manage messages.
Oh I see, my bad(I honestly didn’t read all of it) .
Yes
Oh. You literally just called the class DMChannel.
What do I need to correct in that then?
Im Kinda new to discord.py so any help would be greatly appreciated
ctx.author.dm_channel
There’s no DMChannel between you and the bot then
Send some messages to the bot in its dms
And try again.
await it
does that user have their DMs closed in privacy settings, should look like this
anyone mind checking this? I always seem to have import issues which is why I tend not to import things from other files
link doesn't work?
ill check that thanks
yeah just noticed lol, https://sourceb.in/w7aXsAQN5V
How do I make sure my bot doesn't pass too many ratelimits?
d.py handles that for you
but if you do anything excessive your bot will get rate limited
I still get this error several times
nextcord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
show error
My bot doesn't spam or do anything, but it still got blocked
What host are you using
yeah
replit uses shared IPs, so if someone gets ratelimited on an IP, everyone else gets ratelimited too (read 🧷's for more details )
oh
- Buy a VPS
- Use another host
so now, every single bot running on repl is ratelimited-
broo aiosqlite hurts my brain
ok
maybe
i can't code a simple economy with aiosqlite bruh bruh
whats hard?

SQL is easy lol
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/modmail/cogs/events.py", line 14, in <module>
from .info import timestamps_av
ImportError: cannot import name 'timestamps_av' from 'cogs.info' (/home/modmail/cogs/info.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/modmail/classes/bot.py", line 127, in start_bot
self.load_extension(extension)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: ImportError: cannot import name 'timestamps_av' from 'cogs.info' (/home/modmail/cogs/info.py)```and there's about a dozen more errors related to the bot then being unable to open the log file
is timestamps_av even a thing in the file?
wish it was
it is-
it isn't for me
yeppy async def timestamps_av(self, member, embed, avatar): embed.add_field(name = "Joined Server:", value = f"<t:{int(member.joined_at.timestamp())}:R>", inline = True) if avatar == True: embed.add_field(name = "Avatar", value = f"[PNG]({member.avatar_url_as(static_format='png')})", inline = True) embed.add_field(name = "Joined Discord:", value = f"<t:{int(member.created_at.timestamp())}:R>", inline = True)
so it's inside a class
import the class first..
from .info import MyClass
MyClass().timestamps_av(...)
sopy from cogs.info import Info # class Info(commands.Cog):and then can I do py from Info import timestamps_avor is that wrong. I'm calling the function like thispy await timestamps_av(member, embed, True)in events.py so would I then dopy await Info().timestamps_av(member, embed, True)
you can't import a method inside a class like that
just do ```py
from .info import Info
await Info().timestamps_av(...)
thanks for the clarification on how much of a idiot I was being 
👍
also do I need the from .info or would just from info work?
Whats a good alternative to discord.py
Depends what file you run the bot from
Disnake, pycord and nextcord are the main ones
disnake or nextcord
it's running from a file with the same folder
i have heard of pycord, is that good ?
I have heard PyCord is not as great as the other ones
now theres the choice, disnake, pycord or nextcord lol
I heard it's mostly pycords support server that let them down, their lib seems decent but I've heard support can be downright rude
which tbh I'm not that surprised about, d.py's support often came across as rude in my opinion and experience
hm
@bot.command()
async def off(ctx):
ticket = client.get_channel(940743666014765138)
embed=discord.Embed(title = "**השרת סגור לרגל תכנות ** `🛠️`", description = '**השרת יחזור בקרוב, תשארו מעודכנים !**' "\n" 'לכל בקשה או קבלת עזרה יש לפתוח טיקט: {ticket.mention} ')
embed.set_thumbnail(url = ctx.guild.icon_url)
embed.set_footer(text = f'{ctx.guild.name}', icon_url=ctx.guild.icon_url)
await ctx.send(embed=embed)
ctx.guild.get_channel()
why the ticket mention is not working?
Why need support when you have this friendly server 
I suggest going with disnake
^ same
How is client defined
ill take a look into that !
It shouldn't matter
personally I'm moving over to hikiari once I'm done with d.py
@bot.command()
async def off(ctx):
ticket = bot.get_channel(940743666014765138)
embed=discord.Embed(title = "**השרת סגור לרגל תכנות ** `🛠️`", description = '**השרת יחזור בקרוב, תשארו מעודכנים !**' "\n" 'לכל בקשה או קבלת עזרה יש לפתוח טיקט: {ticket.mention} ')
embed.set_thumbnail(url = ctx.guild.icon_url)
embed.set_footer(text = f'{ctx.guild.name}', icon_url=ctx.guild.icon_url)
await ctx.send(embed=embed)
now
Oh
How is bot defined now
Is your bot variable named bot?
wait how / where do i install disnake
pip install disnake```
oh
kek im dumb
hope my laptop isnt trolling me today, mostly installed packages dont get shown or i get errors like i dont have it lol
You have such issues?

Is that replit
vsc
https://mystb.in/ContainedCircumstancesBrussels.python
why .vc setup isn't working
Vsc doesn't have issues with installing packages as far I am using it
discord-interactions==0.3.0
discord-py-interactions==4.0.2
discord-py-slash-command==3.0.3
🗿
it doesnt matter where i run it lol
Maybe you installed dependencies on another Python version
Missing indent (after line 158)
Did you restart vsc?
dunno how do i check that

type pip freeze
and download vsc's python extension to configure your interpreter
The discord bot space seems swamped with bots, anyone know a good usecase/genre for a bot that isn't as swamped?
ok then?
Do you see these?
It should print the packages you have installed
@bot.command(name="chop")
async def chop(ctx: commands.Context):
global chopping, wood
if Forest_card == 1:
def get_wood():
global wood
global chopping
wood += 1
await ctx.send(f"\n you have now got {wood}")
chopping = False
if chopping:
await ctx.send("chopping wood already, please wait!")
else:
chopping = True
threading.Timer(180.0, get_wood).start()
await ctx.send("In 3 minutes you will have 1 extra oak wood!")
this error comes up
SyntaxError: 'await' outside async function
any way i can fix this and still be able to type other commands during the 3 min wait?
!pypi discord-py-slash-command
A slash command handler for discord.py.
Oh but type pip freeze in your Visual Studio Code terminal window
@desert badger is py extension installed and the interpreter configured?
your def get_wood function should be async too
ah xd, thanks missed that xd
^
how do i check that lol
im dumb af
the extension is installed yes
can you explain pls
In the top left corner there should be something like "Python 3.8" or whatever version you have
where can i find disnakes docs ?
with statement must be indented
async with aiosqlite.connect(...) as con:
async with con.execute(...) as cur:
...```
it has no difference with discord.py, but has more features
Ok and you are not using venv right
o
whut
in your terminal does something like (venv) appear before the directory?
If you don't know that you are not using it that's for sure
In vsc it requires some operations to activate
maybe he has it enabled automatically
im confused
If that would be pycharm yeah, but in vsc you would need to run some commands first
@desert badger do those packages import in IDLE
no

what is the problem?
Might be an issue with the package itself
kill me
Wth
that shit happens to me since over 2 months
did you check if the interpreter that you are using is the local one?
Enable tracemalloc to get the object allocation traceback
how do i enable this?
@vale wing do you know how to check the interpreter in VSCode?
Ctrl+shift+P -> select interpreter
does what he said and send us the screen
this ?
Yes
Select interpreter
its always shown in the bottom left corner
Show us what options it has
it is the local one D_D
is that bad or sum
How to unban a user by id?
run an external terminal and type py -m pip freeze
Enable tracemalloc to get the object allocation traceback
how do i enable this?
external terminal? 😳
@desert badger you can DM me in like 4 hours if you don't resolve that issue, I may try to help you with it by using remote access if you would like to
search in windows cmd or powershell D_D
Hey @flat solstice!
It looks like you tried to attach file type(s) that we do not allow (.log). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
ye hope my laptop wont die its 9 yrs old and even discord is lagging :(
O
Packard Bell EasyNote Le69KB lol
69kb looks sus
I had that too lol
its fucked
but back in 2010 xD
btw it doesnt show
yea im in 2022 and im broke ._.
type there py -m pip install disnake
Enable tracemalloc to get the object allocation traceback
how do i enable this?
probably found the issue 😄 it was a venv that he was using in the end xD
Have you googled it
use the browser to have less lag I'd say
the client eats RAM
I am pretty much sure you can find that there
you have to learn how to read errors, there's more to that one line
He means how to enable the tracemalloc
check know if it shows the same issue
):
that's not his question, he just want to fix the error
he thinks it's enabling that stuff, but that's not his actual error
lol pretty fast on downloading disnake even if it is that old btw
Maybe
seems like you're in a venv
whats that
Below it tells "something was never awaited"
yes
he has installed disnake in venv too D_D
yea
You don't really need the allocation traceback lol
does'nt seem like it
he is in venv but he is using the local interpreter
Just look what is not awaited and await it @heavy belfry
im restarting vsc
right
probably won't solve the issue xD
never underestimate the power of a restart
@desert badger do you have folders like Lib, Scripts
Lol
i have here is the code
async def chop(ctx: commands.Context):
global chopping, wood
if Forest_card == 1:
async def get_wood():
global wood
global chopping
wood += 1
await ctx.send(f"\n you have now got {wood}")
chopping = False
if chopping:
await ctx.send("chopping wood already, please wait!")
else:
chopping = True
threading.Timer(180.0, get_wood).start()
await ctx.send("In 3 minutes you will have 1 extra oak wood!")
elif Forest_card <= 0:
await ctx.send("You have not unlocked this yet. Hint: buy a Forest pass in the shop")
it has a problem with the async def get_wood and that error apears
where
🤦♂️
we're asking you
in your project folder
what error?
In your project root folder
RuntimeWarning: coroutine 'chop.<locals>.get_wood' was never awaited
self.function(*self.args, **self.kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
don't use threading.timer to sleep
use await asyncio.sleep(...)
try doin this threading.Timer(180.0, await get_wood).start()
The problem is where you call the get_wood() but I don't see where it is
ty, ill try it
fetch the user and use the unban method on the User object
@placid skiff LMAO RELOADING HELPED
umm....welp
Nice
or ?
Weird you had a venv there, like how
Lol, probably it doesn't reload automatically
Not used in code
You haven’t used it anywhere
all g
uhh, anyone?
pls stop reading warnings and stuff from the IDE, first write some code, and try to fix them AFTER you run, not by checking the IDE all the time xd
what lib @slate swan
disnake
python has 2 types of warning, the one you saw before was a critical warning, this one "not accessed" is a normal warning, depending on syntax, variable/package usage and so go on
!d disnake.ApplicationCommandInteraction.channel
No documentation found for the requested symbol.
lemme check
!d disnake.ApplicationCommandInteraction
class disnake.ApplicationCommandInteraction```
Represents an interaction with an application command.
Current examples are slash commands, user commands and message commands.
New in version 2.1.
!d disnake.ext.commands.InteractionBot.get_message
get_message(id)```
Gets the message with the ID from the bot’s message cache.
only channel_id
I'm using CommandInteraction though
I was using it just yesterday when writing a bot and it all showed up, certainly for guild although there's no guild in docs
they where too lazy to create a channel attribute xD
It's a typealias
and it still doesnt work
it still doesnt work
so disnake works like discord.py ?
yeah
not actually, they're saving cache storage / just following the API
Mostly yes
Yup, is a fork
I know, just joking xD
oooo
@vale wing oh wow, thanks, I guess it'll work
it has other features added and it is maintained, you will find them in the docs, and the docs is pretty the same as discord.py docs
i'll send you the link again: https://docs.disnake.dev/en/latest/index.html
thank you :)
Well most likely the channel is just a property that is not documented, because I have this code and it works fine
https://github.com/BobuxBot/BobuxAdmin/blob/master/ext/commands.py#L131-L152
im already confused :( what is this i have never used something like this really lol
use bot not client
Ok will python bot fetch code or nah
i always use client tho
Ok it won't nvm
if you are starting python a bot isn't a good project
RuntimeWarning: coroutine 'chop.<locals>.get_wood' was never awaited
handle = None # Needed to break cycles when an exception occurs.
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
still am getting the same error
i started 8 months ago im just dumb
ohk
It is the same as client = commands.bot(prefix="&")
but that creates a bot by subclassing the Client class, it can be done by subclassing the Bot class too
when i understand something i can do it
error says it all
wait am i allowed to dm you ?
You should try it, 8 months are enough experience for doing it, on youtube you can find a good tutorial too if you feel that lost
of course
explain please
so to do shit in 3 mins, you do
await asyncio.sleep(180)
await get_wood()```
and there you go
async def bm(self, inter: disnake.CommandInteraction, message_id: str):
await inter.response.defer(ephemeral=True)
message = await inter.channel.fetch_message(int(message_id))
it says unknown message everytime?
like that ?
https://mystb.in/PatioSwazilandWidth.python
The user is unbanned, but the embed is not displayed, why?
code
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475)
async def unban(ctx, member):
banned_users = await ctx.guild.bans()
for ban_entry in banned_users:
user = ban_entry.user
await ctx.guild.unban(user)
emb=discord.Embed(title="Разбан пользователя", description="**__Информация:__**", color=discord.Color.from_rgb(0, 255, 0), timestamp=ctx.message.created_at)
emb.set_footer(text="© Все права защищены The Greatest", icon_url=ctx.author.avatar_url)
emb.add_field(name="**Участник:**", value=f"**{member.name}** ({member.mention})", inline=False)
emb.add_field(name="**ID:**", value=f"**{member.id}**", inline=False)
emb.add_field(name="**Разбанил:**", value=f"**{ctx.author.name}**", inline=False)
await ctx.reply(embed=emb)
return
ctx.send?
Remove reply?
replace reply
yes
Okay
await ctx.send(embed=emb)
Okaayy
Why message id = str
What is the purpose of the return at the end?
Do you pass this as a function to something else or just use it for the command route in discord?
If the latter you don't need a return
hello i cant install pip files (python module)
error: can't open file 'C:\Users\aero\Desktop\Discord-Bot\install': [Errno 2] No such file or directory
help me please
idk why, but when I typehint it as an integer, it just doesnt let me proceed telling me to input an integer
@slim ibex
?
Try this message_id: int = Param(large=True)
embed is not displayed, although the user is unbanned
Or commands.Param(large=True)
Is any exception or error thrown?
waht
Help
don't define your client, just create a copy of it with perms then do client.run('t0ken') at the end
where is the Param going to come from?
.
oh wow, thanks
oki thanks it worked
good
how to install asqlite module
pip install aiosqlite
and it stopped working again
adamya = Image.open(r"C:\Users\prana\Documents\discord_bot\apple.jpg")
if msg.startswith('!twerk'):
await ctx.send(adamya)
umm how can i send the variable adamya???
uh nvm, xD, I did some shit
that will not send the image?
umm how to send it then?
could you tell the code?
how are you even getting the context first of all ;-;
also
idk
i saw it online
the first command was
await message.channel.send(adamya)
wha..... smhh
and?
and it didn't work
Just upload that image somewhere and send the link 
imagine using the file parameter, welp
i mean how can i send that variable named "adamya"
in discord.py
uhh, just send it
umm what?
just send it, even though it wont send anything since you're opening the file using PIL ;-;
you mean send the whole code?
!d disnake.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") objects. **Specifying both parameters will lead to an exception**.
use the file parameter
send(file=discord.File(file_path))```
not variable
ohhh
thanks
but if you do like image.paste command
how can i send the image in discord.py
first save the image and then use the file parameter
So I have this command https://sourceb.in/GO6fRB56Uu which fetches the history of a channel for me to then iterate through to check for some key words (I use Mee6 for my logging but I want the moderation logs public so I'm making a script to repost them to a different channel). The command is definitely doing something bc I am getting print outs however it is not posting the embeds. i'm getting getting any error's so I'm thinking there is something wrong in py if all([ message.id not in checked_logs, message.author.id == 776782769312628746, # Checks if the message author is my log bot len(message.embeds) > 0, # checks if the mesage contains embeds ]):however I have just realised that Mee6 sends logs as webhooks, would I need to do something else to get a channels webhook messages?
I don't see necessarily doing this with a discord bot tbh, maybe just when you modify the image like welcome embeds and such but most of the time not worth, because if you ever change the host you need to manually modify the paths too 
uhm yeah, different case in full paths
sorry
for?
for frustrating you
no?

lmaooo
Imagine having ~200 images and or gifs and you need to save each of them 
imagine dealing with 200 images for no reason ;-;
if file is from website u dont need to save it to upload just read it and upload it to discord
<&idofchannel> or something
uhhh okay, sorry sir
sir
https://mystb.in/TortureRevealsScreenshot.python
why cmds doesen't works exept .help
heh lol
Idk tho
I deal with over 160
Though there's a reason
imagine having no reason for this
lucky you, you have a reason
thats all I can say
I can't see someone sane doing this without a reason
I keep wondering
Why dyno and mee6 or other big bot don't have an option to display user banners because it's almost the same method as for avatars
hey guys
hey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guys
hey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guyshey guys
In the unban command I use {member .name} and when I unban the user, there is no embed, but the user is unbanned, why?
cool but 72.11.148.222:56533
show code
Okay
Lmao
how do add buttons like this to my bot
i havent used discord.py since 2021 so im outdated
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475)
async def unban(ctx, member):
banned_users = await ctx.guild.bans()
for ban_entry in banned_users:
user = ban_entry.user
await ctx.guild.unban(user)
emb=discord.Embed(title="Разбан пользователя", description="**__Информация:__**", color=discord.Color.from_rgb(0, 255, 0), timestamp=ctx.message.created_at)
emb.set_footer(text="© Все права защищены The Greatest", icon_url=ctx.author.avatar_url)
emb.add_field(name="**Нарушитель:**", value=f"**{member.name}** ({member.mention})", inline=False)
emb.add_field(name="**Разбанил:**", value=f"**{ctx.author.name}**", inline=False)
await ctx.send(embed=emb)
return
@slate swan
Why you mention the member
They're not in the server
Also
You use dpy or a fork
use discord.py's master branch, or a fork
a fork is more considerable since discord.py is no longer developed
do i need to update discord.py
you cant
oh...
install the master branch, 2.0 has it
Fork are more recommended btw
nah mate
pip install -U git+https://github.com/Rapptz/discord.py
through git
I removed {member.mention}, but the embed is not displayed
i need to install git now?
oof ight thnx ig
forks have slash commands too, which you may be obliged to use in future!!!
if your bot gets verified without message intents
now tell me how do i use forks
a fork is a new package based on another one
so they works exactly as d.py
but are maintained and has other features
choose one of the forks, disnake, pycord, nextcord are some famous ones ( ill suggest disnake)
replace discord with the fork's namespace
thats it
ohh but all my previous discord.py code will still run right
yes, other than a few minor things which you need to change
like member.avatar_url is not member.avatar.url
alrit thnx 
.
wait wasn't that like a dpy 2.0 change?
like if your bot is this:
import discord
client = discord.ext.commands.Bot(prefix="a")
client.run(token)
with disnake it became:
import disnake
client = disnake.ext.commands.Bot(prefix="a")
client.run(token)
help
that is, and it will be changed in the forks too
WTF is @vc.command?
vc is a group command parent's callback
got it
saw that now, btw, every command don't work?
so i only need to change this part to disnake.ext?
if they're still running 1.7.3 there might be a bit more breaking changes tho
@mild harbor
yeah, all of the discords to dosmale
what should do ?
all commands don't work?
no idea buddy, didnt the repo's author gave a support link?
exepct .help
ahh got it thnx
the developer don't give shit abt his code
do you have something like @bot.event async def on_message(message) somewhere in your code?
why dont you try making it yourself
as that code is really bad at points
Wait why in the hell did you name a group command like the class name?
he didnt, he just downloaded the code from github
LOL
its not mine
how
lol
you cant trust everyone on stack overflow either
so that code isn't work
so far i found no issues with fixing my error by searching them on overflow 😆



sorry im dumb