#discord-bots
1 messages · Page 985 of 1
We have already tried that
Was it the “loop cannot be accessed outside an async function” error?
Well then the topgg library is not working with discord.py 2.0 probably
ok
Ok
Ok
Ok
Why don't you just make a normal request to the api instead of usne that wrapper?
It's not at all hard
Yeah I'm sorry but I don't want 100% understand this way of doing it
Hey guys! How would I change the duration of a task.loop every time it is run?
I want to make it a random number of minutes between 30 and 60, but when the task is started, it just picks a random number between 30 and 60, sets it as its minutes to loop, and doesn't change (since it's not being rerun)
How would I fix this?
Hello, could anyone point me in the right direction to learn how to turn discord commands (i.e !playmovie night of the living dead) into context dependent commands? (in this case [client.playMedia(night of the living dead])
well that happens sometimes when hosting on replit
LOL ye it takes like 1 min to cooldown
!d discord.ext.commands.Cog.cog_check
cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.
This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
And check the guild id
If you're talking about extensions, I don't believe so
Maybe in your setup() you could conditionally load a cog
Nevermind that wouldn't work
With a cog check it'd work
yeah define it within the cog class
Heyo, anyone familiar with task loops
What do u need help with
best python interpreter version for discord bot?? Is there a go to version for discord.py?
any interpreter thats 3.7+ is usable for dpy
thanks
Sorry @torn sail. Forgot to come back to this. I need help changing the duration of the loop on loop
Is that possible?
cog_check is a method of commands.Cog you override
I heard somewhere that the 2.0 minimum version is higher but I might be wrong
Also why do this when you can just os.listdir your cogs folder
setup.py line 82
python_requires='>=3.8.0',```
@slate swan
mhmmm
well idk maybe they havent updated the setup file since they havent released to pypi
Yeah probably
👋
Hi i am making a leveling system and stoing the xp and level into a database. i got this error. how do i fix it?
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\leveling system.py", line 21, in on_message
if message.author.client:
AttributeError: 'Member' object has no attribute 'client'
help
def check(message):
return message.content == f"{password}"
messg = await bot.wait_for('message', check=check, timeout=30)
cntent = int(messg.content)
if cntent != password:
await member.send("**Wrong answer.** Please try again.")
else:
await member.send("**Correct answer.** Access granted.")
idk if its bc its sent in a dm but it doesnt respond and it doesnt show any error
Show code
Just code 10 commands
Yes
Wdym how
I just said that
ohh ok sorry
message.author.client doesnt exist
it's message.author.bot
He knows that
Since the error says that
Yeah i knew it
What's the full code
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\leveling system.py", line 24, in on_message
await cursor.execute("SELECT xp FROM levels WHERE user = ? AND guild = ?", (author.id, guild.id,))
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\cursor.py", line 31, in _execute
return await self._conn._execute(fn, *args, **kwargs)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 129, in _execute
return await future
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\aiosqlite\core.py", line 102, in run
result = function()
sqlite3.OperationalError: no such column: xp```
no
sure, what should it do?
God damn it
sure
Not another spoonfeeder
hmmm what u think bout tuts???
You code your own bot use YouTube to help
show ur db
Do not use youtube
Use the docs
Just look at the docs
^
I do tho wdym?
^
it shows here that u dont
yeah
@bot.event
async def on_member_join(member):
font = ImageFont.truetype("Bigwhale.otf", 100)
img = Image.open("shinobu.png")
y, x = (318, 163)
draw = ImageDraw.Draw(img)
draw.text((y, x), passwords, (255, 255, 255), font=font)
img.save("verifypw.png")
with open("verifypw.png", "rb") as f:
img = File(f)
b = discord.Embed()
b.title = "**VERIFICATION PROCESS!**"
b.description = "please input the numbers presented above to access the rest of the channels in shinobu. You have 30 seconds to answer."
b.colour = 0xa7c997
await member.send(embed=b, file=img)
def check(message):
return message.content == f"{passwords}"
hh = await bot.wait_for('integer', check=check, timeout=30)
att = int(hh.content)
if att != passwords:
await member.send("**Wrong answer.** Please try again.")
else:
await member.send("**Correct answer.** Access granted.")
Do you have member intents on?
yes i do
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
Okay add a print statement inside the event
Mine?
Just to be sure it even triggers
alright
Delete my db?
yeah because it only updates if the table doesnt exist
if u updated that
The fuck is integer
OH yea i was messing around
You should have message for the event inside bot.wait_for
bc it didnt work on 'message'
Does the print statement work
hold on
yes it did
Ok
Bot.wait_for integer?
Should be "message"
^^
oh oki
does it send the first message?
yes it does
Why are you checking if message.content is the password when you're checking later
whats the passwords variable
oh
i just noticed that
you are checking if the message content is == str(passwords)
Just check if the message.author.id is the member.id
And probably channel
Yeah channel too
i see
password1 = f"{random.randint(1, 10)}"
password2 = f"{random.randint(1, 10)}"
password3 = f"{random.randint(1, 10)}"
password4 = f"{random.randint(1, 10)}"
password5 = f"{random.randint(1, 10)}"
password6 = f"{random.randint(1, 10)}"
passwords = password1+password2+password3+password4+password5+password6
Are you saying the password in dms or in a channel?
in dms
Also bruh that's a string
i know
You're making the message content an integer then comparing the password which is a string to it
Weird i cant see it on the sqlite explorer in vs
code
i removed that already
return message.author.id == member.id and message.guild is None
is it?
Show the better, and improved code
Yeah i think so i'm not that used to dms
Since i don't do shit in bot's dms
Ye it looks fine
@bot.event
async def on_member_join(member):
password1 = random.randint(1, 10)
password2 = random.randint(1, 10)
password3 = random.randint(1, 10)
password4 = random.randint(1, 10)
password5 = random.randint(1, 10)
password6 = random.randint(1, 10)
passwords = password1+password2+password3+password4+password5+password6
channel = bot.get_channel(965325309945729094)
font = ImageFont.truetype("Bigwhale.otf", 100)
img = Image.open("shinobu.png")
y, x = (318, 163)
draw = ImageDraw.Draw(img)
draw.text((y, x), f"{passwords}", (255, 255, 255), font=font)
img.save("verifypw.png")
with open("verifypw.png", "rb") as f:
img = File(f)
b = discord.Embed()
b.title = "**VERIFICATION PROCESS!**"
b.description = "please input the numbers presented above to access the rest of the channels in shinobu. You have 30 seconds to answer."
b.colour = 0xa7c997
await member.send(embed=b, file=img)
def check(message):
return message.author.id == member.id and message.guild is None
hh = await bot.wait_for('message', check=check, timeout=30)
att = int(hh.content)
if att != passwords:
await member.send("**Wrong answer.** Please try again.")
else:
await member.send("**Correct answer.** Access granted.")
is this better?
Does it work
There is a thing called for loop, it will make this cleaner
Where do u get API's stored in json format online?
Any one know how to fix this? https://paste.pythondiscord.com/xuvonarono
I'm looking for a meme generating API to be specific
On their website it says:
If you add a column to a table after you have initialized the model, you have to delete the database and initialize the model again.
oh so i have to make a database file again?
What the hell
Man random.randint(100000, 999999) exists like wtf
By summarising those 6 "password" vars you will just get a number from 6 to 600
Cause they're int and not strings
Excuse me what
What website
oh
well i clearly didnt think of that thank you ig
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\leveling system.py", line 31, in on_message
await bot.commit()
AttributeError: 'Bot' object has no attribute 'commit'
I need help fixing this
You can't update the table by just "CREATE TABLE IF NOT EXISTS" (it will just leave the table the same) you need to actually add a column to there with ALTER TABLE some_table ADD COLUMN column_name INT (or any other type)
Seems like you were using old version of your own table
You call commit method on connection object not on the bot
Well am getting this from a YouTube video
That was just posted
Just recently
Can you help me with that?
@vale wing plz
Well I would implement a sort of database version control system
I will tell you about it more when I get home
In like 30 mins ok
anyone know how to combine 2 view class and send in one msg?
No it is not
I'm looking for some API's stored in json format, where do I get them online?
Well I deleted what I’ve written any way
that's just bad
@jade tartan have a look at that
You could basically iterate through classes children and add them into new one I think
Eh well sorry I don't really know
You typically google them
I did that, I got some suggestions from random API
but I'm looking for API's like this: https://zenquotes.io/api/random
example pls??
Can someone help me with this?
define mins
new_view = disnake.ui.View()
for v in (view1, view2):
for child in v.children:
new_view.add_item(child)```
I never tried but this is what I am guessing
So?
can u give me some API sites which don't require an API key?
nvm I got it
Until discord dies
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git version
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
saying this but i have git installed?
you are using a variable that doesn't exists, you haven't declared mins no where
install git in ur path
hi I havent coded for like 2 months now and just got back to it and I see I have this error in one of my projects of 2 arguments missing but but I look at the code I see those exact arguments are right there.
Its probably something small and dumb that I cant see
when making a command how can I put a space in the command name? for example !help animations
make a command group
wdym
how does that work?
you can add a subcommand of the actual command
^^^
There was a way to execute a command without invoking it? I remember something like execute_command or command.execute was i drunk or something?
@bot.group(pass_context=True)
async def help(self, ctx):
pass
@help.group(pass_context=True)
async def animations(self, ctx):
pass
oh k ty
!d discord.ext.commands.Command.execute
No documentation found for the requested symbol.
@commands.command()
async def kill(self, ctx: commands.Context, member: disnake.Member):
embed = disnake.Embed(
title="BAM!", description=f"{ctx.author.mention} {random.choice(death_links)} {member.mention}", color=ORANGE
)
embed.set_image(url=random.choice(death_options))
await ctx.channel.send(embed=embed)
!d discord.ext.commands.Context.invoke *
await invoke(command, /, *args, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Calls a command with the arguments given.
This is useful if you want to just call the callback that a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally.
Note
This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function.
You must take care in passing the proper arguments when using this function...
so basically app commands and normal commands under the same decorator / class?
Great xD
Mhm
it needs a context tho
Bro i'm struggling on spelling help
uhm, could find a use of it anyway
!d discord.ext.commands.Message.get_contexy
pass_context is old
No documentation found for the requested symbol.
!d discord.ext.commands.Bot.get_context
await get_context(origin, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message or interaction.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
Note
In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
Can't spell depecrated
Command.invoke can also be used , its just not documented
Help
But it still needs a context
Depreciated
interesting
time to read the source code then
Deprecated
help someone ;/
seems that the use of Command.invoke is a little bit different
it is used to remove group command from the command you want to invoke
cmd = bot.get_command()
await cmd(ctx, ...) # ... = the commands arguments
``` or `await cmd.invoke(ctx)` as hunter said
deprecated
I have spelt it correctly
Back to struggline how to parse images from a api
*cmd.callback(ctx, ...)
Wdym wrong?
depecrated
I'm talking about this one@boreal ravine
as i said, the use of cmd.invoke is different, it execute the command yes but it should be used to remove groups from a command
That's why i said i spelt it correctly
deprecated and depreciated are both correct...
We're talking about the spelling
Doing await cmd(ctx, ...) would also work
It won't
it would
!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.
Wait
Nvm I thought u were calling the class
Lol
My bad. Forgot Command had a call method impl
cmd there would be a Command object, which wont take args like context etc
oh, makes sense
Anyone here who has tried pydroid3 before for developing bots?
@supple thorn pls help
What
@supple thorn do you know how to make the user's profile show how much time he spent in voice channels ?
What?
You can't change a users profile
Only they can
@supple thorn That's not what I mean. And the fact that a person prescribes a command and the command shows how much time he spent in the voice channel
yes
I looked at the documentation but nothing is clear there
just store the time and then fetch it when you wanna use it
don't ping people for help
Have a voice channel event when the user joins store the exact time they joined in a database
I like pings
Well i have about 13727 right now
Just get the data about them when the command gets used
is there a website or a video where they do something similar?
still, it's not appropriate for anybody to ping someone and ask for help
well, at least there was an example
So what do I need to do here?
i don't know
I'd say thats entirely up to CokeCane to decide
for themselves
I'm still surprised my name doesn't break the rules
cocaine doesn't break the rules
I thought it would
probably no
Brad here
We would probably ask you to change your username so it isn't a recreational drug
Since we are a learning server and all
But @supple thorn you are clearly a cane of Coca Cola
hm
Lol 😂
Can any one help me plz
I was thinking "ah fuck here comes my end"
I'm not that bad am I?
You do have to wonder why you'd keep a name if you explicitly thought it breaks the rules 
Just as I noticed by discord.py only one documentation that lags does not load normally. So also without examples
Wonder how long til mods notice it
Lmaoo
Who knows 👀
!u
No you're not bad you're brad
Created: <t:1586551853:R>
Profile: @velvet compass
ID: 698273827448291379
Joined: <t:1622294818:R>
Roles: <@&267629731250176001>, <@&831776746206265384>, <@&787816728474288181>, <@&267630620367257601>, <@&764802720779337729>, <@&463658397560995840>, <@&542431903886606399>
Messages: 27,242
Activity blocks: 6,274
Total: 17
Active: 0
Oh damn, 17 infractions?!
Totally not, yes
!u
You are not allowed to use that command here. Please use the #bot-commands channel instead.
mod abuse ban!!
🗿
there 's more than one example here
Do you like coca cola made with cane sugar Brad
For sure
brb gonna mod abuse you in nextcord 
The top one.. on_voice_state_update

I have a general question, what discord bots do you find the most impressive in terms of features, code style and fun interacting with?
Nice. Haven't had one myself though because i never got coca cola with cane sugar
Always drank the high fructose sugar kind
Self Made Dyno, MEE6 and Carl
Zeppelin the mod bot, it's got an insane amount of features and is very powerful
and it's source available
soon™️ will be EPL-2
I just realize you're vcokltfre
:)
yag/carl cause it has it's own "language"
I was thinking this entire time "damn this goose is good"
Was going through your messages
Lmao
Alrighty so I hope I have the repos correct:
https://github.com/Colean128/mee6
https://github.com/CarlGroth/Carl-Bot
https://github.com/ZeppelinBot/Zeppelin
https://github.com/botlabs-gg/yagpdb
I was about to ask you how are geeses superior to ducks
mee6 doesnt actually have their current code available
it was open once upon a time but not anymore
the original repo was under coookie's account iirc
I always liked playing with dank memer
@velvet compass do you have a bot or at least just a team that counts all the time that the user spent in the voice channel and summarizes it ?
Tried to read it's source code but got sad since it's in js
You just pinged a mod
I though dank memer was java/kotlin
Not that I know of, but I could be wrong
Really? From what i saw before it was in js
nvm it's TS using eris
@velvet compass we would at least just see the part of the code that is responsible for how the bot counts the amount of time in the voice and writes it to a variable
Is that a question or a statement?
Probably a statement
statement
Alrighty. I'm not sure of the implementation details but if you have an idea you could open an issue and see if a core dev thinks it is valuable to add
He wants code for when a member joins a vc and put that exact datetime into a database and fetch that data when a command gets used
Lmao brad
Carl one is correct, but it's outdated
Do you want this for yourself or to add it here?
He not doing a PR for a bot here
He wants it for himself
He's russian so he's using a google translate to answer
for myself
So it sounds kinda weird
well, you can also add here so that if suddenly someone like me comes here, he could explain it simply by sending a screenshot of what he wants
I'm not great with discord bots, but I would imagine a timer function would work. Just start the timer when a user's ctx.member.voice changes to True, and end the timer when it is False. Then take the difference and add it to some sort of database entry for the user's time in voice chat
A better way is to just use datetime.utcnow() and just take the difference between now and the old now
Right, that would be the timer function
That is essentially what it would be though. A timer that starts and ends when a user joins and leaves voice chat, then adds that value to a database entry to track the time spent in VC
thanks for the help. But it's useless to explain in words because until you start the code, everything is clear, but as soon as you started. It is no longer clear what and how
That is part of learning though. Taking "pseudo code" that is written out in plain language and changing it into code written in a specific programming language
Do discord.py powers / commands?
@livid hinge
голосовой онлайн - voice online
226h 24m
what ?
yeah, dpy 2 (master branch) does
am I too weird who never does that or nobody does
i do it
I usually don't need to write it out, but sometimes it helps to sketch out an outline, then fill in the details with real code
i mainly do it to keep a vision on what i want
:) okimii, afternoon
hm understandable
good morning (my time)
same thing
its 8am and im tired already
😔
sleep
im in school
so i cant😔
shut yourself up in the locker, easy
we dont have lockers......
sad
😔
then you know where to go
😳
@maiden fable help
With
Lmao
tysm
hm
How can I remove a reaction inside a on_raw_reaction_add function?
guys anyone got a clue as to what docs i gotta refer to when i want my bot to do smth like this(i made help command for it to make it easier for people to understand):
basically wanna do like
.get IT w21
it then retrieves the IT November 2021 pastpaper
you didn't return somewhere
and how to fix it ? how do I stop the action of the command ?
How can I remove a users reaction inside a on_raw_reaction_add function with discord.py?
get the message_id and remove reactions?
await message.remove_reaction(payload.emoji, payload.member)
This worked! I did some other over complicated code but this worked just fine, thank you!
hello
Welcome!
Can anyone give me tempban command
I am not gonna give you a whole command
reason ?
You would not be learning anything.
@Bot.command()
async def tempban(ctx: commands.Context):
...
welcome
Okay give me half the code
Use a database to store unban times and tasks.loop() to periodically check if there are users to unban
🤣
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
Why don't you try and make one, then we will help you.
If I could create something, do you think I would be on this server?
why dont you "learn" to create that something, huh?
I do not know as much as you do
then "learn"
why not..
is there anyway i can make a "only you can see this message" message?
example:
you gotta use views (buttons, slash commands etc..)
yes ofcourse, its called an ephemeral response which can be created only with an interaction like button click/ component usage / slash commands or any other user commands
and set it to ephemeral = True
You will not find anything for free, I do not want to waste money on python language
If I spelled it wrong apologies
......?
ephemeral*
There are many sites where you can see codes
!resources
whaaaaaaaaaaaaaaaaat
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
there are many good "free" resources for learning python
Why do I have to use buttons and slash commands to use it?
that response can only created with an interaction, there's no reason for that, thats how discord works
Can I use it with a reaction?
alternatively, if you want only 1 user to see the message, dms exist
Nope, not a reaction
can someone give me an example of a custom check in events?
if i want automod to be disabled, the event should be disabled guild wide, so how would that look like
.
Not easy to use
I cant understand
what do you not understand? your own difficulty level or the type of resource you want?
Type of resource
VSC > Atom
just press the one of the courses
Ok
Tbh i cant even find how tf i print stuff
the print function?
Ye
!e print("Hello World!")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
Hello World!
Bruh
I know python
Im talking as an begginer
ah
That is new to python
its just a tree full of courses it depends on the courses
!d
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix=get_prefix, case_insensitive=True, owner_id=id, intents = intents)```
?
this code doesn't work for some reason
specify "doesnt work" and no need to add your id in the owner_id
^^^
why-
..
Hi ash and hunter
Well, for some reason bot.owner_id returns None everytime, in my bot. So it's good being on the safe side
Hi
Ur status , exams?
Nah, school and other shit
only reason why you should have it is for a list of owner ids
Ohh
!d discord.ext.commands.Bot.owner_ids exists for that
The user IDs that owns the bot. This is similar to owner_id. If this is not set and the application is team based, then it is fetched automatically using application_info(). For performance reasons it is recommended to use a set for the collection. You cannot set both owner_id and owner_ids.
New in version 1.3.
U know what :( today in my school a vaccination camp was there
even less reasons
I already got the two vaccines
Hola Sparky
It was my 1
And it pains now where the 💉 hit
did you scream?
No.
welp
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
your point?
wish I could explain
Who likes to scream in front of friends and classmates
cool
anyone?
Why this chat is ded ;-;
sad
you cant have custom checks in an event as in commands
you need to make your own decorators or if statements inside the event for that
DM?
Yo
yo
Prolly a heroku issue. There was a data breach a few days back and a few GitHub (Heroku issued) keys were stolen
Prolly
and what can I do?
sir
?
sorry for ping...
Idrk, never really used Heroku sorry
what can i do about my stream key
Just put simple if condition
if message.channel.type == discord.ChannelType.private:
return```
Eg
cool
?
well i'm disnake side so 
Disnake good
but uhh
#discord-bots message
I wrote ai antispam bot with disnake
He basically said the same but + decorators
Decorators are possible as well ofc
Hey guys. I'm a newb in python and I'm currently undertaking a course on udemy.
But i want to start early with my own project.
I have searched around to see the source code for a discord bot that message when NFT's are listed
any idea where can I find one?
disnake is pretty cool 
can i make my bot change its pfp every so often?
anay wy to make an eval command?
i tried most things like eval() and exec but the return error like unexpeced in non quoted string
or smthing
Can you show your code?
define your "every so often"
every so many minutes
well, just like normal user avatar update, that has ratelimits too if im not wrong
ok
i mean, you can use snekbox
@bot.commands()
async def ev(ctx,*, msg):
await ctx.send(exec(msg))```
never used it myself tho
whats that
You can use the discord.ext.tasks extension to create a loop like so:
from discord.ext import tasks
@tasks.loop(minutes=10)
async def change_avatar():
await client.user.edit(avatar=...)
change_avatar.start()
!e
code
!eval <code>
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
hmmm
and its source code is too complex lol
Use eval(), not exec().
??
compile() does what?
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=- 1)```
Compile the *source* into a code or AST object. Code objects can be executed by [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") or [`eval()`](https://docs.python.org/3/library/functions.html#eval "eval"). *source* can either be a normal string, a byte string, or an AST object. Refer to the [`ast`](https://docs.python.org/3/library/ast.html#module-ast "ast: Abstract Syntax Tree classes and manipulation.") module documentation for information on how to work with AST objects.
The *filename* argument should give the file from which the code was read; pass some recognizable value if it wasn’t read from a file (`'<string>'` is commonly used).
@bot.command()
async def ev(ctx,*, msg):
await ctx.send(eval(msg))```
ooh okay
stil doesnt work
What happen
im trying to make an eval command
Oh.
but it doesnt work
Error?
is it meant to be a public eval command?
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
of course not
Show how u type the command
@bot.command()
async def ev(ctx,*, msg):
await ctx.send(eval(msg))```
if you dont want to go thru the pain of making an eval command just use jishaku
I mean how u did the command
looking at a module like jishaku may be a good idea then
though its recommended to make one by your own
i did but i cant find the code for the actual command
Why?
Nvmd
raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "msg".
you are aware how that works, and you can have your own scopes along with it
for something with such potential for remote code execution by others and the ability to cause such damage, unless your intent is to learn how eval commands work I don't think making your own is a great idea
I've seen so many bots where people made their own eval commands which are broken in some way that allows for malicious use, so unless you have a good reason for doing it yourself there isn't really a point
well @commands.is_owner() is always an option
Show what u type in dc in msg arg
print("hi")
https://github.com/Rapptz/RoboDanny/blob/rewrite/cogs/admin.py#L220-#L265
Here's an example of an eval command.
For your own good, don't just copy the code, you will go nowhere.
timtoy
But knowing how dpy users are, people will copy it.
bro no cat pfp😔
I'm sad, my pfp is reflecting that
i see that😔
Or I guess, the lack thereof
H?
Do you want me to break it down? I can do so for you if you find it hard to understand
That's what I typed
What u want
To print the executed command
So in this case it should send hi
?
Stop referring to code or functions as commands lol
You're disregarding common terminology
No I mean just generic code
yeah
This shouldn't be referred to as a command.
i think add_command is to bound a function to the bot right?
They're not talking about dpy commands
ik im just wondering
should i use cogs in main file?
Generally no, it's a good idea to have a multi-file structure for your bot
Cogs are used to split up application logic and organize stuff.
cogs are just extension/containers that have listeners and commands
You can pair them with the "extensions" feature that dpy provides, where you can load/unload/hot reload python modules at runtime
i just want to organize the stuff in my main file
Well, what's the error?
what
the other extensions are other things
... What
Just use multiple files 🤷♂️
that just makes more messy classes in a file
^
plus why make cogs in the main file?
"This doesn't work so what should I do?" Doesn't work. If you can't debug it, at least provide us with info to debug it for you.
categories?
maybe i can uh separate the main commands and extensions commands
Those comments aren't needed
cause it doesn't
Bet saying that makes you feel real mature
I'm out
@slate swan you've already been warned about being rude. Let this be the last warning you need.
so im tryin to make a command and have the bot react to its own message, and when the user reacts with the same emoji it deletes the message. everything works fine except it wont delete the message. theres no error either, pls help me w this, heres code:
@bot.command()
async def test(ctx):
msg = await ctx.send("React below to delete this message.")
icon = await msg.add_reaction("❌")
def check(m):
return m.reaction == icon and m.message == msg
await bot.wait_for("reaction", check=check)
await msg.delete
delete is a function not an attribute
!e ```py
print(import("datetime").datetime.now().timestamp())
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
1650387313.052786
<t:1650387313:R>
<t:1650387313:R>
bot.delete_message(msg) ?
<t:1650387313:F>
await msg.delete()
There must be more formats?
still no work
Ty
I gotta eat rn
oki, dm me when done
You pass an intents object not a bool
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
hi
intents = discord.Intents().all()
client = commands.Bot(command_prefix=get_prefix, case_insensitive=True, owner_id=862374422749249556, intents=intents)```
is it okay now
nvm i got it fixed
channel = self.client.get_channel(id)
await channel.send(embed=embed)```
Yeah you can also just do discord.Intents.all()
channel = self.client.get_channel(id) or await self.client.fetch_channel(id)
await channel.send(embed=embed)
this still doesnt work
Do you got an error?
nope
Have u got ctx?
that would delete the users message tho right?
await ctx.message.delete()
You want to delete bot msg?
yeah
Hang on I almost got it
delete_after=int
So you have ctx.send
In that add delete_after=6 or some number
but i dont want it to delete after a specific amount of time i want it to delete after the reaction is added
@bot.command()
async def test(ctx):
msg = await ctx.send("React below to delete this message.")
icon = await msg.add_reaction("❌")
def check(m):
return m.reaction == icon and m.message == msg
await bot.wait_for("reaction", check=check)
await msg.delete()
it still doesn't work
U gotta do that in a while true loop
Did you pass a valid id?
explain
TypeError: coroutine.send() takes no keyword arguments
Otherwise it will look for it that instance. See the reaction isn't there
yeep
It will check for the reaction as soon as the command triggers
Does the bot have access to that channel?
It won't keep checking it untill reactions is added
but if i have it wait for a message it works fine
yea
Idk then
Then you'll need to provide more info in how that can be None.
RuntimeWarning: coroutine 'Client.fetch_channel' was never awaited
await self.on_error(event_name, *args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
You need to await the fetch.
so im working on a help command but i want to make the page argument optional, i thought i knew how this worked but its not working. heres my code:
@bot.command()
async def help(ctx, page=Optional):
if page == "mod":
await ctx.send("'''yaml\nModeration Commands:\n\n+warn [user] [reason]\n\n+kick [user] [reason]\n\n+ban [user] [reason]\n\n+purge [number]''')
if page == "util":
await ctx.send('''yaml\nUtility Commands:'''")
if page == "fun":
await ctx.send('''yaml\nFun Commands:'''")
if page == None:
await ctx.send("Please format the command like this:\n\nc:help [specify **mod**, **util**, or **fun**]")
no error
You shouldn’t be making help commands that way
Rather you should subclass help command for more customizability
pls explain
cogs?
@sick birch
hello?
@commands.Cog.listener()
async def on_member_remove(self, member):
channel = await self.client.fetch_channel(964209152798904343)
embed = discord.Embed(description='Goodbye from all of us..', color=random.choice(self.client.colors))
embed.set_thumbnail(url=member.avatar_url)
embed.set_author(name=member.name, icon_url=member.avatar_url)
embed.set_footer(text=member.guild, icon_url=member.guild.icon_url)
embed.timestamp = datetime.datetime.utcnow()
await channel.send(embed=embed)```
is it correct
Do you guys have any idea for a anti nuke system
ban the member who says snipe?
I want to make a rate limit where if you kick/ban too many people in a certain amount of ttime
you get your role removed
But I have no idea where to start
also nvm about this i was using the wrong bot prefix XD
want something complex?
Yeah I could definitely use some ideas
Is it possible to get the message.id directly from a " await channel.send() " function?
How do i make this with a member and not a role?
await channel.set_permissions(guild.get_role(961982510340923484), send_messages=True, read_messages=True)
- Check if a Member joined a Server
- Check if the Member is a Bot Account
- Get the Role object of a role with specific permissions that would qualify as a mod/staff role
- Ask for confirmation from Two or more Members with the required Role for letting the bot access all the Channels in the Server. Else Kick it
I just want to make where if a Moderator kicks/bans 10 people within a minute they lose their mod role
hey, which hosting do you guys use for discord bots?
use a task?
Maybe, I just do not know how to make one
Pebble Host
the first one doesnt even make sense
😭
First thing yeah do as Robin said but if you would ever like to typehint something with Optional don't try to set it as default value but as typehint
def func(arg=Optional) # wrong way
def func(arg: Optional[int]) # correct way, replace int with required type```
you could make a dictionary
bot.bans = {}
@event
async def on_member_remove(member):
"check if the member was banned and if then by whom and make a key in the dictionary (bot.bans) if it already doesnt exist else update it"
@ext.tasks.loop(seconds=5)
async def _t():
"iterate through bot.bans and check if a value of a key is > 10 and do the *stuff*"
'''Create another task for cleaning the dictionary'''```
hey yo i have a question
can someone come in a vc and teach me evrething about creating dicord bot with pyton?
There is docs for that
Personally I can't and I doubt anybody would
You can check this tutorial https://vcokltfre.dev
A tutorial to help you make better Discord bots.
but im iranian my us lunguge is not really good for reading docs
Well knowing english will help you a lot in programming
nvm ill try my best
I am not native english speaker either tho
use google translate on the webpage itself
most languages use english keywords so you need to know a bit of english
happy sql noises
i have a question ???
https://vcokltfre.dev/ in this link it teach about welcoming users or giving auto roles?
A tutorial to help you make better Discord bots.
I think it teaches about events
😐
And you can find events in events reference in docs or ask us
i wouldnt recommend that tutorial anymore
you made a new one?
no vco is developing one
can someone give me a link so i can make a bot like mee6 or probot ??
but thats a good idea ash 😳
xD
theres no such thing
Isn't it made by him as well
yes, that one isnt being maintaned anymore
Eh well you can try searching through github 😉
and iirc that tutorial is in 1.7.3
you wont find code for mee6 lmao
it uses a custom wrapper
mee69
bro
soo its not that easy , i was think its easy pz
not at all
intent = discord.Intents(members=True)
client = commands.Bot(command_prefix=get_prefix, case_insensitive=True, owner_id=862374422749249556, intent=intent)```
it is easy if you know what you are doing
discord.py is an advance lib which you need to know what youre doing
Clearly best bot
commands stop working when i use intents
you use replit site ???
sheesh
Wondering how did he write it with html
since when does intents take arguments?
No, I use VSC for development
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
New in version 1.5...
wait yeah you can
its okay, my school taught us to make a video conferencing app with pure htm, a bot isnt a big deal :)
i doubt it would break for passing kwargs into its params
bruh
😳
Anyways gonna go learn docker volumes cya
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
CSS is all about finding out the attributes and what they do
i thought you changed domains😔
that said, the actual domain is tutorial.vcokltfre.dev, vcokltfre.dev wont redirect forever
22
bro
must be expensive
how much do you pay for all of them like 100 dollars a month?
nah it equals out to something like $20/mo
namecheap?
because they're yearly but half of them are short-lived shitposts I don't renew
$240/- a year 👀
mhm
it costs a hell of a lot less each year to do the domains than I spend ice skating
cloudflare pages
nice
its all free
noice
some stuff uses my server but I need my server anyway
that's a little more expensive lol
vco
make an api that distributes goose pictures
or an http status goose api
why does my bot not work when i put it in pycharm
did you define it?
Define "not work"
can someone giv eme python creating discord bot doc link?
Like library docs or a tutorial?
just read the discord develoepr documentation to make an app and then just check your libs docs
tutorial
wym
Uh you could try https://tutorial.vcokltfre.dev
A tutorial to help you make better Discord bots.
at first i have to type import discord?
dude what this link is
i know how to create bots
how i can code it with python
??
i never cant make discord bots 
if you are using discord.py and not an extension
im using replit.com
yeah
but are you using discord.py?
up next to the repl name does it say just python?
You should learn how to code before starting on a bot
@warm tulip can u send me fr so we can dm
dm me so i send screen photo
send friend request first
i cant until u do that
i adedd u
@warm tulip learn the basics of programming first (if don't know already )
I need to make a loop to go through the roles of the server, and remove them all then give the Visitor role, But I do not know how to add a loop in an event
I do not know how to add a loop in an event
What loop, pls say bit clearly python loop or event loop (bot.loop)
also you need not to do .key()
An event loop to pull all the server roles,
Then is the user is kicking/banning 10 members within 60 members it will remove all of its roles and give it the visitor role
!d discord.Guild.roles
property roles```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of the guild’s roles in hierarchy order.
The first element of this list will be the lowest role in the hierarchy.
it returns a list just iterate through it
Okay, then how I would loop that
what
This
it returns a list? which a list is an iterable?
ah its for a member
!d discord.Member.roles
property roles```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.
These roles are sorted by their position in the role hierarchy.
this is the right property
im using discord-py-interactions how would i set someone's nickname
what is the IDE you use ?
VS Code
oh ok that’s only the theme i didn’t know
wdym by withing 60 members?
No
That is the seconds count
from config import TOKEN
My bad I misunderstood your question
For what reason you need config ?
yeah but what the command you want to code ?
hello
There are no good free hosts
Oracle has an excellent free tier however
depends on whether you have morals
oracle isn't exactly known for being an ethical company
I got a website to host a bot for free. Mine is working now
ive got him, ill start explainging things from the ground up to him bcs i know what its like to be in his place, as i started like that too so yeah, dont worry ive got it
Yes there is
You just have to keep your token safe
It’s free bro
you just need replit and the website
idk
replit is not a host~
Totally agree
- uptimebot (the website)
If you are only planning to have the bot in 1 or 2 guilds Heroku us prob the best option since you don't need a credit card for that. As for repl.it I don't recommend using that since then you also share your IP.
thats not a host either, it just pings your repl at interval of some time
Have you considered that needing to ping a website all the time with an uptime checker doesn't make something a good host perhaps
A website which is, i might add, not a bot obviously
Bruh my bot is working 24/7 now
which you can do yourself by opening the repl in every 30 seconds or a minute
absolutely not
you creat a code to keep alive your bot
No you can
thats a fact
then you run it
Everything regarding hosting please go to the dedicated thread.
I wonder sometimes how many of uptimerobot's checked sites are Discord bots on Replit

