#discord-bots
1 messages · Page 916 of 1
lol
I coded last night while totally drunk and while I don't understand the code I wrote at all it works twice as well as the code it replaces and is fewer lines 
LMAOOOO
motivational 😔
oh yeah side note, don't try to explain TCP/IP to your drunk friends while you are also drunk
we have kids here 
Pov: I don't have friends/People around me ain't as nerdy as me
your point...?
nvm
at least you have friends
Says who 👀
the mutual friends tab on discord
your preference
😔
welp
pretty much whatever except vim because vim will just confuse you
Vim uwu though 😔
uwu
now you can run the pip command again
and hopefully it should work
Hmmm, this may help https://www.answerlookup.com/how-add-git-windows-path-environment-variable
Steps to set Windows PATH Environment Variables for GIT
😔 Adding to PATH sucks
if it doesn't I'm not sure, I have git installed by default on my distro and I dont use windows
ajb, stop using linux and go to a doctor
but without linux how will I have such pretty terminals and not have to deal with windows bs
Use Mac!
I'll be dead before I willingly overpay apple for a computer 
the 75% profit margin I'd be paying apple is much better spent on servers 
😔 use ChromeOS
chromeOs uses linux kernel..
pls help me, i cant do 2+ word from file forbidden
i mean forbidden check event
only work when i put one word in that file
um wait
@slate swan
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
How to enable nextcord slash command perm?
I use @commands.has_permissions but it didn't work on slash command
for me it triggers sometimes...
how do you know that it's getting triggered without a message being edited
Some kind of ID check ?
idk the bot sends msg as edited in logs channel
I can send the code for it
Does it send the message which were not edited too?
Can someone help?
PizzaHat/cogs_hidden/events.py line 45
async def on_message_edit(self, before, after):```
Wdym by enable slash command perm? Adding checks etc?
yes sometimes
not always
That triggers even when attachments/embeds are removed from the message
discord.gg/dpy thanks
So maybe check that
why would it not
nope
so what should I do... I'm working on check to ignore bots
other than that what else?
you are trying to log only edited content right?@dense swallow
yup
how do i install a pip?
with python, add it as path
you can just return it after.content == before.content
Windows?
so if after.content == before.content: return?
Yea that would do the job
yes
oh alright thanks
tick on "add to path" while installing python
it's on the bottom of the installer
Or add python to your system environment variable manually
2 boxes I think
u have to reinstall it
i can't find it
so how do i install a pip
python will install pip now, click on next and continue with your install
What to fix
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
Even if I unindent it,it doesnt work
Use Nextcord or dpy(personally I prefer dpy)
you already reply pinged me 
Ok dude
how to fix this
Traceback (most recent call last):
Traceback (most recent call last):
File "main.py", line 12, in <module>
client.remove_command(name="help")
TypeError: remove_command() got some positional-only arguments passed as keyword arguments: 'name'```
?
remove_command(name)
@drowsy thunder
Not remove_command(name=name)
ok
bruh
i am unable to create a custom help command
@maiden fable
"Not remove_command(name=name)"
Read what hunter said
You could also just passhelp_command=None to your bot's constructor
remove_command is not your bot's constructor
remove_command vs. help_command=None in your bot constructor is pretty much a micro optimisation although
sir i m new to discord py
discord.py doesn't have anything to do with python classes being created
Actually not sure, cause remove_command will have to handle aliases and what not
It's still better to just pass help_command as None
same error with this code
Again not your bot's constructor
That should be inside the constructor
!e ```py
class Foo:
def init(self, arg: str) -> None:
self.arg = arg
Foo("bar") # constructor!
@pliant gulch :warning: Your eval job has completed with return code 0.
[No output]
umm
ok
Yes?
can u help me to fix this
Guys,how to check if a message has walls of text and repeated text?
May I have a look by gettong the repl link in dms?
okh wait
@vocal plover can ya tell how to check walls of text and repeated text?
how to disconnect an bot from a voice channel?
await voice_bot.disconnect() doesn't work
voice_bot = voice_bot_in(server)
server = message.server
!d discord.Member.move_to
await move_to(channel, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Moves a member to a new voice channel (they must be connected first).
You must have the [`move_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.move_members "discord.Permissions.move_members") permission to use this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.edit "discord.Member.edit").
Changed in version 1.1: Can now pass `None` to kick a member from voice.
but I want fully disconnect the bot
read the last line in the embed?
invalid syntax
show code
await move_to(channel, VoiceChannel, reason=None)```
btw new error: move_to is not definied
how to send messages such that they are only visible to the author
client.remove_command(“help”)
those are called ephemeral messages, and they're only possible as responses to interactions like slash commands or message components (buttons)
leeme try
and what ya meant with guild.me?
Guys
property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
ok thx
He is reported to python modmail
message/context.guild.me
thanks and can you also send a full example to the disconnect code? I don't get it
InvalidArgument: activity must derive from BaseActivity.
@bot.command()
@commands.is_owner()
async def status(ctx, *, arg=None):
if arg == None:
await ctx.reply("Where status?")
return
await bot.change_presence(status=nextcord.Status.do_not_disturb, activity=arg)
How to make the bot add reaction to the response
??
@slate swan
you need to pass an Activity subclass to the function, e.g. discord.Game or discord.Streaming
if u are using embed do
embed.add_reaction("🚓")
??
Not embed and,its in Nextcord
those activities have a name parameter that you can write your message in
e.g. ```py
activity = discord.Game('with chocolate')
Shows up as: Playing with chocolate```
Its not like that
then ig
ctx.add_reaction("🚍")
nnonono
yeah spmething like that
I am using msg
show code
wdym its not like that, thats exactly what the change_presence() method expects as an argument
!d discord.Client.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter...
needs to be a discord.Game/ discord.Activity
like this shouldwont help though
there is
this
Where?
arg is a string
It's a str
you cant literally pass arg as the activity, it needs to be wrapped in an activity class first
hmm
even this has an example of how to use it
i dont understand anything
learn argument and annotations then
XD
The activity accepts a discord.Activity
hmm n
if a member has not send a message or reacted to a reaction in x days he wil be given a role. how can i make that?
would this work ?
@bot.command()
@commands.is_owner()
async def status(ctx, *, arg=None):
if arg == None:
await ctx.reply("Where status?")
return
await bot.change_presence(status=nextcord.Status.do_not_disturb, activity=nextcord.Activity(f"{arg}"))
```????
imma test
why the f-string?
for arg?
yeah, its already a string
oh ok
also you havent given the activity any type you want it to be
??
is it playing? competing? streaming?
oh ok
e.g. py discord.Activity(type=discord.ActivityType.watching, name='over you')
?
What is the use of discord.Widget? I mean what is a widget?
something like this embedded on a website
will this work?
@bot.command()
@commands.is_owner()
async def status(ctx, *, arg=None):
if arg == None:
await ctx.reply("Where status?")
return
await bot.change_presence(status=nextcord.Status.do_not_disturb, activity=nextcord.Activity(type=discord.ActivityType.watching, name= arg))
Thanks 😊
What is that?
Command "userinfo" is not found
Code:
@client.command
async def userinfo(ctx, user: discord.Member=None):
embed = discord.Embed(title="User information")
embed.set_thumbnail(url= user.avatar_url)
embed.set_footer(text="Requested by {ctx.author}",icon_url=ctx.author.avatar_url)
embed.add_field(name="Nickname:",value=user.display_name,inline=False)
embed.add_field(name="Id:",value=user.id,inline=False)
embed.add_field(name="Owner",value=user.is_owner,inline=False)
embed.add_field(name="Joined to server at:",value=user.joined_at,inline=False)
await ctx.send(embed=embed)
Obvious
@client.command must have brackets
Also how do you define client
And yeah
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Thank you
client = Thank you nice
Why {ctx.author} not work?
How to check if the author is a bot or not?
@viscid relic what is your python knowledge level
!d discord.User.bot
Specifies if the user is a bot account.
Beginner
Thank you
ouch, you shouldn't start python using discord.py
You should learn a bit more before getting to making discord bots
At least learn the basics of OOP
Probably
Ok
We all know this
object oriented programming is a very important concept for discord.py since there's a lot of objects and classes it uses (just look at the docs)
i would suggest knowing the difference between the two and instance attributes/methods vs class attributes/methods, that way you can avoid writing mistakes like discord.Member.name which tend to pop up in the help channels
if you want some resources you can type !resources in #bot-commands and search for OOP, there's a youtube playlist by corey schafer that covers them well
I and other regular members of this channel usually suggest python beginners to learn more python before getting to making discord bots, because at this point most of them just copy code and understand nothing
Not discouraging them or anything
Well I mentioned the concrete topic but anyways thanks for telling me about this I will be aware of myself
i agree tbh
that isn't the only point of view though, thats the thing
there are 2 ways that a new programmer can get discouraged:
- people telling them to go learn the language before tackling a hard project
- the beginner doing the hard project and not being able to do anything so they get discouraged and quit
its kind of a double edged sword
how do i not spam console and just print whole list instead of spam
you are printing the list each time after it gets appended to. if you want to print it after all the appending, take the print statement outside the loop
lmao
where did you put it
outside the for loop?
show the code
oh
wonder if a list comp would do anything here
ye
don't think that and would help
but doesn't Python make them into bools?
oh
im thinking of Rust where both sides must be a boolean since the compiler doesn't coerce them
if statement must be boolean. if foo doesn't work
error[E0308]: mismatched types
--> src/main.rs:4:8
|
4 | if number {
| ^^^^^^ expected `bool`, found integer
For more information about this error, try `rustc --expla
More things to speed it up
i believe this would make a list of references to the same embed actually, since and would return the last operand if all were true
Rust?
ye
I am trying to add this information to the .json in this way:
but it is being added like this:
code:
import json
dictionary = {
"5622987331403947": {
"username": "Arcanjo'#5288",
"registered": "18/03/22"
}
}
json_object = json.dumps(dictionary, indent = 4)
with open("inventory.json", "a") as outfile:
outfile.write(json_object)
can someone help me?
with .json files, you need to read and write the entire file at once, appending cant be done
One of the reasons it’s not suitable as a database
you should consider storing user ids instead of their names fetching their username as needed (since they can change) and also using a database, for example SQLite (with asqlite or aiosqlite)
Even changing something small requires you to rewrite the entire file
I was trying to use sql, but my windows locale is not showing up as an option :c
but the sql server is not showing up as runningonly this SQL Server VSS Writer appears
do you know how to solve this error/bug?
during the installation no errors occurred
dunno what to suggest for that besides a google search (maybe this would help? https://docs.microsoft.com/en-us/sql/sql-server/install/local-language-versions-in-sql-server)
but if you're interested in using an alternative database for discord bots, you can look into PostgreSQL (another client-server db) or SQLite as i mentioned before (single-file db)
ok, I'll see if I can fix it here, thanks for the help
@native onyx answer is linux ftw
linux is best OS for servers
headless n u only waste ram cpu on wat u need
sad, I had kali linux installed on virtual box
kali linux is pentesting distro tho
i know
but a lightweight installed debian or arch
ubuntu has alot preinstalled shit u dont need for q server
all u need is nothing n install sshd
n screen
so which one do you recommend
then use like putty
to connect to server
i recommend buy vps for 5$
instqll debian
selfhosting is whqck
The actual contents of the message.
@native onyx what kind of bot u gonna run?
:) how to make slash command
Guys im trying to run my bot on heroku but every time i run it it says my python is not configured for tkninter when i never even imported it
depends on your lib
discord py
main?
y e s
check its examples on github
link :)?
i mean slash
@native onyx i can maybe let u get an acc to my server to host urs but wanna kno what kind of bot u gonna run
press example folder and press slash commands
oh ok :v
@bot.command(name = 'order')
async def order(ctx: commands.Context, *, echo: str = "oops! make sure you say something! EX: !order [example]") -> None:
msg = await ctx.send(echo)
await msg.add_reaction(":thumbsup:")
await msg.add_reaction(":thumbsdown:")
channel = message.channel
await channel.send('You have 60 seconds to confirm! Press [placheolder thumbsup] to confirm! press [placeholder thumbsdown] to try again!')
def check(reaction, user):
return user == message.author and str(reaction.emoji) == ':thumbsup:'
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await channel.send('Gotcha! order confirmed')
else:
await channel.send(':thumbsup:')
i cant seem to add the kwarg message and get it to work, depending on where i put it smthn diffrent happens every time. pls help
wait nvm main still doesnt have examples so good look reading src
:vv wut

which one-
is a bot with rpg features
bro the discord one aka the one with all the src code in it
i guenenly have no idea why this is happening
and which one i should clic :V
why is your default a message meant to be sent in discord @supple crescent
sorry?
async def order(ctx: commands.Context, *, echo: str = "oops! make sure you say something! EX: !order [example]") -> None:
echo arg
i followed a tutroial and thats what they put tbh
bro don't copy tutorials
dont be like binds 
👍
👍

anyaway, i keep the msg there bc when i try to alter it or remove it altogether, it stops repeating what i say
I want to add some text to my bots status.
I know i can use
await client.change_presence(activity=discord.Game(name="test"))
But I want to display more information's when you click on the Bot. Like an Server Link etc.
Like here.
omg
https://python.plainenglish.io/how-to-change-discord-bot-status-with-discord-py-39219c8fceea
you could do smthn like "playing: [server link]
Personalizing your Python Discord bot’s status for your server with discord.py
np
orrr @uncut zephyr you could make it the about me
wait nvm ur already using the abt me
Yeah exactly. I thought it would be the same. Just found out I want to change the "about me" 🤦♂️
no I am not, am I?🤔
i dont read german but what is uber mich?
Haha sorry, yeah its "about me"
ah alr, good luck!
Thanks :)
I have a button and with the press of button I just create a channel so the button shows interaction failed what should I do abt that? Is there any way to supress it as I only want to create button and dont wish to send back any message in channel on interaction
what library?
You could send back an ephemeral message
!d discord.InteractionResponse.defer
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
just use this.
Umm Ig you mean what @slate swan suggested
Aye but I heard it creates problem, does it?
no
Aye ill add it then!!Thansk a lot @slate swan @torn sail
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
https://paste.pythondiscord.com/guzifukela I am trying to create slash commands. No errors showed up but the slash commands did not show up on the servers the bot was in. I even re added the bot with applications.commands. Intents were also added
try adding the test_guilds kwarg to the deco since if not specified, it takes approx. 60 mins to register them to all servers
@bot.command(name = 'order')
async def order(ctx: commands.Context, *, echo: str) -> None:
msg = await ctx.send(echo)
await msg.add_reaction(":thumbsup:")
await msg.add_reaction(":thumbsdown:")
await ctx.message.delete()
channel = message.channel
await channel.send('You have 60 seconds to confirm! Press [placheolder thumbsup] to confirm! press [placeholder thumbsdown] to try again!')
def check(reaction, user):
return user == message.author and str(reaction.emoji) == ':thumbsup:'
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await channel.send('Gotcha! order confirmed')
else:
await channel.send(':thumbsup:')
i cant seem get the second part, the rexognize if you have reacted part working. any help?
Ephemeral is an invisible message and defer tells the users the bot will follow up later
Umm how can I use it? If am not asking you a lot
Wait I got it!!
Thanks a lot btw!!
damn 7k trophies ur insane
get a room
Ephemeral -> btw how often can u use those are there limits?
could i finally use this for game?
sink ships game or what ever RPG
or can we use Ephemeral just like any msg?
can u do bot dm->msg->send in server Ephemeral to a member? 😛
ofc u can
No limit
You only can use ephemeral messages with an interaction
can anyone help?
error?
why are you doing client.waot_for when your deco is @bot.command?
sorry i forgot:AttributeError: module 'email.message' has no attribute 'channel'
🤦♂️
save yourself an extra variable
channel = message.channel
await channel.send('You have 60 seconds to confirm! Press [placheolder thumbsup] to confirm! press [placeholder thumbsdown] to try again!')
Change this to:
await ctx.send('You have 60 seconds to confirm! Press [placheolder thumbsup] to confirm! press [placeholder thumbsdown] to try again!')
ur right!
also for standard emojis, you need to compare the actual unicode character, e.g. \👍 or \N{THUMBS UP SIGN}
and change your def check function because it has message.author
it is the acual thumbs up its just not showing for sum reason
so add msg inside the heck?
ah okay
no
it's ctx.author, not message.author
!d discord.ext.commands.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
look at the attributes of Context from the docs
ahhhhhh, i see now
oh ok thanks
new error. yay.
reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
gives the error " AttributeError: module 'http.client' has no attribute 'wait_for'"
bot = commands.Bot(command_prefix='!', help_command=None, intents=intents)
you likely have overriden that variable with another bot
@supple crescent actually, show your imports
@spring flax i do have some usless stuff from experimenting btw
from distutils import errors
from doctest import Example
from email import message
from http import client
import discord
from discord.ext import commands
from discord.ext.commands import Bot
import time
from discord import Intents
from discord.ext import commands
import asyncio
which ones am i repeating? am i just blind 😅
yeah
import discord
from discord import Intents
from discord.ext import commands
import time
import asyncio```
this will suffice
wow ok
imagine emailing
Hey, I try to implement a slash command with the disnake libary. Every time I start the Bot I get the following error: SyncWarning: Failed to overwrite global commands due to 400 Bad Request (error code: 50035): Invalid Form Body
In 0.options.0.description: This field is required
In 0.options.1.description: This field is required
warnings.warn(f"Failed to overwrite global commands due to {e}", SyncWarning) looks like I need to add descriptions to the slash command parameters. Anybody know how to fix this?
agagin, scrapped commands
pip install -u disnake
I already have disnake installed
thanks, so the imports seemed to clear that up but now channel is undefined. how hould i define it?
how have you?
what have you done to define channel right now?
i had it defined up there :
channel = message.channel
await channel.send('You have 60 seconds to confirm! Press [placheolder thumbsup] to confirm! press [placeholder thumbsdown] to try again!')
but then we streamlined it to
await ctx.send('You have 60 seconds to confirm! Press [placheolder thumbsup] to confirm! press [placeholder thumbsdown] to try again!')
should i just redifine it doen there?
yup
when writing commands, is it typically
1 class per 1 cog?
you are referring to a channel variable right?
yeah
tyty
Also u need to setup
yes but
except asyncio.TimeoutError:
await channel.send('Gotcha! order confirmed')
else:
await channel.send('👍')
was relying on channel = message.channel, although that was bugged since message.chanel didnt work anyway
Name huh?
A cog is a class, do you mean one cog per extension?
yeah i believe a cog file was meant
not message.channel like I said, Context ( ctx) in the case of the command) has a channel attribute. So ctx.channel
I'd do 1 cog per file, but you can have multiple cogs per extension and doing so can help with the structure of large bots
Wait Indents?
a cog file and an extension?
Do try excpet have else too?
A cog is the individual class, an extension is a 'module' with a setup method
yes
so an extension could be
file.py
```or it could also be
```py
folder/
__init__.py - has a setup() method
cog1.py
cog2.py
...
U mean different file like mod.py
it worked, ily man. thanks for helping me with my shit code
extensions are resolved in the same way as imports, so if you can import setup from {extension} that extension can be loaded by dpy
she was asking about extension ig
for example
try:
#do a bot.waot_for
except:
#if it failes
else:
#if the check is met
@commands.Cog.listener()
async def on_member_join(self, member):
with open('guilds.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
channel_id = guilds_dict[str(member.guild.id)]
await Client.get_channel(int(channel_id)).send(f'{member.mention} welcome!')
@commands.command(name='welcome')
async def set_welcome_channel(self, ctx, channel: discord.TextChannel):
with open('guilds.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
guilds_dict[str(ctx.guild.id)] = str(channel.id)
with open('guilds.json', 'w', encoding='utf-8') as f:
json.dump(guilds_dict, f, indent=4, ensure_ascii=False)
await ctx.send(f'Sent welcome channel for {ctx.message.guild.name} to {channel.name}')
**Error: **
line 421, in on_member_join
await Client.get_channel(int(channel_id)).send(f'{member.mention} welcome!')
TypeError: get_channel() missing 1 required positional argument: 'id'```
is this a large bot or guild?
Alright +1
Put channel id
TypeError: get_channel() missing 1 required positional argument: 'id' btw
you're trying to call the method on the class Client, you need an actual instance of Client/Bot to call the method on
mm i'm reading, 1 minute
if you've defined commands.Bot as client, you put a capital C whereas you should have put client
Client.get_channel(id=str(channel_id)) ?
Do u guys suggest doing client.get_channel(2839282893).send("hi")
U dont need to define id
I'd personally put the channel in a variable (and check that it isnt None) and then use .send() on that variable
also should't it be guild?
so what should i du
await Client.get_channel(int(channel_id)).send(f'{member.mention} welcome!')
it has to be awaited if you do that
should i copy that
guild.get_channel?
Bruh
what?
could do, but client.get_channel is also perfectly valid
member.guild.get_channel
ah ok
im gonna try
he's right...
yeah though in the context of a command, I assume guild.get_channel is better right?
just thought guild would be needed specified
Yes ik but that was an example
so in my example here
PingCommand class is a cog?
info is an extension?
yes
thanks guys
^^,
Np
only one command in a cog?
so far yes lol
She's starting?
ping is the only thing that belongs in a ping cog tbf
@slate swannp
no i was just asking
Ok
why i read it as farting?
Idk
lol
weird brain
..
so if i were to add a /server command to info.py
i'd add a new class for it
and add another bot.add_cog(...) in info.setup?
well yeah
No
wdym info.setup? you can use the setup method
U can put the commands related to it in 1 class
never used add_cog only load_exstansion
You don't have to add the cog manually. You can make a cogs folder and loop through it

yes class
In that case what you might want to do is make the folder called info, in the __init__.py put your setup method and imports from other files in the folder, and then separate the cogs into individual files like ping.py something_else.py
that makes more sense yeah
Epic docs fail
😄
i don't think i've ever seen more than 1 add_cog in any setup method.. typically.. right?
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
Typically people don't but I'm not really sure why, if anything it's a good thing to do that not a bad practice
disnake*
epic fail of docs
doesnt matter lol
maybe bc everyone's copying each other's bots?
Lol
extensions loading is how it is so you can have better structure, and then people went and made every file its own ext lol
!d from mayter import doesnt
7.11. The import statement
import_stmt ::= "import" module ["as" identifier] ("," module ["as" identifier])*
| "from" relative_module "import" identifier ["as" identifier]
("," identifier ["as" identifier])*
| "from" relative_module "import" "(" identifier ["as" identifier]
("," identifier ["as" identifier])* [","] ")"
| "from" relative_module "import" "*"
module ::= (identifier ".")* identifier
relative_module ::= "."* module | "."+
```...
Not me
lol!!!!!
Makes no sense
yeah
.bm cogs and things
H?
.bm things & cogs
Your input was invalid: You must either provide a valid message to bookmark, or reply to one.
The lookup strategy for a message is as follows (in order):
- Lookup by '{channel ID}-{message ID}' (retrieved by shift-clicking on 'Copy ID')
- Lookup by message ID (the message must be in the context channel)
- Lookup by message URL
Usage:```
.bookmark [target_message] [title=Bookmark]
#bot-commands
I use
for GTAO's bot we have extension init files that look like this which makes the actual loading simpler while keeping good structure and everything in places you'd expect
how do I check if bot is able to give the mentioned role from the command?
do I check the role position or what ?
@daring olive why dont u have like !vps
Imports
Why inside a function
repl n i dont know those websites they use all complain not working
because that's how dpy loads extensions
can you screenshot the project structure too?
please ping
some folders arent expanded else it would be massive, but if you want to see the structure of a specific one just point it out
@vocal ploveri would recommend do a standalone moderation bot
pretty much the only one I can't show because it would give away sensitive logic lol
u dont want ur RPG bot fail n cant do moderation when needed
Sensitive logic.
and its no need to be same bot
yeah a couple hundred lines of scam detection is not something I want to make public for the scammers to use to help them bypass it lol
Custom voice does ur bot speak??
no it allows users to create small private voice channels for themselves via a command
U mean private voice
maleonmale
What?
1on1
Melonmail?
huh?
yeah a moderation bot should be same as ur RPG bot
Also with some utilities
I don't have an rpg bot
should't
is moderation another bot?
Ofc not
No it's part of the same bot because the bot is designed to handle important things for the server
In the same way @unkempt canyon has both moderation utilities and stuff like the eval command
then what i try say is make ur modbot seperate
modbot is an idler but when u need it u cant have a game bugging
Listen people need functionality the more the commands the more the fam
if I make it separate it wouldn't make a difference, everything in the bot is designed to fail without affecting other components, and if the whole thing is down it means the host is down so I'm fucked anyway
i take that as sarcasm lol
also needs functionality the more the less
he still should keep modbot sperated from gamebot
ok
ye lol?
Ill hope my bot will have heavy traffic with only a ban command
haha
will nvr happen with that wish
but i hope u get high traffic server one day
In moderation ppl need ban kick mute unmute lock unlock nick resetnick warn
then u can test ur ban-command u got from #discord-bots
u forgot 1
most usefull one
timeout
Unban u
I was banned for 1 year and unbanned today
kick is just meh
i like this buildt in timeout
it pauses u from all chans n voice
Kick is friendly
n they have a countdown
Imagine completed bot but no hosting
dont u have 5bucks a month?
No
i hope govs around world gives kids 5$ a month to spend on VPS
if u want to host ur completed awesome bot
I just maked it for fun
but u ask for free hosting
Yup
.
someone has to pay
electricity n bandwidthbut u want it for free
and 1999999999 more kids
Ill pay when ill be like 18
dont you have like cutoff cards for vps duo studie'?
Im 14 bro stop
if u root it yes
No way
A ethernet pendrive
when login? put settings? hostiung?
Internet
Who likes to root there router
but u would need a new router 😄
perhaps
u askedme
if u could host bot on router
Nvmd
yes?
Ur name say ping me
I wasn't sure if I would interrupt you
@uncut zephyr just cause of name i get no choice than to ping
U can
I guess my bad xD
@honest vessel
Yeah I have a question. You can add a "add to your Server" button to your Bot.
But when I try to click mine, this shows up
Na its because this Server is on mute and I want to know if someone responds
U dont have permission
nvr seen can u show ur code?
i can show mine

await channel.send(embed=embed, view=InviteBot())
U don't have permission
Vro hes saying about inviting his bot to the server
There is no code. I did it on the Discord developer site
@uncut zephyr
bro its enough okay?
class InviteBot(ui.View):
def __init__(self):
super().__init__()
url = f"https://discord.com/oauth2/authorize?client_id=1111111111111&permissions=277105134663&scope=bot%20applications.commands"
self.add_item(ui.Button(label="Add me to your server", url=url, style=ButtonStyle.blurple))
``` disnake
I dont think thats asked
Bot promo
url =
Why f string there
cause i was born with 3 legs
U mean 3 brain cells 🤣 jk
I dont know. what is super()?
!d super
class super([type[, object-or-type]])```
Return a proxy object that delegates method calls to a parent or sibling class of *type*. This is useful for accessing inherited methods that have been overridden in a class.
The *object-or-type* determines the [method resolution order](https://docs.python.org/3/glossary.html#term-method-resolution-order) to be searched. The search starts from the class right after the *type*.
For example, if [`__mro__`](https://docs.python.org/3/library/stdtypes.html#class.__mro__ "class.__mro__") of *object-or-type* is `D -> B -> C -> A -> object` and the value of *type* is `B`, then [`super()`](https://docs.python.org/3/library/functions.html#super "super") searches `C -> A -> object`.
The [`__mro__`](https://docs.python.org/3/library/stdtypes.html#class.__mro__ "class.__mro__") attribute of the *object-or-type* lists the method resolution search order used by both [`getattr()`](https://docs.python.org/3/library/functions.html#getattr "getattr") and [`super()`](https://docs.python.org/3/library/functions.html#super "super"). The attribute is dynamic and can change whenever the inheritance hierarchy is updated.
nop
Then
u think i bait u to invite my bot? 😄 u cant
I want this button to work. (in english: add to server)
Oh.
Discord .py fork
Discord fork lmao
Lol
can i post my bot invite link here? jk
No
kek i just trie meme a valid id
Its a jumpscare
ye
no need for super here
no, I just wanted to see its face
i think i am already joined
Nvmd
How to get the Add to server button to your bot's profile:
- Go to https://discord.com/developers/applications/ and select your bot.
- Insert at least one tag in the TAGS (MAXIMUM 5) field (these can be any text, separated by comma's)
- From the side menu click on Oauth2 -> General
- Modify the Default Authorization Link with a Custom URL or In-App authorization
ofc i would nvr share invite link here
!stats
Star / Wildcard imports
Wildcard imports are import statements in the form from <module_name> import *. What imports like these do is that they import everything [1] from the module into the current module's namespace [2]. This allows you to use names defined in the imported module without prefixing the module's name.
Example:
>>> from math import *
>>> sin(pi / 2)
1.0
This is discouraged, for various reasons:
Example:
>>> from custom_sin import sin
>>> from math import *
>>> sin(pi / 2) # uses sin from math rather than your custom sin
• Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import.
• Causes ambiguity. From the example, it is unclear which sin function is actually being used. From the Zen of Python [3]: Explicit is better than implicit.
• Makes import order significant, which they shouldn't. Certain IDE's sort import functionality may end up breaking code due to namespace collision.
How should you import?
• Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name)
>>> import math
>>> math.sin(math.pi / 2)
• Explicitly import certain names from the module
>>> from math import sin, pi
>>> sin(pi / 2)
Conclusion: Namespaces are one honking great idea -- let's do more of those! [3]
[1] If the module defines the variable __all__, the names defined in __all__ will get imported by the wildcard import, otherwise all the names in the module get imported (except for names with a leading underscore)
[2] Namespaces and scopes
[3] Zen of Python
Ok hes typing since 5 min
#bot-commands
thanks
cya later
Cya tmrw
happy hacking
nop still doesn't work 🤔
Lol
@client.event
async def on_member_join(ctx, member):
with open('log.json', 'r', encoding='utf-8') as f:
guilds_dict = json.load(f)
embed=discord.Embed(title=f"Hello {member}")
channel_id = guilds_dict[str(ctx.guild.id)]
await client.get_channel(int(channel_id)).send(embed=embed)
-TypeError: on_member_join() missing 1 required positional argument: 'member'
Remove "ctx"
make what? the embed? the bot?
em.add_field(name=name, value=amount)
``` 
nono but it will send
all items in my inventory
i want like if u have more than 5 items
then it sends the embed with u have 5 items
and then going to other page
u can see other items
idk how to explain if u dont understand
ok but i use ctx
a paginator?
def check_for_bot(self, ctx):
def check(message):
return not message.author.bot
return check
res = await self.client.wait_for('message', check=MemCheck.check_for_bot(self, ctx))
I would like to understand why is the check function not working?
The check function checks if the author of the message is not a bot, but the bot just gets messages from itself regardless
ok i am so dumb
just remove it
so basically i just needed to make name = i
f
Bro if i remove the ctx the channel_id not work
you won't even need it
there is no context in that event
you have to remove it so the event works
channel_id = guilds_dict[str(ctx.guild.id)]
NameError: name 'ctx' is not defined
replace it with member
also
channel_id = guilds_dict[str(ctx.guild.id)]
Look closer, this gets the guild not channel
!d discord.Member.guild <-
The guild that the member belongs to.
he wants the channel it seems
he needs to get a channel ID himself, there is nothing called member.channel in on_member_join
try ```py
def check(m):
return m.author.bot is False
await self.cient.wait_for(..., check=check)
so?
What you are doing is wrong
You want to send a message to a certain channel right?
Get the ID of that channel manually and then do client.get_channel(IDHERE)
guilds_dict prolly has channel ids as values?
because in on_member_join event, you only get the member that joined
oh right let me check
@tacit token what does guilds_dict contain?
bro my bot in 85 server. I dont add 85 for the code
then just replace ctx with member
ty hero
ok
no problem
Well thanks to @boreal ravine too
I will try
Apply for the verification?
@boreal ravine Thanks for the help and sorry for bothering you
It seems I had a big misunderstanding for the check function
def check_for_bot(message): return not message.author.bot and message.channel.id == ctx.channel.id
This is what I wanted
You're trying to check if the author is a bot ?
Most likely a stupid question but I have a bot that posts a video response IE: Yes, No, Ehhh ETC. I want the video to post but not show the link. Here is an example of it happening. Is there something I put in my code to make the link disappear? I tried <Link> but that just shows the link and not the video.
how do i make a channel move to a different category when a command is run?
but it wont work cuz of message.channel.id == ctx.channel.id?
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead...
For text channels 
nothing (unless it says to verify your bot)
its says verify ur bot
Then Verify it;) and congratulations
Btw make a command that checks the guilds, basically if ur bot has like 10 guilds with the same owner they'll not going to verify it
like this?
await guild.edit_text_channel.category('CLOSED TICKETS')```
wait
no, like py category = discord.utils.get(ctx.guild.channels, name = "ur category name") await ctx.channel.edit(category = category)
omg i cant spell 💀
okay thanks
ctx.guild.categories .....
iirc
!d discord.Guild.categories
property categories```
A list of categories that belongs to this guild.
This is sorted by the position and are in UI order from top to bottom.
yes
But ctx.guild.channels works too
Since category is a channel 
why not use the categories property
it'd be faster
Yep agreed 
stop using cringe emojis 
guild has no attribute category?
thats justin
I can say the same for you True
anyone know why tf its saying this although it is in the same exact folder as the .py file
I use emojis in my messages lesser than I used to
and that is a good thing
is it in the same folder as the command prompt?
it was more of a first-time-nitro happiness
lemme check
understandable
try doing print(__import__("os").getcwd()) and see if the file is in the same folder as it prints
its not gonna work anyways, even if you fix the file issue
😔 Yerl here, I will just go away and play some games
how come 🤨
Idk
i dunno but fuck this gave me alaugh
if message content would be equal to redeem, it cant be the password at the same time
shit expensive fruits
AAAAAH YES
same price too
one cucmber for one....1000 coins? tf
give me 1000 coins plox
Reasons I hate economy bots
always wanted my own cucomber
who even has the time to do that stuff anyways
@slate swanhow did u come across python n start coding?
Agreed
Please take this to OT channel before I use the command
lol
come
import asyncpg could not be resolved
do you know which type I have to pass to send the ID and the DATE?
USE usersData
CREATE TABLE listUsersData(
id_user (typing),
date_registered (typing)
)
somebody help?
guys on_member_leave works? on_member_join work but the leave not really
a series of data:
date = datetime.datetime.now()
date = date.strftime("%m/%d/%Y, %H:%M:%S")
and the id would be:
ctx.author.id
comando = f"""INSERT INTO listUsersData(id_user,date_registered)
VALUES
({ctx.author.id},{date})"""
did you pip install it and restart your ide?
on_member_leave should work fine, but sometimes it doesn’t send all the data just partial
o ok ty
!sql
SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.
Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.
For example, the sqlite3 package supports using ? as a placeholder:
query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)
Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.
See Also
• Extended Example with SQLite (search for "Instead, use the DB-API's parameter substitution")
• PEP-249 - A specification of how database libraries in Python should work
gg thanks restarting solved the issue
SELECT Ukraine FROM Russia Where President.Name="....
Biden, Joe
meme
think i missed an inner join there
how to send a message to use in PM?
!d discord.Member.send
await send(content=None, *, tts=False, 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://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.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://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.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://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.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://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
which of the parameters is responsible for where the message is sent?
you specify the member instance to send it to, but that isn't a param
the member instance would be a param of your command function
I dont need reddit's meme subreddit anymore, this stuff is real 😔
not necessarily, you could send a pvt. message to the author
well generally it would be a param
get_member 👀
that works too
is there a methode to rename my discord bot If I do it in the Discord Developers Portal it doesn't work
!d discord.ClientUser.edit
await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the current profile of the client.
Note
To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") is given through the use of `fp.read()`.
The only image formats supported for uploading is JPEG and PNG.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned...
is it verified?
!d discord.Bot.edit
No documentation found for the requested symbol.
i's something like this
YourBotInstance.user.edit(username="whatever")
ill find it real quick
here
ghost ping 😔
thx man
same thing with avatar right?
only async def functions or coroutines can be used with await
check what pop_random_line1() is
To upload an avatar, a bytes-like object must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via open('some_filename', 'rb') and the bytes-like object is given through the use of fp.read().```
ah
wym
what is pop_random_line1()? can you show where it is defined?
you need a bytes object, this is a steamReader, Didnt work for me
idk if encoding works
how to get the guild id when my bot is on some server?
for example sending a welcome message on the certain server
wtf
you're talking abt on_member_join event?


