#discord-bots

1 messages · Page 775 of 1

zealous dagger
#

Here you go

slate swan
#

do you even know what, ./ means and you are loading extensions with self, when you should load them with self.bot/client

slate swan
zealous dagger
#

Ok

zealous dagger
#

Going to eat

slate swan
#

not if they are in the bot class

slate swan
#

exactly :)

maiden fable
#

What did I miss???

slate swan
maiden fable
#

Oh nvm then

#

I have already fought a few times, no more fighting

slate swan
quaint epoch
#

is bot.application_id the bot's user_id?

slate swan
#

is that........ Hunter the great?

maiden fable
maiden fable
quaint epoch
slate swan
quaint epoch
maiden fable
#

application_id is the ID of the application

quaint epoch
slate swan
slate swan
#

How do you guys not get ID autocorrected with I'd

quaint epoch
maiden fable
maiden fable
glass rock
#

uhh any alternatives to somehost? they shut down

slate swan
maiden fable
glass rock
slate swan
maiden fable
#

Rip okay

slate swan
#

or epikhost

quaint epoch
#

y'all hosting?

glass rock
echo wasp
#

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))

slate swan
#

yes cause it's already in 73 guilds tho noone uses it

slate swan
maiden fable
#

its the same

quaint epoch
glass rock
echo wasp
quaint epoch
slate swan
#

should i stick with the old prefix system or move onto using slash commands?

maiden fable
#

Rip gotta reinstall ALL THE MODULES AGAIN

slate swan
#

use both imo

maiden fable
#

AAAAAAAAAAAAAAAAA I HATE THIS

echo wasp
#

now it won't work will it i have to change in ctx.channel.send(random.choice(dad_joke))

slate swan
maiden fable
slate swan
maiden fable
#

I like being single thanks

slate swan
maiden fable
#

Sarthak, u already love Hikari tho ;-;

craggy cloak
#

idk why but my console is getting this error:

Traceback (most recent call last):

quaint epoch
slate swan
slate swan
maiden fable
#

Phew

craggy cloak
maiden fable
#

No please

#

WORST thing that can happen

craggy cloak
maiden fable
#

Repl being Repl

slate swan
quaint epoch
# craggy cloak

uh, do you have any idea of command where this error occurred?

slate swan
#

send the full error , nvm replit

maiden fable
#

Windows 11 do be cool tho ngl

craggy cloak
quaint epoch
slate swan
#

how do i get a user's id using their username?

maiden fable
slate swan
#

!d discord.utils.get

unkempt canyonBOT
#

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...
maiden fable
#

not much

slate swan
#

and use .id on the object u get

slate swan
slate swan
#

i use my desktop for that lol

slate swan
maiden fable
#

Hmm, I just bought a new laptop today, soooo I am just trying it out with stuff haha

slate swan
#

Wait what , you manage to consume 1.03 gbs in a single day

maiden fable
#

No

#

They also include my old projects

quaint epoch
#

what happens if you verify your bot?

maiden fable
#

From my older PC

quaint epoch
#

does it lose all it's intents?

maiden fable
quaint epoch
#

anything else?

maiden fable
slate swan
maiden fable
slate swan
#

member = discord.utils.get(message.guild.members, name='username')
member.id
like this?

quaint epoch
maiden fable
#

LMAO

slate swan
maiden fable
#

My bot got one

slate swan
#

!d discord.Guild.get_member_named

unkempt canyonBOT
#

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.
maiden fable
unkempt canyonBOT
#

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.
slate swan
#

i have a username already

maiden fable
#

Rip

slate swan
#

Ah

#

i want its id

quaint epoch
slate swan
#

i have a username

#

yea just guild.get_member_name(username).id

quaint epoch
#

mhm

slate swan
quaint epoch
#

lmao free nitro link

maiden fable
#

Nitro is bad ngl

quaint epoch
# slate swan trying
@bot.command()
async def foo(ctx, member: str)
  await ctx.send((ctx.guild.get_member_named(member)).id)```
slate swan
#

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

maiden fable
#

right = trig

#

W0W

slate swan
#

yessirrr , i speak a language from atlantis

maiden fable
#

Yea yea Sarthak

#

RIP, tensorflow still not available for Python 3.10

quaint epoch
slate swan
#

okay python hates me

maiden fable
#

Don't u think you cof too much?

wary ice
#

Why ????????

quaint epoch
slate swan
maiden fable
#

python -m pip

quaint epoch
#

bro what is discord-components

slate swan
#

hi guyspithink

slate swan
#

thats what it is

wary ice
wary ice
quaint epoch
maiden fable
slate swan
wary ice
quaint epoch
slate swan
quaint epoch
#

but why would you need to install discord-components?

slate swan
slate swan
#

i was getting bullied by seniors in high school not fun😔

maiden fable
#

And then there's me who doesn't even talk to anyone in school

quaint epoch
slate swan
unkempt canyonBOT
maiden fable
#

There

slate swan
slate swan
quaint epoch
#

!ot

unkempt canyonBOT
maiden fable
# slate swan error😳
def change_pfp():
    print("I will do it, cry about it")
class okimii:
  def __init__(self):
    while True:
      change_pfp()
maiden fable
maiden fable
#

Anyways, not continuing this here, let's go to an OT channel

slate swan
#

I was successful in including hunter in an Ot chat , yaya

quick gust
#

.bm

maiden fable
#

Anything else?

quick gust
#

.bm

slate swan
#

bm a bm

maiden fable
slate swan
#

uwu

#

ok am being annoying now

maiden fable
slate swan
#

TypeError: object of type 'User' has no len()

full lily
#

Can you send a traceback

slate swan
#

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()

full lily
#

What is i

slate swan
#

SavageX#6666

full lily
#

A string?

slate swan
#

object

quaint epoch
full lily
#

That's your issue

quaint epoch
#

it requires a string

slate swan
#

wait i'll check to make sure

quaint epoch
#

you can do str(i) tho

full lily
#

If you alr have the object then what are you trying to do

slate swan
#

User objects are not the same as Member objects.

full lily
#

fair enough

maiden fable
#

Facts, but discord.Member is a subclass of discord.User, so everything that User has, a member will have

slate swan
#

Depending on what they want to do, they might already have the Member object though.

slate swan
#

it is this

quaint epoch
#

if you have the user obj, you don't need to get the member

full lily
#

Surely it the other way around

#

It's*

quaint epoch
#

just await ctx.send(i.id) i being the user object

slate swan
#

If you have a member object you have everything a user object has.

#

oh

quaint epoch
clever orbit
#

can anyone help me with this ?

#

its a music bot

maiden fable
#

Against ToS

slate swan
#

Delete your screenshot please

#

It contains a token :p

maiden fable
#

Lmao

slate swan
#

And yeah, we don't provide support for music bots.

quaint epoch
slate swan
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

clever orbit
#

uff i totaly forgot that

#

gotta rest it asap

quaint epoch
slate swan
quaint epoch
#

!d discord.User

unkempt canyonBOT
#

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.
quaint epoch
slate swan
#

yes

quaint epoch
#

oh yeah!!

slate swan
quaint epoch
#

users won't have roles

#

members will

slate swan
#

soooo

quaint epoch
#

so, py member = await ctx.guild.fetch_member(i.id) member.roles

slate swan
#

perfect

maiden fable
#

Why not use guild.get_member

quaint epoch
#

i never trust the cache

maiden fable
#

No

#

Always prefer cache

quaint epoch
cloud dawn
#

!d disnake.Guild.getch_member

unkempt canyonBOT
#

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.
maiden fable
#

Yes

cloud dawn
#

In between solution

maiden fable
#

getch the best

#

It was my idea to implement that BTW

cloud dawn
#

getch gut

quaint epoch
#

i want getch everything

cloud dawn
quaint epoch
#

otherwise i will not be statisfied

maiden fable
#

Idk cz am half dead

swift imp
#

!d if

unkempt canyonBOT
#
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.
cloud dawn
#

getch doesn't have a lot yet.

quaint epoch
cloud dawn
#
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 
maiden fable
#

Lmao

quaint epoch
#

phew

cloud dawn
#

!d disnake.Guild.get_member_named

unkempt canyonBOT
#

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.
cloud dawn
#

This is kinda a shit function.

quaint epoch
#

discord should remove usernames altogether

#

my name would be 879807617260716143

#

hey there @879807617260716143

cloud dawn
#

Mine would be 169790484594556928 (flex)

quaint epoch
#

how you doing 879807617260716143

#

how are you doing 169790484594556928?

cloud dawn
full lily
quaint epoch
cloud dawn
#

Tue, 24 Aug 2021 19:21:21 UTC pretty accurate.

quaint epoch
cloud dawn
#

opt in he means forced.

full lily
#

Congratulations to you too

tardy lagoon
#

What object does a bot.fetch_user()
Return?

slate swan
#

hello can anyone elaborate my error

#

Not related to bots but yeah

tardy lagoon
#

!d disnake.ext.commands.Bot.fetch_user

unkempt canyonBOT
#

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.
slate swan
#

You're sometimes using space and sometimes using tabs for your indentation.

slate swan
#

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.

potent spear
#

try and see

slate swan
#

Indentation is wrong though

#

You need to align the .set_footer and .send correctly.

potent spear
#

also, comparing the length of both roles is a terrible idea, both could have the same length but different roles

slate swan
#

Yeah because the role added is the booster role

#

Now try another role and you will get an error

potent spear
#

there are other flaws like: you don't have a check what will happen if the after roles are empty etc

slate swan
#

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

potent spear
#

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?"

slate swan
potent spear
#

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

cloud dawn
#

Also ```py
if before.roles != after.roles:

potent spear
#

that's not the best option, since the if statement will be true if a role got removed too, which we don't want

slate swan
#

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)
#

..

manic wing
#

nice code you got there

slate swan
#

yh

manic wing
#

can i join a server your bot is on? pithink

slate swan
#

sure

manic wing
#

just wanna test the eval command 😳

slate swan
#

check ur dms

manic wing
#

SHHHH

keen talon
#

delete it rn

slate swan
#

why

keen talon
# slate swan why

someone might use it to run some code which might harm your computer

#

remove it fast

slate swan
#

oh

#

kk

manic wing
#

😳

slate swan
#

what if it’s on replit

manic wing
#

then happy days

slate swan
#

i host my bot on replit

visual yarrow
#

Erm, hello. What's going on here? 👀

keen talon
#

were you trying to get his token

manic wing
slate swan
#

bruh

manic wing
#

i dont want the token of a bot with 1 server

slate swan
#

not safe

slate swan
manic wing
#

i was just gonna make an example of why you have a private eval

coral flicker
#

That code will allow anyone to hack your bot.

keen talon
slate swan
#

oh kk

#

use jsk tbh

manic wing
coral flicker
#

Even hack your entire system if it's hosted there

manic wing
#

!pypi disnake-debug || use this instead

unkempt canyonBOT
#

A visual debugging extension for disnake discord bots including easy blacklisting, evaluation, echoing and much more!

manic wing
#

great eval and all that

slate swan
#

thats cool

manic wing
slate swan
daring olive
#

can you guys all stop using "stuf" in your messages

keen talon
manic wing
#

every tool one might need

manic wing
slate swan
#

looks good lol

manic wing
#

cheers

#

not finished just yet

slate swan
#

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?

glass tundra
#

Can anyone explain me more about the idea of cogs and why they are better than just discord.ext.commands?

slate swan
#

i figured it out

slate swan
glass tundra
#

hm...

#

I still need understand that thing

#

And need to have some creativity to any project

#

but thx.

slate swan
#

They are magically cool
you just need some basic OOP knowledge to use them!

glass tundra
#

I know oop... I'm just dumb.

manic wing
manic wing
glass tundra
#

So... Is there some discord bot idea thing?

#

Bc I don't have any.

slate swan
glass tundra
slate swan
glass tundra
#

I want something to do T-

#

But most things are too hard or too simple.

manic wing
round robin
#

when setting uptime_start to time.time on ready it doesnt work

#

it says its not defined when i try to use it

final iron
velvet tinsel
#

show the code please pithink

echo wasp
#

how would i config welcome messages the way someone helped me doesn't work

velvet tinsel
echo wasp
velvet tinsel
#

how does it not work?

echo wasp
#

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'```
manic wing
#

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 😳

velvet tinsel
echo wasp
#

that is broken

modern fiber
#

Is this how it should look?

echo wasp
velvet tinsel
#

!d discord.Embed pithink

unkempt canyonBOT
#

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.
modern fiber
#

Ah

#

Should I use this formation?

#

Imma ofc delete those parts.

#

Like channel send, membed.add_roles etc.

echo wasp
#

can someone explain how i fix that error

velvet tinsel
velvet tinsel
echo wasp
velvet tinsel
echo wasp
#

do i need the config module?

velvet tinsel
#

maybe try def __init__(self, client, configs)?

modern fiber
#

so it doesnt be like it changes yk

velvet tinsel
modern fiber
#

It just presses on filled latters

#

.. typing shit

velvet tinsel
#

a mouse cursor?

modern fiber
#

not that

#

lemme show

final iron
modern fiber
#

doesn't let me type

modern fiber
#

when I try to type it changes words already writted

final iron
#

Oh yeah

#

Take a picture of your keyboard

velvet tinsel
#

you mean like it automatically adds stuff you don't want?

echo wasp
velvet tinsel
final iron
final iron
#

I know his issue

modern fiber
#

it doesn't even let me do ctrl + enter

final iron
#

@modern fiber take a picture of your keyboard

velvet tinsel
#

well idk :sadge:

final iron
#

What you use to type

echo wasp
velvet tinsel
#

maybe it's json.loads(db) Maskuh

modern fiber
#

Sexy keyboard ikr

velvet tinsel
final iron
#

While you're in pycharm

#

That should fix your issue

modern fiber
#

yep

#

thanks bud you are legend

final iron
modern fiber
#

that emotionally reminds me of my stepsis

#

she was so good like you

#

until she was found dead under bridge

potent spear
#

that's cursed

modern fiber
#

well rip

potent spear
#

Enough discord for today

modern fiber
#

LOL

velvet tinsel
#

I should leave

#

this conversation had taken a dark turn

modern fiber
#

Is this how it should look? @velvet tinsel

echo wasp
velvet tinsel
#

message?

velvet tinsel
modern fiber
#

it should dm user

velvet tinsel
#

then do member.send

modern fiber
#

10-4

velvet tinsel
#

10-4?

modern fiber
#

.

#

I own a Police Roleplay Server, don't question

#

lol

echo wasp
#

lol

velvet tinsel
#

what's 10-4

slate swan
#

Why checking the server name, which can change. Instead of checking for the server ID which will never change.

velvet tinsel
#

is it a date or a equation

echo wasp
#

i'll aswert

echo wasp
#

well if anyone knows how to make a welcome message configureble per server let me know in #help-potato

slate swan
#

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.

echo wasp
#

nope

slate swan
#

?

echo wasp
#

not at all

slate swan
#

And if you want to keep it that way, which is bad, then you need to put everything in one event.

slate swan
#

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

modern fiber
#

Well, I don't need those, but it gives me an errors bc of them?

potent spear
modern fiber
#

can you send me it?

potent spear
#

\u200b

modern fiber
#

#

nvm I got it

#

ty bud

potent spear
#

gern geschehen

#

a bot will convert this

slate swan
#

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

modern fiber
#

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?

slate swan
#

yea it has administrator

slate swan
#

weird

modern fiber
slate swan
#

Bold or Underlined or Both

modern fiber
#

nvm I got idea

#

ill just do
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

slate swan
#

Sophia. has no roles

slate swan
#

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

slate swan
#

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

velvet tinsel
#

imagine fighting

keen talon
velvet tinsel
slate swan
#

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

modern fiber
#

Guys, this is the code, but this is how it appears. How do I fix those gaps?

potent spear
velvet tinsel
#

why do I keep getting friend requests from random people

#

it's annoying lmfao

slate swan
#

@potent spear

velvet tinsel
modern fiber
#

▬▬▬▬▬▬▬▬▬▬▬

potent spear
velvet tinsel
modern fiber
#

help please

potent spear
#

read please

slate swan
#

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

slate swan
#

and?

potent spear
#

if you can't read that, ig go back to the books

velvet tinsel
slate swan
#

i'll try lol

modern fiber
velvet tinsel
#

I don't get what's hard about that pithink

modern fiber
#

gasps ah

potent spear
#

told you 3 times, won't repeat, sorry

slate swan
modern fiber
potent spear
#

apparently

echo wasp
#

Anyone know how to make a configable welcome message.

velvet tinsel
velvet tinsel
echo wasp
#

I gave you code i know how to make one I need to be able to config it for each server

slate swan
echo wasp
#

Instead of default

velvet tinsel
echo wasp
#

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

sage otter
velvet tinsel
#

maybe store it in a jso- oh yes, tylerr is here, finally I can leave this chat

echo wasp
#

I tried that config had no value so failed

#

I have code and error above somewhere

sage otter
#

If it’s json. Scrap it.

#

You’ll get nowhere good with json data storage.

echo wasp
potent spear
#

nice link to paste xd

echo wasp
#
  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``'
echo wasp
#

@potent spear there I had wrong link

velvet tinsel
#

😳

#

json is an amazing db

wicked atlas
echo wasp
#

And it works

potent spear
echo wasp
#

Though I should go to else

potent spear
#

also, you know what a context manager is?

echo wasp
#

So how do I define it and yup

slate swan
#

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?

potent spear
echo wasp
#

Pseudo?

potent spear
slate swan
echo wasp
#

Lol but I get that

potent spear
#

see? this is understandable in any language, yet isn't actual code

slate swan
slate swan
potent spear
slate swan
echo wasp
potent spear
#

the main problem is his basic python knowledge

slate swan
potent spear
echo wasp
#

Let me get my example that goes well from my bets bot

echo wasp
potent spear
#

I'll just say that the current init isn't good

echo wasp
#

Well I can't find docs on that stuff

#

So that why I ask

potent spear
#

pseudo code is just explaining what you'll try lol

#

pseudo = ~fake

echo wasp
#

Oh

slate swan
slate swan
potent spear
#

the problem is, sometimes I have to explain for what looks like a 3 year old

rocky trench
#
                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'
slate swan
rocky trench
#

its in a cog

manic wing
rocky trench
#
    @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}``')```
echo wasp
#

try must have an except or finally

potent spear
#

that's the first arg you'll need

rocky trench
potent spear
rocky trench
#

alright, time for me to go study cogs by hard

manic wing
#

sniper are you good at dpy/forks

potent spear
#

just OOP in general

potent spear
manic wing
#

how good

echo wasp
#

@potent spear try must have an except or finally

manic wing
#

i want full info no holding back

#

fuck modesty

potent spear
potent spear
manic wing
#

wow ignored smh

potent spear
manic wing
#

what

potent spear
#

lmao

manic wing
#

im asking about you

#

*confusion*

potent spear
#

what I know about dpy?

manic wing
#

yes

#

how good are you at dpy

#

from a scale of dekriel->hunter

potent spear
#

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

manic wing
rocky trench
#

so ctx.message.author is ctx.author

potent spear
manic wing
potent spear
manic wing
#

what

potent spear
manic wing
#

whos the beginner

#

you?

potent spear
slate swan
#
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
final iron
echo wasp
manic wing
#

i was just curious

#

ive given up on jarvide

#

but 🤫

final iron
manic wing
# final iron Why?

people like dekriel add weird ass commands and the ai was never done so its kinda false advertising

potent spear
potent spear
slate swan
#

nope

final iron
#

Add a print statement

#

See if it's being run

slate swan
#

how do i make it actually show the image tho

potent spear
#

you definitely want to start looking into commands asap

slate swan
#

me?

final iron
#

Yes

slate swan
#

its confusing

potent spear
#

it's not a too steep learning curve

#

check out basic bots as example

slate swan
#

i have

final iron
#

Trust me, doing it your way is going to get a lot harder

slate swan
#

and thats what it taught me

potent spear
tidal hawk
#

Where is the best way to store reminders in Discord bot? Json or something else

echo wasp
slate swan
#

it taught me to do it that way

manic wing
#

do you get banned for misinformation

final iron
manic wing
potent spear
# echo wasp explain is the config file the welcome.json?

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?"
...

slate swan
tough mirage
#

what is this red line there for?

slate swan
#

because of 2 awaits?

manic wing
potent spear
manic wing
#

SyntaxError: inconsistent use of tabs and spaces

slate swan
#

oh lol

manic wing
tidal hawk
#

Why not @potent spear

echo wasp
manic wing
#

!e
def x():
print()
def y():
print()
x()
y()

unkempt canyonBOT
#

@manic wing :warning: Your eval job has completed with return code 0.

[No output]
potent spear
manic wing
#

fuck

tidal hawk
#

But you can still use it for reminders, no? xd

slate swan
#
  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}]

echo wasp
final iron
potent spear
rocky trench
#

sniper, I'm struggling with adding buttons in cogs

slate swan
#

thats the response i get from just returning it with nothing

#

how do i access the url

#

["url"] doesnt work

tough mirage
echo wasp
final iron
#

You're missing self

#

It returns a list

tidal hawk
potent spear
# echo wasp when the use %welcome_config

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"
    }
}```
?
slate swan
rocky trench
#

any idea why it doesnt recognize it?

final iron
final iron
#

You need to get the first element of the list

potent spear
potent spear
echo wasp
slate swan
potent spear
slate swan
#

[0][3]?

rocky trench
final iron
rocky trench
#

is it even possible to get buttons and views in cogs?

potent spear
rocky trench
#

I got like 5 of these views

#

all in the cog class

slate swan
potent spear
final iron
#

Have you learnt python yet?

slate swan
#

yes..

final iron
#

You sure?

slate swan
#

just new to discord bots

stray solar
#

Idk if its the wrong chat but.. if someone can help me pls (embed)

final iron
#

This is pretty basic stuff

slate swan
#

ive used apis before and the ways ive tried dont work

stray solar
#

await ctx.send(embed = discord.Embed(description = text))

rocky trench
potent spear
stray solar
#

its worked before but now is not

rocky trench
#

Ik I can be very annoying but I'm having some troubles with putting my code in cogs now

potent spear
echo wasp
potent spear
stray solar
#

so i cant user anymore a selfbot so

potent spear
oblique cobalt
stray solar
#

use**

oblique cobalt
potent spear
slate swan
#

yes

stray solar
oblique cobalt
slate swan
stray solar
#

okok

oblique cobalt
#

i think you want to do requests.get(...).json()

final iron
#

@slate swan Send your code

echo wasp
oblique cobalt
#

then do result[0]

final iron
#

I can help effectively now

oblique cobalt
slate swan
oblique cobalt
potent spear
oblique cobalt
#

so tl dr is, you get context manager in .get or stuff

slate swan
#

oh it works now

#

it didnt work before when i done the exact same thing...

oblique cobalt
#

you either .json() or .text() then do it on it

oblique cobalt
#

.json() ?

slate swan
#

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

oblique cobalt
#

ignore that, its mostly issue that shouldnt be cared about

slate swan
#

im so stupid lmao

oblique cobalt
#

dont worry about that

#

there you go :D

slate swan
#

ty

echo wasp
#

self, ctx?

potent spear
echo wasp
potent spear
#

idk what you're saying, but you can base yourself on your previous commands in a class

echo wasp
unborn raft
#

Discord bot script Python dm ME

oblique cobalt
#

if you are advertising, sorry but nobody here needs prebuilt script

final iron
echo wasp
# oblique cobalt ?

i think he wants us to build him a discord bot script or something like that?

potent spear
#

anyways, if your bot isn't in too many guilds currently, you can do it manually

echo wasp
potent spear
#

since that'll take you not as much time as coding the command xd

wary ice
slate swan
oblique cobalt
potent spear
wary ice
final iron
unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

oblique cobalt
kindred epoch
#

how do i get all the command names from a certain cog?

potent spear
potent spear
oblique cobalt
echo wasp
wary ice
kindred epoch
echo wasp
#

to know what they are

final iron
echo wasp
final iron
kindred epoch
echo wasp
oblique cobalt
final iron
# echo wasp yea

The reason hes getting the commands is probably for his help command...

potent spear
#

very likely

potent spear
#

F

#

you don't want to hardcode

final iron
oblique cobalt
echo wasp
oblique cobalt
#

back then i used to do same, and it was basically pain in ass to modify

echo wasp
final iron
kindred epoch
#

@final iron im trynna copy jarvides help cmd 🤫

kindred epoch
#

kekNoc 🤫

oblique cobalt
# echo wasp never done it before

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

oblique cobalt
#

also if command is group, it has .commands too which goes on same thing as i just said

oblique cobalt
#

i didnt tell you to do it rn so u can do it anytime

echo wasp
#

or leave config

potent spear
#

No need for a command, just use events

echo wasp
#

also is it possible to turn it off from a command

wicked atlas
potent spear
#

Yup

potent spear
echo wasp
#

i use events but not these events

potent spear
echo wasp
#

and barely played db

#

so i don't know how to make stuff for a database

tough mirage
#

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")```
oblique cobalt
# echo wasp explain how because i don't understand what ya mean

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

final iron
tough mirage
#

yea

echo wasp
oblique cobalt
echo wasp
#

i know how to use a database in reg python not discord.py

oblique cobalt
# echo wasp yes

you use json right (bad practice btw, but its fine to use it and you can move afterwards)

tough mirage
echo wasp
slate swan
#

sql is easy to learn

oblique cobalt
slate swan
#

no dont

echo wasp
slate swan
#

get out of your comfort zone and learn something good and useful thats how you get better

slate swan
#

sql is a query language

#

for databases

echo wasp
slate swan
unkempt canyonBOT
slate swan
#

use this

oblique cobalt
slate swan
#

sql is a language which is used by many modules like pg and sqlite

oblique cobalt
slate swan
#

you should be specific as sql isnt a module

echo wasp
oblique cobalt
slate swan
#

very easy

echo wasp
#

how do i make a welcome config using this

slate swan
# oblique cobalt aight

since each module has their own way of storing data i.e pg uses a server unlike sqlite which uses a file

slate swan
oblique cobalt
echo wasp
#

accross all servers

slate swan
slate swan
#

and you check the ids and get the text and send the msg

slate swan
#

that easy

echo wasp
#

no sotring the stuff

slate swan
#

and check rows with the async generator

echo wasp
slate swan
final iron
echo wasp
slate swan
oblique cobalt
final iron
#

So thats why I never add it

slate swan
#

which always should be done

echo wasp
#

how do i store the text (store the id of the guild and channel and save a record of text)

#

@slate swan

slate swan
#

use insert

potent spear
#

You’re running ahead of yourself waaaayyyy to much

slate swan
#
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
#

and yeah learn sql first

potent spear
#

Learn how to implement an async db in your bot first

leaden jasper
#

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
potent spear
#

Then learn sql, and move on from there

echo wasp
potent spear
potent spear
echo wasp
final iron
leaden jasper
#

just asking which way is better

slim ibex
#

I have returned

potent spear
slate swan
leaden jasper
#

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)
      )
final iron
oblique cobalt
slate swan
potent spear
fresh orchid
#

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

final iron
fresh orchid
#

Ok Ghanas

final iron
#

I asked there when I was purchasing my pi

fresh orchid
#

Thanks*

surreal sierra
#

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

unkempt canyonBOT
#

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.

slate swan