#discord-bots
1 messages · Page 775 of 1
do you even know what, ./ means and you are loading extensions with self, when you should load them with self.bot/client
Means????
./ means that you are searching for files in the current folder
Ok
Nooo
Going to eat
not if they are in the bot class
What did I miss???
a fight between me and a member 
peaceful, innit
is bot.application_id the bot's user_id?
is that........ Hunter the great?
Never
Hunter the loser
peaceful, __init__
I disagree
alr
application_id is the ID of the application
hm, well i found that it is also my bot's user id
this looks like simping everytime
you can stop
oof
How do you guys not get ID autocorrected with I'd
pc supremacy
most of the time, they are same
using Windows
he is just trolling me
uhh any alternatives to somehost? they shut down
ill keep doing that until it's hunter
You got a credit card?
no 😦
sneakyhub / google cloud , aws
Rip okay
or epikhost
y'all hosting?
do they all need a credit card
i get this error code: py dadjoke = ["Why did the old man fell in the well?.... ||Because he cant see that well.||" , "Why did the invisible man turn down the job offer?.... ||He couldn't see himself doing it!||", "Why do C# and Java developers keep destroying their keyboards?.... ||Because they use a extremely typed language.||", "Why is it a bad idea to iron your four-leaf clover?.... ||Cause you shouldn't press your luck.||", "Wanna hear a joke on Construction?.... ||I am still working on it.||", "What kind of bird doesnt know the words to their own song?.... ||A hummingbird||", "I once debated a flat earther. He got so mad he stormed off saying he would walk to the edge of the earth prove me wrong.... ||He’ll come around eventually.||", "Why did the bullet end up losing his job?.... ||He got fired.||", "If you become seriously depressed, try drinking a gallon of water just before you go to bed.... ||That will give you a reason to get out of bed in the morning.||", "Why do astronauts use linux?.... ||because you can't open windows in space.||", "How does a computer get drunk?.... ||It takes screen shots.||", "Why are Pokemon players considered naughty?.... ||Because they always want a pikachu.||", "I figured out why Teslas are so expensive.... ||its because they charge a lot.||"] @bot.command(name='dadjoke') async def dadjoke(ctx): await ctx.channel.send(random.choice(dadjoke))
yes cause it's already in 73 guilds tho noone uses it
the function name
sneakyhub and epikhost dont
its the same
are all of the strings on their own lines?
thx
that is the code man what i sent ya
change the list name to dad_joke
should i stick with the old prefix system or move onto using slash commands?
Rip gotta reinstall ALL THE MODULES AGAIN
use both imo
AAAAAAAAAAAAAAAAA I HATE THIS
now it won't work will it i have to change in ctx.channel.send(random.choice(dad_joke))
uh yes, do that
lol
alr, and which discord.py fork do you recommend i use?
so, hunter uwu? :))
Disnake <3
Yea
No
thanks
I like being single thanks

Sarthak, u already love Hikari tho ;-;
idk why but my console is getting this error:
Traceback (most recent call last):
well, show us the full error
no, we r just best friends
double date :))
Phew
there is only this small error idk why
Repl being Repl
that's something literally every error has
uh, do you have any idea of command where this error occurred?
send the full error , nvm replit
Windows 11 do be cool tho ngl
I found it thx anyway
uh k
arch/kali
I'd love to peep into the "Python Stuff"
how do i get a user's id using their username?
Just the every Python project I have ever made
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
blackarch
not much
and use .id on the object u get
Wowww
^^ read this savagex
Hmm, I just bought a new laptop today, soooo I am just trying it out with stuff haha
Wait what , you manage to consume 1.03 gbs in a single day
what happens if you verify your bot?
From my older PC
does it lose all it's intents?
You get to join more than a 100 guilds
You gotta apply for each intent separately
It gets a tick mark and you obliged to have a reason for getting privelaged intents
A check mark
member = discord.utils.get(message.guild.members, name='username')
member.id
like this?
hell yeah count me in
wait you looking for a member?
My bot got one
!d discord.Guild.get_member_named
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.
If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.
If no member is found, `None` is returned.
!d discord.Guild.get_member_named can also work
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.
If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.
If no member is found, `None` is returned.
i have a username already
Rip
who's id?
mhm
trying
lmao free nitro link
Nitro is bad ngl
@bot.command()
async def foo(ctx, member: str)
await ctx.send((ctx.guild.get_member_named(member)).id)```
who needs nitro when you can get a good vps at the same price or maybe really less
hrl , it's wrong
Nvm it's right
yessirrr , i speak a language from atlantis
yessirrr
So, you speak Fortnite sweat as well?
!ot
cof cof
okay python hates me
Don't u think you cof too much?
Covid
python -m pip
bro what is discord-components
hi guys
Know?
No
stop changing your pfp and name, we all know you okimii
Hunter Lib
Cant 😔it's for smart people
Unlike me
Know ?
py -m pip install discord-components
you mean smort
but why would you need to install discord-components?
You can say that
🧠
i was getting bullied by seniors in high school not fun😔
And then there's me who doesn't even talk to anyone in school
class okimii:
def __init__(self):
while True:
change_pfp()```
!ot
and learn to fight back
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
There
boi wut
error😳
relatable
smh
same here👀
You guys going to school?
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
def change_pfp():
print("I will do it, cry about it")
class okimii:
def __init__(self):
while True:
change_pfp()
Not nowadays sadly, talking about the past
🧑🦯
Anyways, not continuing this here, let's go to an OT channel
I was successful in including hunter in an Ot chat , yaya
.bm
Anything else?
.bm
not ot command for you because hunter uwu
bm a bm
Rip
#ot2-never-nester’s-nightmare if u wanna continue UwUing me
i get error
TypeError: object of type 'User' has no len()
Can you send a traceback
Traceback (most recent call last):
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\disnake\ext\commands\bot_base.py", line 561, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\disnake\ext\commands\core.py", line 930, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\acer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\disnake\ext\commands\core.py", line 185, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object of type 'User' has no len()
What is i
SavageX#6666
A string?
object
then i won't work
That's your issue
it requires a string
wait i'll check to make sure
you can do str(i) tho
If you alr have the object then what are you trying to do
User objects are not the same as Member objects.
fair enough
Facts, but discord.Member is a subclass of discord.User, so everything that User has, a member will have
Depending on what they want to do, they might already have the Member object though.
if you have the user obj, you don't need to get the member
just await ctx.send(i.id) i being the user object
yo @full lily , you events, nice! congrasholashions
Against ToS
Lmao
And yeah, we don't provide support for music bots.
lmao i did not notice that (saves screenshot)
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
yeah do that
k nvm
how do i get roles from this
i.id.roles wont work , neither i.roles
lemme check
!d discord.User
class discord.User```
Represents a Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the user’s hash.
str(x) Returns the user’s name with discriminator.
are you sure i is a user obj?
yes
oh yeah!!
soooo
so, py member = await ctx.guild.fetch_member(i.id) member.roles
perfect
What u even doing bruv
Why not use guild.get_member
i personally prefer fetch
i never trust the cache
no
!d disnake.Guild.getch_member
await getch_member(member_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get a member from the cache by ID. If fails, it fetches the user from the API and caches it.
Yes
In between solution
getch gut
getch everything, getch channels, getch guilds, getch users, getch messages,
i want getch everything
Why didn't you recommend it then lol
otherwise i will not be statisfied
Idk cz am half dead
!d if
8.1. The if statement
The if statement is used for conditional execution:
if_stmt ::= "if" assignment_expression ":" suite
("elif" assignment_expression ":" suite)*
["else" ":" suite]
``` It selects exactly one of the suites by evaluating the expressions one by one until one is found to be true (see section [Boolean operations](https://docs.python.org/3/reference/expressions.html#booleans) for the definition of true and false); then that suite is executed (and no other part of the [`if`](https://docs.python.org/3/reference/compound_stmts.html#if) statement is executed or evaluated). If all expressions are false, the suite of the [`else`](https://docs.python.org/3/reference/compound_stmts.html#else) clause, if present, is executed.
getch doesn't have a lot yet.
NOOOO
disnake.Client.getch_user (Python method, in API Reference)
disnake.ext.commands.Bot.getch_user (Python method, in API Reference)
disnake.ext.commands.InteractionBot.getch_user (Python method, in API Reference)
disnake.Guild.getch_member
Lmao
phew
!d disnake.Guild.get_member_named
get_member_named(name, /)```
Returns the first member found that matches the name provided.
The name can have an optional discriminator argument, e.g. “Jake#0001” or “Jake” will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to work.
If a nickname is passed, then it is looked up via the nickname. Note however, that a nickname + discriminator combo will not lookup the nickname but rather the username + discriminator combo due to nickname + discriminator not being unique.
If no member is found, `None` is returned.
This is kinda a shit function.
everyone should id's
discord should remove usernames altogether
my name would be 879807617260716143
hey there @879807617260716143
Mine would be 169790484594556928 (flex)
Lol starts with an 8 your account is prob a year old.
It's not exactly a promotion. It was opt in
really?
Tue, 24 Aug 2021 19:21:21 UTC pretty accurate.
but congrasholashions anyways
opt in he means forced.
Congratulations to you too
What object does a bot.fetch_user()
Return?
!d disnake.ext.commands.Bot.fetch_user
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://docs.disnake.dev/en/latest/api.html#disnake.User "disnake.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`disnake.Intents.members`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.members "disnake.Intents.members") and member cache enabled, consider [`get_user()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot.get_user "disnake.ext.commands.Bot.get_user") instead.
You're sometimes using space and sometimes using tabs for your indentation.
#bot-commands for random commands please ^^
Check the difference between after.roles and before.roles.
It will give a list of roles the user had before and after the update.
Then you can compare both and see if the role added was the booster role.
try and see
also, comparing the length of both roles is a terrible idea, both could have the same length but different roles
Yeah because the role added is the booster role
Now try another role and you will get an error
there are other flaws like: you don't have a check what will happen if the after roles are empty etc
As I said
The day when a user gets a different role, it will error.
Because you define the embed object if the role added is the booster role, but always try to send the embed.
Simply align the .send in the if statement
Same for .set_footer
Yes
you don't have a message variable
think 🧠
you have to think about it mate
like "how would I possibly mention a member, if I have the before and after arguments?"

there's still a flaw in your code
the length of the roles doesn't matter the slightest bit, the only thing that matters is if the goat role was added to the member
Also ```py
if before.roles != after.roles:
that's not the best option, since the if statement will be true if a role got removed too, which we don't want
So that's where snipers of ot2 make guns.
help me with my eval code rq
@bot.command()
async def eval(ctx, *, args):
result = eval(args)
await ctx.send(result)
..
nice code you got there
yh
can i join a server your bot is on? 
sure
just wanna test the eval command 😳
check ur dms
damn that's dangerous
SHHHH
delete it rn
why
someone might use it to run some code which might harm your computer
remove it fast
😳
what if it’s on replit
then happy days
i host my bot on replit
Erm, hello. What's going on here? 👀
were you trying to get his token
no
should use exec but dont do that
bruh
i dont want the token of a bot with 1 server
not safe
bruh
i was just gonna make an example of why you have a private eval
That code will allow anyone to hack your bot.
they might use it to get your token
with quite a visual demonstration 😄
yes
Even hack your entire system if it's hosted there
!pypi disnake-debug || use this instead
great eval and all that
thats cool
made by you as well nice
can you guys all stop using "stuf" in your messages
then why did you reply to me like that
every tool one might need
😳
looks good lol
what are you gonna add?
logs would be cool
is this what i should do when i want to make a command both a slash command and a normal command?
new to using slash commands
Library?
Can anyone explain me more about the idea of cogs and why they are better than just discord.ext.commands?
Well I'm sure you can't do that
i figured it out
You can store your commands in different files , and thus making your code cleaner and easy to edit ( that's for your/dev side)
You can use Cogs as categories for your help command when you make a custom help command
( For the user side)
hm...
I still need understand that thing
And need to have some creativity to any project
but thx.
They are magically cool
you just need some basic OOP knowledge to use them!
I know oop... I'm just dumb.
what do you mean by logs?
im lost for ideas
idea thing?
Yea, some ideas, I've got none.
like, you want to learn, or command ideas?

when setting uptime_start to time.time on ready it doesnt work
it says its not defined when i try to use it
Can we see how you're trying to do it?
show the code please 
how would i config welcome messages the way someone helped me doesn't work
can you show the code 
how does it not work?
let me get error
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: title is a required argument that is missing.
Ignoring exception in command welcome_cfg:
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "H:\My_stuff\Discord bots\discord bot\cogs\Events.py", line 53, in welcome_cfg
self.configs[str(ctx.guild.id)]['title'] = title
AttributeError: 'Events' object has no attribute 'configs'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Events' object has no attribute 'configs'```
i love when people send code that is tailored and specific and most likely copy and paste expecting us to magically know what, when, why and how theyre doing it. not aimed at anyone specific 😳
I have to agree with this, but I was scared of clashing with the #code-of-conduct
it is a welcome_config
that is broken
Is this how it should look?
nope
well....why...why await member.send.Embed?
!d discord.Embed 
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
Ah
Should I use this formation?
Imma ofc delete those parts.
Like channel send, membed.add_roles etc.
can someone explain how i fix that error
I mean ig
never dealt with an 'Events' object before
events is the cog file name
ah~
do i need the config module?
maybe try def __init__(self, client, configs)?
How do I change cursor
so it doesnt be like it changes yk
c...cursor?
a mouse cursor?
Like a sqlite cursor?
doesn't let me type
you mean like it automatically adds stuff you don't want?
it is not accessed by pylance
ok
It has nothing to do with the code
no bro like-
I know his issue
it doesn't even let me do ctrl + enter
@modern fiber take a picture of your keyboard
well idk :sadge:
my what
how would you write a config for a welcome message ?
maybe it's json.loads(db) Maskuh
I'd go with...wait what are you doing with welcome_cfg?
Press the insert key
While you're in pycharm
That should fix your issue

that emotionally reminds me of my stepsis
she was so good like you
until she was found dead under bridge
that's cursed
well rip
Enough discord for today
LOL
Is this how it should look? @velvet tinsel
channel.send
message?
channel is undefined rn
it should dm user
then do member.send
10-4
10-4?
lol
what's 10-4
Why checking the server name, which can change. Instead of checking for the server ID which will never change.
is it a date or a equation
i'll aswert
my guy winrar
https://www.dictionary.com/e/slang/10-4/#:~:text=10-4 is an affirmative,pic.twitter.com%2FzpsDNPtorQ
ok
well if anyone knows how to make a welcome message configureble per server let me know in #help-potato
So i have a problem using in a discord bot using a replit database, here's the code:
async def on_message(message):
if message.content.startswith('$start'):
if message.author in db.keys():
message.channel.send('You have already started!')
else:
db[message.author] = 0
message.channel.send('You have started your profile, now go make some money!')
@client.event
async def on_message(message):
if message.content.startswith('$gib money'):
db[message.author] = db[message.author] + 1
message.channel.send('your balance is ' + db[message.author])```
When I execute the commands nothing happens and no error pops up
That's not how commands work.
nope
?
not at all
And if you want to keep it that way, which is bad, then you need to put everything in one event.
This is how you make actual commands.
using @@slate swanclient.command? If that's the case then I have commands using that but I don't get what that has to do with not responding (although I will change it right away)
I ment '@client.command'
It doesn't respond because you have 2 events.
Put them both in one.
I'll just change them to client.command
Not good:
@client.event
async def on_message(message):
...
@client.event
async def on_message(message):
...
Good:
@client.event
async def on_message(message):
...
...
thx
Well, I don't need those, but it gives me an errors bc of them?
you can't leave the name empty, what you can do tho, is use an empty char as name
can you send me it?
\u200b
gern geschehen
I also suggest you to use hyperlinks
this is shit
a bot will convert this
also this doesn't work for some reason, mentioned user isn't kicked, no error, nothing:
#$kick
@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason)
I have the same thing for a #ban command and that doesn't work either
Well how can I do this?
Add like one more title.
So the "Important Links" is bigger. Or should I just use the text.size?
are you sure the bot has permissions to kick the specific user
yea it has administrator
Hm. What should I do then?
Bold or Underlined or Both
Sophia. has no roles
In your on_message event
Add at the bottom
await client.process_commands(message)
ok I'll try, btw the command is straight from a youtube tutorial
Otherwise no commands will ever be executed.
See this
maybe instead you should encourage usage of listeners
Do so if you wish to do.
Nothing halts you from doing it instead of telling me what to do.
lol don't fight about it
we're not fighting lol

imagine fighting
Imagine ||dragons 🐉🐲||
ok
supposed to be like this?
sec
@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason)
await client.process_commands(message)```
I ment this
cause it's not working
Guys, this is the code, but this is how it appears. How do I fix those gaps?
hell no, that last line only needs to be in on_message
Hm? @velvet tinsel
dude said just to do this
@potent spear
you mean the ones near the weird _____________________________?
yeah like- its just gaps
▬▬▬▬▬▬▬▬▬▬▬
in your on_message event
is indeed what he said
well uhh...
help please
read please
can you just like modify the code lol I DO NOT understand what you mean
@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason)
await client.process_commands(message)
if you have the time and strenght
remove the final line
and?
remove last line
put last line in on_message event
if you can't read that, ig go back to the books
sniperglitcherz has already told you what to do, so did krypton
i'll try lol
@potent spear help me maybe?
I don't get what's hard about that 
gasps ah
told you 3 times, won't repeat, sorry
well I am definitely new to discord.py
you never told me ;-;
apparently
Anyone know how to make a configable welcome message.
are you new to python?
use the on_member_join event (and also use intents
)
I gave you code i know how to make one I need to be able to config it for each server
well I have been using python as my only and main language for 2-3 years so I wouldn't consider myself that new to python but still not an intermediate
Instead of default
well I don't know what you're trying to do with the welcome command, maybe fill me in?
I have like 7 different servers and all welcome messages look exactly the same I want to make it able to be changed per server via command in discord
It’s just oop and asyncio. nothing too advanced.
maybe store it in a jso- oh yes, tylerr is here, finally I can leave this chat
Use a database
nice link to paste xd
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: title is a required argument that is missing.
Ignoring exception in command welcome_cfg:
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "H:\My_stuff\Discord bots\discord bot\cogs\Events.py", line 53, in welcome_cfg
self.configs[str(ctx.guild.id)]['title'] = title
AttributeError: 'Events' object has no attribute 'configs'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Program Files\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Events' object has no attribute 'configs``'
json 💪
😳
json is an amazing db
And it works
def __init__(self,client):
self.client = client
try:
with open("welcome.json", "r") as db:
self.configs = json.load(db)
except FileNotFoundError:
open("welcome.json","x")```
this could be your main problem yk
tf is the point even of the except?
lmfao I was joking
To create the file if not found
Though I should go to else
think about it
if the file was created, self.configs still isn't defined mate
also, you know what a context manager is?
So how do I define it and yup
Hey, i want to make a discord bot that actually gets the role by the id that i defined, and if someone don't have the required role
so it send him the 'faild' embed.
i tried to put else: but it didn't worked
someone know how can i make it?
make the pseudo code first, then I'll tell you if it's good enough to write out in python
Pseudo?
example
if I shit my pants
then change pants
else, keep farting
get the role by using the get_role method and the member's roles by using the roles property on the Member object, and then check if the role exists using simple python
Lol but I get that
see? this is understandable in any language, yet isn't actual code
thats a pretty nice example-
can you send me the code/ i've already tried everything
I should make a post in the subreddit ELI5
shall I write the bot for you, my Lord? ¯_(ツ)_/¯
You haven't tried everything but you tried everything you know
the main problem is his basic python knowledge
I'll upvote
I'm doing them daily on this channel tbh
Let me get my example that goes well from my bets bot
So that doesn't fix the error
well, I need to know what you're going to try before helping
I'll just say that the current init isn't good
Oh
You're too skilled to leave your creations here ;-;
Basic idea of what the task is
Easy
the problem is, sometimes I have to explain for what looks like a 3 year old
await db.execute('''INSERT INTO warnings (member, reasons, moderator) VALUES ($1, $2, $3)''', member.id, reason, ctx.message.author.id )
``` File "c:\Users\bert\Downloads\discord bots\Bertie's discord bots\cogs\warns.py", line 37, in warn
await db.execute('''INSERT INTO warnings (member, reasons, moderator) VALUES ($1, $2, $3)''', member.id, reason, ctx.message.author.id )
AttributeError: 'Context' object has no attribute 'id'
See? I'm physically 15 and mentally 3, people just come here for code
its in a cog
it thinks member is ctx
@commands.command()
async def warn(ctx, member : discord.Member = None, *, reason = None):
if member is None:
embed = discord.Embed(
title = '**Error**',
description = 'Please provide a valid member to warn!',
color = (0x3498db)
)
await ctx.send(embed=embed)
else:
if reason is None:
await db.execute('''INSERT INTO warnings (member, reasons, moderator) VALUES ($1, $2, $3)''', member.id, 'unknown reason', ctx.message.author.id )
await db.execute('''UPDATE warnings SET warns = warns + 1 WHERE member = $1''', member.id)
await ctx.send(f'{member} got warned by {ctx.message.author}, reason: ``unknown reason``')
else:
await db.execute('''INSERT INTO warnings (member, reasons, moderator) VALUES ($1, $2, $3)''', member.id, reason, ctx.message.author.id )
await db.execute('''UPDATE warnings SET warns = warns + 1 WHERE member = $1''', member.id)
await ctx.send(f'{member} got warned by {ctx.message.author}, reason: ``{reason}``')```
self
self, ctx
try must have an except or finally
that's the first arg you'll need
And I wont need to use self?
nope
alright, time for me to go study cogs by hard
sniper are you good at dpy/forks
just OOP in general
not at forks
how good
@potent spear try must have an except or finally
some other notes
ctx.message.author.id is just ctx.author.id
nah, tell me what you'll try to do to define self.configs
wow ignored smh
learn python OOP basics first
what
lmao
what I know about dpy?
I'd say a 7/10 max
8 being not using docs for anything
9 as in I helped writing the docs
10 as in I am the docs
ah ty
ok
so ctx.message.author is ctx.author
correct
im taking this as an insult
This page shows Python examples of config.Config
that's just a
"Hey, I'm a beginner, where do I start?3
what
do yo know what this is?
I thought you were just asking how to start the dpy lib
import discord
import os
from keep_alive import keep_alive
import requests
client = discord.Client()
def generate_image():
resp = requests.get("https://api.thecatapi.com/v1/images/search").json()
return resp
@client.event
async def on_ready():
print("Logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("!cat"):
await message.channel.send(generate_image())
keep_alive()
client.run(os.getenv('TOKEN'))
``` why does this not return anything when i do !cat
He's trying to recruit you for a project
how to define self.configs
im not
i was just curious
ive given up on jarvide
but 🤫
Why?
people like dekriel add weird ass commands and the ai was never done so its kinda false advertising
lol
well, you tried in the init
this is your pseudo code
check if config file exists
if not: create it
if it does
read from it and assign self.configs to it
Are there any errors?
nope
oh nvm it works [{'breeds': [], 'id': 'a1u', 'url': 'https://cdn2.thecatapi.com/images/a1u.jpg', 'width': 480, 'height': 640}]
how do i make it actually show the image tho
you definitely want to start looking into commands asap
me?
Yes
its confusing
i have
Trust me, doing it your way is going to get a lot harder
and thats what it taught me
nah, like actual good examples
https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py
Where is the best way to store reminders in Discord bot? Json or something else
explain is the config file the welcome.json?
it taught me to do it that way
json is 100% the way to go 
do you get banned for misinformation
.txt files
Punished, yes
smacks lips: time to push the limit
Sql
you have to think about certain stuff first
"what should it store?"
"what should the structure look like?"
like "when do I update this file?"
"should I update the config instantly too?"
"do I keep a backup when things go south?"
...
only if its deliberate
what is this red line there for?
because of 2 awaits?
i can almost see the syntax error
a database is definitely what you're looking for
and NO json isn't one
SyntaxError: inconsistent use of tabs and spaces
oh lol
i reckon this is pretty bang on
Why not @potent spear
I already have that set for if it is not created it needs the guild id, the title, and the description
!e
def x():
print()
def y():
print()
x()
y()
@manic wing :warning: Your eval job has completed with return code 0.
[No output]
json is used for other purposes, not as a db
fuck
config if what exactly?
But you can still use it for reminders, no? xd
resp = requests.get("https://api.thecatapi.com/v1/images/search").json()
return resp
#[{'breeds': [], 'id': 'a1u', 'url': 'https://cdn2.thecatapi.com/images/a1u.jpg', 'width': 480, 'height': 640}]
when the use %welcome_config
What's up with your indents, you're missing self, use f strings and pass_context is now depreciated
I can eat soup with a fork, no?
get my point?
sniper, I'm struggling with adding buttons in cogs
thats the response i get from just returning it with nothing
how do i access the url
["url"] doesnt work
@commands.command()
async def clean(ctx, limit: int):
await ctx.channel.purge(limit=limit)
await ctx.send(f'Cleared by {ctx.author.mention}')
await ctx.message.delete()```
fixed
Not fixed
you can eat soap with a fork i've done
Yeah but how are some other databases so much different from Json, they still store by key value? speed? Can you throw some more practical databases?
Sqlite3
I guess your config.json will look like so
{"guilds":
1234:
{ "title": "Hey shitbag",
"description": "yup, I called you that"
},
65151:
{ "title": "Sup buddy",
"description": "may the force be with you"
}
}```
?
resp = requests.get("https://api.thecatapi.com/v1/images/search")[4] doesnt work
It returns a list with a dictionary in it
correct per guild
You need to get the first element of the list
use aiohttp, requests is blocking in an async context
well, the key is the guild's ID
ok so how do i put that in play
so how do i access urls
Close is basically self
[0][3]?
wdym?
By getting the first index of the list and then getting the key
is it even possible to get buttons and views in cogs?
to refer to the current class, you use self
I dont wanna refer to the same class
I got like 5 of these views
all in the cog class
first, have a config json with that kind of structure
you can have it empty at first ofc
but make sure it gets filled in the on_guild_join event
yes..
You sure?
just new to discord bots
Idk if its the wrong chat but.. if someone can help me pls (embed)
This is pretty basic stuff
code?
never used that before
Error says it all
ive used apis before and the ways ive tried dont work
await ctx.send(embed = discord.Embed(description = text))
have u read this sniper?
well, think about it
whenever your bot joins a new guild, you obviously want to add it in the config json
its worked before but now is not
Ik I can be very annoying but I'm having some troubles with putting my code in cogs now
I have no experience with buttons or fork stuff, can't tell
oh alr
true so do i have to add all guilds that are already in it to it manully?
well, I'll tell you why
discord updated its API recently
and you're selfbotting (you're using a user token)
to make it work, you'll have to start using bot tokens
so i cant user anymore a selfbot so
hmm, you could run a command once to fill it up, so you don't have to do that manually lol
do you still need help on this
use**
why are you even selfbotting
nope, that's against ToS anyways
you cant do tjat
fun with friend on private server
use bot not user
#[{'breeds': [], 'id': 'a1u', 'url': 'https://cdn2.thecatapi.com/images/a1u.jpg', 'width': 480, 'height': 640}] that is the original response
okok
yeah but ur doing subscribe directly on request manager
i think you want to do requests.get(...).json()
@slate swan Send your code
ok so do i open the database file then add that paramter to it i have never sent stuff to a data base before
then do result[0]
I can help effectively now
he already did
i did but then i got rid of it
ye
don't call your config json a database
anyways, your command should loop through every guild and APPEND it to the config json
ofc, you have no idea what the title and description of that config per guild would be, you can set that up manually
so tl dr is, you get context manager in .get or stuff
you either .json() or .text() then do it on it
which ?
.json() ?
ye
thats why i got rid of it but i was looking back at the json response when i was trying to index it when it wasnt converted it to json
ignore that, its mostly issue that shouldnt be cared about
im so stupid lmao
ty
what stuff do i put in the parenthaces ()
self, ctx?
you should be able to make a basic command by now
yes i usally put self, ctx onthe on_ready i do just self
idk what you're saying, but you can base yourself on your previous commands in a class
how do i add to that one file?
Discord bot script Python dm ME
?
if you are advertising, sorry but nobody here needs prebuilt script
Hmm?
i think he wants us to build him a discord bot script or something like that?
probably, not sure
just add a command to your bot, it has nothing to do with your config stuff atm
anyways, if your bot isn't in too many guilds currently, you can do it manually
i was working on the guild join
since that'll take you not as much time as coding the command xd
Νice
Nah, bribe me with money, not for free
try python -m pip
add PIP to path or that ^^
Dont try
!rule 9
its same thing
how do i get all the command names from a certain cog?
python get-pip.py
checked the docs before asking? xd
that is if he has that file locally
ya don't or add them to your help command
No is wrong
?
to know what they are
What?
they asked how to see all the command in a cog
Are you okay?
so youre saying i should go through the whole docs or like a certain category
yea
it has a search option yk
just do see python -m pip install whatever and see if it works
The reason hes getting the commands is probably for his help command...
very likely
yea i add them manully
You because you have very bad practices doesn't mean you should recommend them to others
i suggest you to write modular code
true but it works doesn't it
never done it before
back then i used to do same, and it was basically pain in ass to modify
not to hard just add one command after another while your building
I doubt it "works" to the extent a normal help command would
@final iron im trynna copy jarvides help cmd 🤫
Thief
🤫
bot.commands is list of each command (subcommands not included)
each command has .brief, .doc, .hidden and stuff like that
you could take advantage of those instead of hardcoding
i could
also if command is group, it has .commands too which goes on same thing as i just said
i haven't got the need for it yet
i didnt tell you to do it rn so u can do it anytime
so i have multiple commands just no welcome config commands
or leave config
No need for a command, just use events
also is it possible to turn it off from a command
Yup
ye
Desperate
explain how because i don't understand what ya mean
i use events but not these events
@oblique cobalt will 😉
why does it send the message multiple times?
@commands.command()
@commands.has_permissions(ban_members=True)
async def gban(self, ctx, user: discord.User):
for guild in self.client.guilds:
await guild.ban(user)
await ctx.send(f"{user} has been banned from all **COL** discords")```
events are executed when discord sends you stuff for each action happening
i dont know how command will listen for that
point is, you can like use events to send message to specific channel of server
you can use command to manipulate where it is sent to and what
ofc by database
Is the user in multiple guilds that the bot is in?
yea
right i just don't know how to put that thing into play
which one you dont understand ? database part ?
yes
i know how to use a database in reg python not discord.py
you use json right (bad practice btw, but its fine to use it and you can move afterwards)
yea, but how do I make it only say it one time
i can or use moongo witch i have no idea how to use
sql is easy to learn
for now stick with what you know, so what you do in json is you get server's id as key, and value will be channel's id where it is gonna be sent
in events, you use that guild id to get channel id, then you do bot.get_channel(id) and send it to there
no dont
i learned that just not sql discord.py lol
get out of your comfort zone and learn something good and useful thats how you get better
theres no such thing as sql dpy
sql is a query language
for databases
yes i don't know how to add it into discord.py
!pypi aiosqlite
use this
same way you normally do sql but use async driver instead
sqlite* not sql
sql is a language which is used by many modules like pg and sqlite
when i say sql i generally mean stuff like postgres, sqlite3, mysql and stuff
you should be specific as sql isnt a module
installed
aight
how do i make a welcome config using this
since each module has their own way of storing data i.e pg uses a server unlike sqlite which uses a file
config by?
basically you make table that stores guild id and channel id (and others you want), then in event you use those datas
meaning they can choose there own welcome message and just the default
accross all servers
store the id of the guild and channel and save a record of text
how tho?
and you check the ids and get the text and send the msg
no sotring the stuff
and check rows with the async generator
i know that
which is in the docs
Oh I don't use ; in my sql statements. How bad is it that?
bad they tell you to use it in the docs
no no ; is for ending the statements
its fine, mostly used coz habits and multi statements in one line
i add it so it will show its ending
which always should be done
how do i store the text (store the id of the guild and channel and save a record of text)
@slate swan
use insert
You’re running ahead of yourself waaaayyyy to much
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
and yeah learn sql first
Learn how to implement an async db in your bot first
when you compare things is it better to compare by value like this
reaction.message.id == msg.id
or by object like this
reaction.message == msg
Then learn sql, and move on from there
i learned sql
Well, if you check the docs of certain classes, you can see with == by what they are compared
That’s already great
i know async just not the async db
Is it for consistency and shit or could I have potential bugs?
i didnt check the docs, but those objects are the same thing because == is true
just asking which way is better
I have returned
Well, you can always know. Let’s say messagea == messageb because they have the same ID, then I’d leave it as is and not add .id after
it should always be added or it will be incomplete
Ok thanks
its for this btw
reactionObj, user = await cog.bot.wait_for(
'reaction_add',
timeout = 30.0,
check = lambda reaction, user:
user == ctx.author
and reaction.message == msg
and str(reaction.emoji) in (reactYes, reactNo)
)
That doesn't answer my question. I'm asking this because I need to know if I need to update my code right now or if I can do it later
; is completely optional for single statements
will it do anything no is it bad practice yes should it be done yes
You can always check in the docs/sourcecode
Anyone here have experience with raspberry pi for discord bot Hosting?
If yes what rasperry pi should I buy
I only want to Host one Single bot on one server
And I‘m sorry if this is the Wrong Channel
Thanks for answer. When I decide to get on I will edit everything
vps
Try asking in #microcontrollers
Ok Ghanas
I asked there when I was purchasing my pi
Thanks*
hi, is it okay to share the code I need help with, with an online code pile? Discord doesnt let me to send it here, the whole command that I need help and I guess people wont be that happy if I send a text file they have to download to help
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
anytime btw you can check in sql bolt it will show that the query is incomplete