#discord-bots

1 messages Ā· Page 713 of 1

dusk pumice
#

ajh

#

yes. Your right

manic wing
#

i realised

#

someone took the time to copy and paste the python bots lol

#

@slate swan

#

you're good at copy and pasting

#

do you write code or is it all copy and paste?

pliant gulch
#

šŸ‘€

slate swan
#

🤭

manic wing
#

😳

crude crater
#

Menace

slate swan
#

to earth

slate swan
#

šŸ‘€

#

🤭

dusk pumice
#

šŸ‘€

crude crater
dusk pumice
#

šŸ™‚

crude crater
#

That takes 0 knowledge and skill and it just flat out lazy

#

If you wanted to do that just use RedBot

manic wing
#

well not lazy tbf

crude crater
#

Actually yeah because you do have to still put together the code

manic wing
#

hats off to kraots because he actually succeeded - copy and pasting the whole docs command is hard

slate swan
crude crater
#

So maybe not lazy but definitely not either skillful either

elder bear
slate swan
#

Soo CutieShrug

manic wing
#

do i have permission to expose you

slate swan
#

About?

manic wing
#

those things

slate swan
#

Sure

#

My bot had slash with autocomplete for both first so idk what you'll expose so gl ASakashrug

manic wing
#

nvm actually

slate swan
#

Welp I'm off to sleep, 5am here salute

crude crater
#

Night 😁

soft narwhal
#

how do i split text

sage otter
#

!d str.split

unkempt canyonBOT
#

str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).

If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.

For example:
shrewd inlet
#

how do i make a command that can give and remove roles but it can detect whether the use has the role or not to determine if it needs to give or remove it?

crude crater
#

I got you

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
crude crater
#

1 sec

shrewd inlet
slate swan
#

!d discord.Role.position to compare role potions

unkempt canyonBOT
#

The position of the role. This number is usually positive. The bottom role has a position of 0.

Warning

Multiple roles can have the same position number. As a consequence of this, comparing via role position is prone to subtle bugs if checking for role hierarchy. The recommended and correct way to compare for roles in the hierarchy is using the comparison operators on the role objects themselves.

slate swan
#

You may like using @has_permissions() check too

shrewd inlet
#

alr

crude crater
#
@bot.command()
@commands.has_permissions(manage_messages = True)
async def addrole(ctx, role: discord.Role, member: discord.Member):
    guild = ctx.guild
    await member.add_roles(role)
    await ctx.send(f'I succesfully added role {role} to {member}')
###########################################################################################################################
    if member == guild.owner:
            return await ctx.send("You can't give roles to the server's owner!")

    elif member.top_role > guild.me.top_role:
            return await ctx.send(f"This member's top role is higher than yours!\n\n{member.top_role.name} <-- {member.mention}'s top role\n\n{ctx.author.top_role.name} <-- Your top role")

    elif member.top_role > ctx.author.top_role or member.top_role == ctx.author.top_role:
            return await ctx.send("You cannot give roles to someone with a higher or equal role to you!")

    elif member.top_role == guild.me.top_role:
            return await ctx.send("This member's top role is equal to your top role!")

    elif role == ctx.author.top_role:
            return await ctx.send("You cannot add a role higher then your top role to yourself!")
quick gust
slate swan
#

wow

crude crater
#
@bot.command()
@commands.has_permissions(manage_messages = True)
async def addrole(ctx, role: discord.Role, member: discord.Member):
    guild = ctx.guild
    await member.add_roles(role)
    await ctx.send(f'I succesfully added role {role} to {member}')
###########################################################################################################################
    if member == guild.owner:
            return await ctx.send("You can't give roles to the server's owner!")

    elif member.top_role > guild.me.top_role:
            return await ctx.send(f"This member's top role is higher than yours!\n\n{member.top_role.name} <-- {member.mention}'s top role\n\n{ctx.author.top_role.name} <-- Your top role")

    elif member.top_role > ctx.author.top_role or member.top_role == ctx.author.top_role:
            return await ctx.send("You cannot give roles to someone with a higher or equal role to you!")

    elif member.top_role == guild.me.top_role:
            return await ctx.send("This member's top role is equal to your top role!")

    elif role == ctx.author.top_role:
            return await ctx.send("You cannot add a role higher then your top role to yourself!")
###########################################################################################################################




@bot.command()
@commands.has_permissions(manage_messages = True)
async def removerole(ctx, role: discord.Role, user: discord.Member):
    await user.remove_roles(role)
    await ctx.send(f'I succesfully removed role {role} to {user}')
quick gust
#

brother

slate swan
#

Bro

crude crater
#

That's with the removerole too

quick gust
#

nvm...

crude crater
crude crater
quick gust
#

these kinda guys spoonfeed and expect to get spoonfeed lol

crude crater
#

Not really

quick gust
#

didn't ask

slate swan
#

why give him the full code

#

I doubt the 1st and 2nd elif statement tho

shrewd inlet
slate swan
#

You cannot check > or < with roles

shrewd inlet
#

i want to do it with just one command

crude crater
#

I'm just here to help, if he would've specified he doesn't want code then I wouldn't of had sent it+he literally asked how to make the code

quick gust
crude crater
#

It has to be 2

shrewd inlet
crude crater
#

It's 2 different actions

shrewd inlet
shrewd inlet
#

i’ve seen bots that can do it

crude crater
#

Lmao bruh

slate swan
#

imagine spoofeeding and failing

shrewd inlet
shrewd inlet
quick gust
#

so u want to add a role in one command and remove the role in another?

shrewd inlet
quick gust
#

ah I see what u mean

#

so what we do is

slate swan
#

check if the role is in member.roles, if not use member.add_role, if it is in their roles, use member.remove_roles

slate swan
quick gust
#

first get the role using the ID
role = ctx.guild.get_role(id)

now check if role is in member.roles, if it isn't then add the role. And if it is then remove the role

slate swan
quick gust
#

if that method exists

#

not sure

quick gust
slate swan
#

u wouldn’t need to get the role if u use role: discord.Role in the args

slate swan
#

yeah

pliant gulch
#

Internally it's still grabbing the role from cache otherwise making an API call

#

You can't just pop a Role out of thin air

slate swan
#

i didn’t say u could

pliant gulch
#

u wouldn’t need to get the role if u use role: discord.Role in the args

slate swan
#

yea referring to him using guild.get_role

quick gust
# shrewd inlet where do i put this

well u need to make it yourself, u won't get spoonfeed with the exact thing here. I told u the methods and how you should do it so use that

slate swan
#

but if you hardcode the role object with get_role it would be limited to a single role
Using it as a arg to get from user will allow you to use any role

quick gust
shrewd inlet
#

oh yeah mb

soft narwhal
#

how do i split text
so like


Output: You said hello and lol```
quick gust
slate swan
#

!e print("this is :: the text".split("::"))

soft narwhal
quick gust
#

np

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

['this is  ', ' the text']
soft narwhal
slate swan
#

because it’s a list

#

It's a list , you splitted the string into a list of strings divided by ::

soft narwhal
#

alright ty

#

how do i do it with the message sent by the user

plain cloud
#

message.content.split(ā€œ::ā€)

slate swan
#

first thing , if you are doing it with a command
Get off on_message events

#

else , what popleoma said would work for u

plain cloud
#

Don’t necessarily need the .lower() it’s just habit

ebon island
#

Trying to troubleshoot a tricky interaction between a class method in a discord.py cog and a dataclass attribute

So basically, what happens is as follows:

Async task is created as an object and stored to Server.task

when the final condition is reached the task instead calls itself (recursive) but this is called with self.take_turn() in this case

The problem is, the self.take_turn() is saved to the dataclass and when it tries to call self.take_turn() it looks for the take_turn() method in the Server dataclass object rather than in the cog mentioned above and thus cannot find it

How do I work around this?

plain cloud
#

pydis_nope_py alas this is beyond my reading comprehension

ebon island
#

I'll try to explain it better

plain cloud
ebon island
#

I have a cog which has a take_turn() method, it has a recursive call when it ends the iteration

    async def take_turn(self, server):
        for num in range(server.word_count):
            await self.make_message(server, num)
        else:
            await self.pass_the_mic(server)
            server.task = asyncio.create_task(self.take_turn(server))

and I have a dataclass Server object which has that task written to it by server.task in the above code

but the problem is when it tries to call itself and feeds in the self.take_turn(server) evidently it is calling the take_turn() method from the dataclass itself and not from the cog as desired so it is unable to find the method

#

consider "server" in the above to be an dataclass object which has the attributes word_count and task

#

so when it does server.task = asyncio.create_task(self.take_turn(server))

it is calling the self.take_turn(server) recursively

#

so it writes the task to call the self.take_turn() to the server.task attribute

#

but the server object does not have a take_turn method, only the cog does, and when it tries to call the take_turn() method from within the dataclass object it doesn't find the take_turn method and throws an exception

pliant gulch
#

Sounds like you should use functools.partial and pass that instead

#

!d functools.partial

unkempt canyonBOT
#

functools.partial(func, /, *args, **keywords)```
Return a new [partial object](https://docs.python.org/3/library/functools.html#partial-objects) which when called will behave like *func* called with the positional arguments *args* and keyword arguments *keywords*. If more arguments are supplied to the call, they are appended to *args*. If additional keyword arguments are supplied, they extend and override *keywords*. Roughly equivalent to:

```py
def partial(func, /, *args, **keywords):
    def newfunc(*fargs, **fkeywords):
        newkeywords = {**keywords, **fkeywords}
        return func(*args, *fargs, **newkeywords)
    newfunc.func = func
    newfunc.args = args
    newfunc.keywords = keywords
    return newfunc
ebon island
#

what is that?

pliant gulch
#

With this you can 100% make sure that you call the func with the self representing the Cog

ebon island
#

I am going to have to watch a video on that package

ebon island
#

I really appreciate your help earlier by the way suggesting to make the Helper function the import for the other cogs

#

that was an excellent suggestion and you sir are a gentleman and a scholar

plain cloud
# soft narwhal no

To retrieve items from a list you do
listname[where the item is]

for example

ebon island
#

the stuff in the [] is an integer btw necessarily, it is the index of the item

#

starting with 0

plain cloud
#

!e
myList = [ā€œbaconā€, ā€œcheeseā€, ā€œbobā€]
myList[1]

manic wing
#

!d discord

unkempt canyonBOT
#

To work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

It's " , not ``

pliant gulch
#

Mobile moment

plain cloud
#

Mobile moment indeed 😌

plain cloud
slate swan
#

Indeed

shrewd inlet
#

what’s the variable for the user that did the command

#

like i want it to mention the user that did the command

slate swan
shrewd inlet
plain cloud
#

message.author ? this what I’ve been using

shrewd inlet
slate swan
shrewd inlet
#

thx

slate swan
#

yw

muted lynx
#

is there any way I can choose a random channel from a guilds channels

sage otter
#

random.choice(Guild.channels)

#

Ez

shrewd inlet
muted lynx
#

will that have the id or name

plain cloud
slate swan
slate swan
plain cloud
#

oh Nevermind I see the beginning now

shrewd inlet
#

oh that’s right

slate swan
#

lol

plain cloud
#

my bad ducky_australia

sage otter
slate swan
#

how do i make my bot record like mee6?

#

i feel like thatd be complicated

#

to do

#

use a database

shrewd inlet
#
@bot.command()
@commands.has_role(924841723753021490)
async def role(ctx, user: discord.Member, role: discord.Role):
   embed = discord.Embed(description=f"(ctx.author.mention): Added {role.mention} to {user.mention}",color=0x2f3136)
   await user.add_roles(role)
   await ctx.send(embed=embed)
#

what did i mess up here? :P

slate swan
#

ur using ( instead of {

quick gust
#

yeah it should be inside curly brackets

shrewd inlet
#

ohh

slate swan
sage otter
slate swan
#

Also , just a suggestion
Add the role before sending the message

slate swan
slate swan
#

Oh sorry yeah

quick gust
#

...

slate swan
#

Nvm me

sage otter
#

Doubtful. He literally means record. Mee6 while in vc can record audio.

quick gust
#

kekw np

sage otter
#

And save it and play it back.

heavy folio
#

member and user is different

sage otter
#

I never said it did oogh

slate swan
#

mhm , they would have to do some api stuff themself right?

#

Or , nextcord is implementing it iirc

pliant gulch
#

It was java or js that had voice receive

#

No python wrapper has fully implemented voice receive

slate swan
#

Javascript has it already

#

since djs v12 ig

boreal ravine
shrewd inlet
#
@bot.command()
async def role(ctx, user: discord.Member, role: discord.Role):
   embed = discord.Embed(description=f"![approved](https://cdn.discordapp.com/emojis/925244874750566432.webp?size=128 "approved") {ctx.author.mention}: Added {role.mention} to {user.mention}",color=0x2f3136)
   await user.add_roles(role)
   await ctx.send(embed=embed)

@bot.command()
async def removerole(ctx, user: discord.Member, role: discord.Role):
   embed = discord.Embed(description=f" ![deny](https://cdn.discordapp.com/emojis/925244906241400862.webp?size=128 "deny"){ctx.author.mention}: Removed {role.mention} from {user.mention}",color=0x2f3136)
   await user.remove_roles(role)
   await ctx.send(embed=embed)
#

for some reason it can only give them one role

#

but it can’t give them other roles

pliant gulch
shrewd inlet
boreal ravine
manic wing
shrewd inlet
manic wing
#

what

shrewd inlet
#

but if i try to give them some other role it doesn’t work

quick gust
#

in a single try or multiple tries?

boreal ravine
shrewd inlet
#

idk how to explain it

shrewd inlet
boreal ravine
#

role hiearchy

#

ur bot role must be above the role u wanna give

shrewd inlet
slate swan
#

Any errors?

quick gust
shrewd inlet
quick gust
#

well the code seems completely fine to me

shrewd inlet
#

there’s an example

quick gust
#

but I could be missing something so wait for someone else to hopefully respond with an answer

quick gust
#

use a * operator before role arg

#

since its only taking north as the role

slate swan
#

or just use id or mention

quick gust
#

which probs doesnt exist

quick gust
slate swan
#

Using ,role "north america" is also a solution

sweet geyser
#

:lemonshake:

shrewd inlet
shrewd inlet
quick gust
#

alright cool

slate swan
#

How do I add an environment variable using python ? ```py
os.environ["name"] = "value"

#

or is there some other method..

muted lynx
#

yes

slate swan
#

I want to change Jishaku settings , and it uses env

muted lynx
#

that works

slate swan
#

Alright ty

muted lynx
#

also

#

I sent you something in dms

slate swan
#

how to fix this get_bank_data being underlined

#

making a economy bot

manic wing
slate swan
#

no i do not

#

prob would be a good idea to make one

manic wing
#

possibly pithink

#

or

#

make open_account return account data and make new account data if the data doesn’t exist

#

somethings wrong with your syntax highlighting wtf

#

can you show that whole file? async and await arent highlighted which is weird

boreal ravine
frail notch
#

Ok this is very general but can anyone point me into something to explain to me how restorecord bot works? Like how it gets the permission from users to make them rejoin a server

pliant gulch
#

Or at least I'm assuming so, as that's the only way to make a user join a guild

frail notch
pliant gulch
#

No clue of any

slate swan
#

what is @staticmethod for?

pliant gulch
#

Regular methods have self as the first parameter, there for needs to be called with an instantiated class

#

Staticmethods don't

slate swan
#

ah i see

#

do i need it for a class that doesnt need an init?

pliant gulch
#

You don't need it for a class that doesn't have a constructor

#

Either way if your class didn't have a constructor it would use the default one

#

!e ```py
class Foo:
pass

print(Foo)
print(Foo())

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

001 | <class '__main__.Foo'>
002 | <__main__.Foo object at 0x7f143385d510>
slate swan
#

and wdym by uninstantiated classes

pliant gulch
#

The first print shows an uninstantiated class

#

The second one is instantiated

slate swan
#

what does that word mean?

pliant gulch
#

If it's constructed or not basically

slate swan
#

ah i see

dreamy sluice
#

Anyone know how to connect a bot to a voice channel the user is in?
I tried this

@bot.command() 
async def joinvc(ctx):
  channel = ctx.author.voice.channel
  await channel.connect()

But it gives this error

Ignoring exception in command joinvc:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 27, in joinvc
    await channel.connect()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1277, in connect
    voice = cls(client, self)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 199, in __init__
    raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/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: RuntimeError: PyNaCl library needed in order to use voice
pliant gulch
#

!e ```py
class A:
@staticmethod
def foo() -> None:
print("bar")

A.foo()
A().foo()

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

001 | bar
002 | bar
slate swan
#

ahhh i seepithink

dreamy sluice
slate swan
#

so what does the decorator do? exactly

pliant gulch
#

Turn the method it decorates into a static method

#

kek

visual island
#

simple. You don't need self, use staticmethod

slate swan
#

so it makes it staticpithink

pliant gulch
#

Yep a static method

slate swan
#

ahhh makes more sense thank you guyspithink

#

now i have to add it to 1000functions pithink

#

im not joking btw*

#

my code has 1000functionsšŸ˜” 😭

pliant gulch
#

Are you just using a class as a namespace?

slate swan
#

you mean to organize it all?

pliant gulch
#

Sure

slate swan
#

yes i am

pliant gulch
#

Like Class.foo() instead of foo()

slate swan
#

im adding all of those functions to the class yes i am

pliant gulch
#

That's gonna be a pain

slate swan
#

yes

pliant gulch
#

If your only using the class as a namespace I don't really see the point in that

pliant gulch
#

Although sadly, python has no namespace per-say like C++

slate swan
#

makes it cleaner

#

anyways gtg add the decorator to 1000functions no jokepithink

pliant gulch
#

Idk, this seems pretty redundant for OOP here, functional programming will do just fine

slate swan
#

šŸ¤·ā€ā™‚ļø

slate swan
tawny knoll
#

is there any built in listener for "on_command_use" or something of that nature? looking to track what commands get used the most / who's using them and unsure how

visual island
#

on_command event

tawny knoll
quasi wharf
#

discordpy is no longer in use right?

#

and disnake is stable to be used?

slate swan
#

discord.py can be used but it will break in some time if discord changes something ( for verified bots)
and yea disnake is one of the stable forks

slate swan
#

alright alright

slate swan
#

is it the same way to install packages ? on repl it

#

my firs ttime using it

slate swan
#

yea 😭

#

yes

#

and did you made that?

#

yes

#

its from my code i am just trying it on repl it

#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

slate swan
#

many libs that are blocking your code

#

and

#

!pep8 read thispithink

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
• PEP 8 document
• Our PEP 8 song! :notes:

slate swan
#

okay

#

whats this mean?

#

invalid syntax

#

hmm.

#

its not correct lol

#

you dont pip install in a file

#

you do it in the terminal

#

ah

#

i see

#

thanks!

spark plaza
#

hi

maiden fable
spark plaza
#

how to use tthe bot?

slate swan
#

wym?

#

I dont like repl it

#

screw that

#

imma stick with visual studio code

slate swan
# slate swan is it the same way to install packages ? on repl it

all the errors:
no need to import embeds,member,color member again error handlers,taks and commands again,client,json again,schedule 2 times,time,dont do wildcards imports to follow pep8 no need to import weebhook and requestweebhookadapter,use asyncpraw,dont import ext commands 3 times,no need to import a function from random

#

oh :0

slate swan
spark plaza
#

lol

#

i mean the prefix

slate swan
#

of which bot?

#

@unkempt canyon prefix?

spark plaza
#

nothing i got it no worries

#

yup

slate swan
#

its !

spark plaza
#

i got it

slate swan
#

lol

spark plaza
#

and btw

#

why is !e used to print

#

here

maiden fable
#

It's eval

slate swan
#

its used to evaluating code

spark plaza
#

evaluate?

maiden fable
#

It's used to run a Python code

spark plaza
#

ok

#

thx

slate swan
#

!e

print("hi i evaluate code")
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

hi i evaluate code
spark plaza
#

#bot-commands

maiden fable
#

Lol

slate swan
maiden fable
#

Nvm, he's doing something in there

#

Seems like he wanted to find that channel and go there

spark plaza
#

what

#

yes

#

too many channels

maiden fable
#

Ignore what okimii said, we took the wrong meaning before @spark plaza

spark plaza
#

no worries

slate swan
maiden fable
#

Lmao same

#

But then I saw he was doing things in #bot-commands so I clarified

slate swan
#

lol

tough lance
#

Hllo

slate swan
#

no need for channel

#

you can just do

await ctx.send()
#

show your command

#

nvm

#

not really but dont convert bet to an int

#

just tylehint it

#

!pep 484 read this

unkempt canyonBOT
#
**PEP 484 - Type Hints**
Status

Provisional

Python-Version

3.5

Created

29-Sep-2014

Type

Standards Track

slate swan
#

type hint it

#

so python gets a hint that the argument is a int

#

bet: int

quick gust
#

u could use .lower() ig

slate swan
#

what does -> after function declaration do lol

#

saw something like this the other day

def a(b) -> int:
  pass
visual island
#

return type

slate swan
#

!e py def fun() -> int: return "string" fun()

unkempt canyonBOT
#

@slate swan :warning: Your eval job has completed with return code 0.

[No output]
slate swan
#

dont think so

#

so unless the return type is the one mentioned, it'll return None

bronze pilot
#

What's the error, if you don't mind me asking?

visual island
velvet tinsel
#

morning

#

im gonna go sleep

bronze pilot
#

I would've thought that the problem is that you didn't use an f"" string or .format(), so it shouldn't show an error

bronze pilot
#

Try that, I feel like it should fix it. Maybe Python doesn't like the characters { and } in a basic string

#

From what I remember they're always highlighted differently from the string in VSCode, so there's some significance

#

Yeah, I thought so šŸ™‚

slate swan
#

missing a colon

velvet tinsel
#

uhhh why....why....?

bronze pilot
#

do ```python
f"Wrong Argument! It should be py {Heads/Tails} {Number}"

velvet tinsel
#

is heads a str?

slate swan
bronze pilot
#

Yep

velvet tinsel
slate swan
velvet tinsel
#

or an int? cause you're basically dividing it

slate swan
#

then what do you want to do lol

velvet tinsel
#

"{heads}/{tails}"

slate swan
bronze pilot
#

The f doesn't show up, it's just the correct syntax for string formatting

velvet tinsel
#

then do {heads}/{tails}

#

{heads/tails} is basically dividing it

visual island
# slate swan alright

also it's useful for libraries for the users to know what the function they're using returns. For example this function returns str

velvet tinsel
#

and if it's a str you can't divide it

bronze pilot
#

If you are using string formatting, heads and tails are variables

#

What would the value of them be..?

velvet tinsel
#

So you can't just divide them

bronze pilot
#

I can;t imagine you couldn't just remove the {}

#

You could, if they are integers

velvet tinsel
#

do they want it to be divided?

bronze pilot
#

But in this case it's a bit confusing

velvet tinsel
bronze pilot
#

I don't think so, but I don't know

#

I don;'t know hahaha

#

For example if they try

#

!e ```python
print(f"Wrong Argument! It should be py {Heads/Tails} {Number}")

unkempt canyonBOT
#

@bronze pilot :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'Heads' is not defined
bronze pilot
#

yeah

velvet tinsel
#

I'd go for {heads}/{tails}

bronze pilot
#

Oh I get what you mean

velvet tinsel
#

and it's saying it?

bronze pilot
#

Try putting a backslash before the "special" characters? (;ike { and })

velvet tinsel
#

is heads an int?

bronze pilot
#

It's a common feature in most programming languages, should work in Python

velvet tinsel
#

what do you want it to say?

bronze pilot
#

worth a shot

velvet tinsel
#

give us an example

bronze pilot
#

No dude, listen

velvet tinsel
slate swan
#

what do you want it to say

bronze pilot
#

No seriously, try ```python
await ctx.send('Wrong Argument! It should be py {Heads/Tails} {Number}')

velvet tinsel
#

oh, so remove the {}

bronze pilot
#

If it works then it works, if it doesnt then i have another idea

slate swan
#

it's not a special character without the f

velvet tinsel
#

also

#

you can lose the { you dont need it

#

also whats Number

bronze pilot
#

Try re.escape(your_string) if that doesnt work

slate swan
#

what does he want to do
I don't get it

#

kinda confusing

velvet tinsel
bronze pilot
#

NEITHER DO I

#

🄲

velvet tinsel
#

im confused af

velvet tinsel
quick gust
velvet tinsel
bronze pilot
#

Im confused about *

quick gust
#

it's the argument they want the user to input

#

the money amount

velvet tinsel
#

I know heads tails

I mean if it's a str then you can lose the {

#

**test** test

bronze pilot
#

No no, I meant it as "everything" just a joke

slate swan
zealous dagger
#

Someone please come and help me in

slate swan
#

ask

zealous dagger
#

@help-chili

velvet tinsel
#

you can do await ctx.send("wrong argument! it should be py Heads/tails") but Im not sure about why you need the bet amount in there

#

well, they know what they betted

#

oh

#

then it should be await ctx.send('Wrong argument! It should be py {random.choice["heads", "tails"]} {bet}')

heavy folio
#

why ctx.channel.send

#

ye idt ctx.channel.send is a thing

#

nvm it is

ionic granite
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

bronze pilot
#

Idk why it's a thing

#

is there any case where ctx.channel.send() is preferred over just ctx.send()?

small igloo
#
await message.add_reaction("āœ…")
await message.add_reaction("āŒ")
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
bronze pilot
#

watch

#

\āœ…

#

Ah you are using same ones

small igloo
# velvet tinsel full error
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 244, in gamble
    await message.add_reaction("?")
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\message.py", line 1223, in add_reaction
    await self._state.http.add_reaction(self.channel.id, self.id, emoji)
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\thosiba\PycharmProjects\main.py\main.py", line 28, in on_command_error
    raise error
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thosiba\Downloads\d-bots\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thosiba\Downloads\d-bots\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: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
velvet tinsel
#

wait

#

I think I know why

small igloo
quick gust
#

he is using the unicode emojis i think

velvet tinsel
#

iirc there is like an ID thing for emojis

velvet tinsel
#

what

bronze pilot
#

It looks to be the same ones from discord

velvet tinsel
#

help

bronze pilot
#

When I started with Discord bots I saw a tutorial saying put a backslash before any emoji and you can copy it like text

quick gust
velvet tinsel
#

what are the emoji ID things called again

bronze pilot
#

Done that for the tick and cross emojis and it worked

quick gust
#

wha

velvet tinsel
#

the ones that look like <1398479743121312112>

small igloo
velvet tinsel
quick gust
velvet tinsel
bronze pilot
#

unicode or not, it worked for me

velvet tinsel
#

I'll go sleep now

small igloo
bronze pilot
#

I'm going to cause more trouble than not

small igloo
bronze pilot
#

Going away as well bye guys, happy new year when it comes

small igloo
small igloo
slate swan
#

Good afternoon ladies and gentleman.

#
m = await ctx.channel.fetch_message(some.message.id)
for r in m.reactions:
  if r.emoji == "šŸŽ‰":
    await ctx.send([users.name for users in r.users])
#

TypeError: 'method' object is not iterable

#

It gave me this error. Someone help me to fix it.

velvet tinsel
#

On the morning

slate swan
#

@velvet tinsel Help me

small igloo
velvet tinsel
small igloo
small igloo
slate swan
slate swan
small igloo
velvet tinsel
#

I need the entire error

small igloo
velvet tinsel
#

Also why make a for loop

slate swan
#
Traceback (most recent call last):
  File "C:\Users\LeeHaoMingDennis\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\LeeHaoMingDennis\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\LeeHaoMingDennis\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'method' object is not iterable
slate swan
velvet tinsel
#

!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...
velvet tinsel
#

Python acting up

velvet tinsel
slate swan
#

How?

#

Any examples please 🄺

velvet tinsel
#

Then print msg.reactions

shadow wraith
#

hi dekriel

#

x]

slate swan
shadow wraith
#

can someone ask a not-hard question related to discord.py or disnake im bored

#

excluding HelloHello's

shadow wraith
#

if you don't know what disnake is, just an active fork of discord.py which is maintained since discord.py is no longer getting maintained

slate swan
#

Help me

shadow wraith
#

for 🄚zample

maiden fable
shadow wraith
slate swan
#

I'm not

#

I'm in a command

shadow wraith
#

šŸ’€

slate swan
shadow wraith
#

fuck i didn't read it ur using ctx

#

🤨

slate swan
#

What

full valley
#
# Handling report if gameid is not valid
@report.error
async def report_error(ctx, error):
    if isinstance(error, KeyError):
        ...

How can I handle key errors from commands?

shadow wraith
full valley
#

Thats when invoking the command

#

I know why its an error, but just want to do x when it happens

slate swan
#

@velvet tinsel @maiden fable Um?

shadow wraith
#

wait isinstance in discord.py not handle default errors in python

small igloo
full valley
slate swan
#

there's an on_error event too

maiden fable
#

!d discord.TextChannel.fetch_message

unkempt canyonBOT
#

await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
shadow wraith
#

ig so

#

oh discord lagged

slate swan
slate swan
#

How

#

Do I use it

boreal ravine
#

by calling it

visual island
#
async for user in Reaction.users():
  # do stuff
#

or .flatten() it

#

to get a list

slate swan
#

How do I flatten it

#

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

#

@visual island

glacial kernel
#

How do I keep my bot online at all times?

loud junco
#

is this how it works?

#

first time using try except

slate swan
loud junco
velvet tinsel
slate swan
#

Txt/json is the best

velvet tinsel
loud junco
velvet tinsel
slate swan
velvet tinsel
velvet tinsel
loud junco
#

ok

loud junco
heavy folio
#

um what

loud junco
#

ez to learn
ez to use
even dumb pepo like me know how to use

glacial kernel
heavy folio
loud junco
#

like heroku or replit

velvet tinsel
glacial kernel
#

Ok

loud junco
#

like this one

@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    await ctx.send(f'Dont spam :/ try**{round(error.retry_after, 2)}** seconds')
  else:
    raise error
```?
loud junco
#

...

velvet tinsel
loud junco
#

that is me

heavy folio
#

nvm

loud junco
#

im not spoonfeeding myself

heavy folio
#

head smack

velvet tinsel
#

They just copy and pasted the error handler

heavy folio
#

yeah that'd work

velvet tinsel
loud junco
heavy folio
#

NO wait

loud junco
#

its in my code

velvet tinsel
#

Cool

loud junco
#

but im facing issues

heavy folio
#

that'd be a global error handler

velvet tinsel
#

Like what

loud junco
heavy folio
#

if you only want it for your command, use @funcname.error

loud junco
velvet tinsel
velvet tinsel
#

Unless you want different responses for different errors xD

loud junco
#

like if u are hunting in cd then it will tell

you hunted too much try in another blah blah sec

#

if u are fishing in cd then it will tell

you fished too much try in another blah blah sec

velvet tinsel
loud junco
#

eh

velvet tinsel
#

Yeah

loud junco
#

what is the command for the api

velvet tinsel
loud junco
#

;-;

heavy folio
loud junco
#

nothing

velvet tinsel
loud junco
#

@hoary vale.error
what i do here

heavy folio
#

oh

loud junco
#

wtf

heavy folio
#

it's the same

velvet tinsel
#

Bro

velvet tinsel
#

What don’t you get

loud junco
#

BRUH

velvet tinsel
#

It’s simple

loud junco
#

@ hunt

velvet tinsel
unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

loud junco
#

oo ya

#

i forgot

velvet tinsel
#

Bro

#

Change your name @hoary vale

loud junco
velvet tinsel
loud junco
#

ok

velvet tinsel
#

With an @

velvet tinsel
unkempt canyonBOT
maiden fable
#

Imagine hunting without Hunter

maiden fable
velvet tinsel
#

I miss you 😩

maiden fable
#

Oh code hunting... Nvm

loud junco
#

...

velvet tinsel
#

I wish you could be here more often so I can go to sleep

maiden fable
#

I do that only at night most of the times, so, uhhh

maiden fable
velvet tinsel
#

Rather than people pinging me at 1 AM

maiden fable
#

@velvet tinsel

velvet tinsel
velvet tinsel
unkempt canyonBOT
loud junco
#
    seccd = round(name.get_cooldown_retry_after(ctx))
    mincd = 0
    hrcd = 0
    rseccd = 0
    rmincd = 0

    if seccd > 59:
      rseccd = seccd % 60
      mincd = (seccd - rseccd) / 60

    elif mincd > 59:
      rmincd = mincd % 60
      hrcd = (mincd - rmincd) / 60

    if rseccd == 0 and rmincd == 0 and hrcd == 0:
      res += f':white_check_mark: {name}\n' 
    else:
      res += f':spinning_clock: {name}: **{hrcd}h {rmincd}m {rseccd}s**\n'
#

whats wrong here

slate swan
#

How do i get the context of the first message in a channel?

#

!d discord.ext.commands.Bot.get_context

unkempt canyonBOT
#

await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
slate swan
#

fetching the first message in the channel would be a hard task

#

await new_channel.history(oldest_first=True, limit=1).flatten() could work

#

sure

#

just get that message object , and use get_context to get the context

#

thank you for the help

modern fiber
#

I need help setting up a code. I have the code finished, just not sure how to make it work. Can somebody help me?

slate swan
#

AttributeError: 'HistoryIterator' object has no attribute 'content' sadge

loud junco
#

u wanna host the bot isit

modern fiber
#

can I show you?

#

This the command I want

slate swan
#

RoWifi

modern fiber
#

And this is the code I got.

#

bruh?

loud junco
#

u wanna make embed?

slate swan
modern fiber
loud junco
#

????

modern fiber
loud junco
#

oo

modern fiber
#

bruh

#

you understand now?

loud junco
#

what are u trying to ask

#

u already have the code

#

just paste that into ur bot's code

modern fiber
#

I did

loud junco
#

and run it

modern fiber
#

but it isnt working?

#

I need like to insert some cookie or smth?

loud junco
#

whats the error

#

idk json

slate swan
slate swan
modern fiber
slate swan
#

and ctx should be cts

loud junco
#

just logic problem

modern fiber
slate swan
#

sus

#

but ctx should be cts

loud junco
#

its ctx bro

slate swan
#

or cts ctx

quick gust
modern fiber
slate swan
#

dskjahdkahkjad

#

pip3 install requests

modern fiber
#

pip install requests

quick gust
#

tfw when u just copy code without knowing what it does

slate swan
#

just dont use requests

loud junco
slate swan
#

use aiohttp....

loud junco
#

but its not working

quick gust
loud junco
slate swan
slate swan
#

and code

#

AttributeError: 'HistoryIterator' object has no attribute 'content'

#
  overwrites = {
    ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
    ctx.author: discord.PermissionOverwrite(view_channel=True)
  }
  new_channel = await ctx.guild.create_text_channel(f"welcome-{ctx.author.name}", category=new_member_cat, overwrites=overwrites)
  await new_channel.send(ctx.author.id)
  await new_channel.send(message_struct)
  first_message = new_channel.history(limit=1, oldest_first=True)
  first_ctx = await bot.get_context(first_message)
  print(first_ctx)```
heavy folio
#

it's a blocking library

modern fiber
#

Hm-

frail notch
#

do y'all know any alternatives to restorecord

slate swan
#

i forgor

heavy folio
slate swan
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
modern fiber
#

I need a command that gives the user role he has in a roblox group.
Also, if possible, for it to change his nickname. Actually, to add (Rank) @amber beacon to his nickname!

Here is the current code I got.

groupID = 9247039
robloxCookie = ""
xsrf = ""

@bot.command()
async def promote(cts, user: int, role: int):
    with requests.Session() as group:
        # get xsrf, its needed.
        group.cookies['.ROBLOSECURITY'] = robloxCookie
        xsrff = group.post('https://friends.roblox.com/v1/users/1/request-friendship')
        xsrf = xsrff.headers['x-csrf-token']
        # Promote user!
        url = f"https://groups.roblox.com/v1/groups/{groupId}/users/{user}"
        group.headers["Content-Type"] = "application/json"
        data = {"roleID": role}
        res = group.post(url)
        await ctx.send(res.json())
#

If you could help me, would be appreciated a lot.

#

Anybody? -_-

shadow wraith
#
@bot.command(aliases=["wyr"])
@commands.guild_only()
async def wouldyourather(ctx):
    async with aiohttp.ClientSession() as session:
        request = await session.get("https://would-you-rather-api.abaanshanid.repl.co")
        reqjson = request.json()

    embed = disnake.Embed(
        title="Would you rather...", description=reqjson["data"], color=0x7194FF
    )
    embed.set_footer("ID: " + reqjson["id"])
    await ctx.reply(embed=embed)

this doesn't work and always says courotine obj not suscriptable

#

there's no full traceback since i also have a on_command_error event which shows it, i just got a enable tracemalloc

#

wait nvm i figured it out

small igloo
#

!charinfo āœ…

unkempt canyonBOT
small igloo
#

!charinfo āŒ

unkempt canyonBOT
quick gust
#

@small igloo #bot-commands

small igloo
graceful mulch
#

I want help

#

it is urgent

boreal ravine
#

how do I view my bots cached users/members

graceful mulch
#

idk

shadow wraith
slate swan
#

gr8

quick gust
#

sounds kinda cocky

visual island
slate swan
#

remove the invite , it has your token

graceful mulch
boreal ravine
slate swan
#

you can just provide the piece of code and the error here for people to help

graceful mulch
#

no error

slate swan
#

or if its too long use a pastebin

graceful mulch
#

it isssssss too different

#

no idea nothing

#

i am mad , now

slate swan
#

code?

#

!paste

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.

graceful mulch
#

but i am smart too

#

i had a back up

#

now i will have to spend

#

hours working on it

#

HUH

#

it worked but I had to make a new

quick gust
#

i have 0 idea what u are talking about

graceful mulch
#

replit

#

No need to have

#

any idea also , it is a biiig problem

quick gust
#

um ok

graceful mulch
#

I WILL sue replit's ceo

quick gust
#

...

graceful mulch
#

I will

#

he made my bot remove 10 commands

#

just do its f replit updating and package failed nuisance

tawdry perch
#

what kind of things should be stored of infractions, or is this enough? ```sql
CREATE TABLE IF NOT EXISTS infractions(
id serial PRIMARY KEY,
user integer,
apply time,
expire time,
active bool,
type text,
reason text,
)

#

oh maybe the actor

boreal ravine
unkempt canyonBOT
tawdry perch
#

ĀÆ_(惄)_/ĀÆ

boreal ravine
#

ĀÆ_(惄)_/ĀÆ

visual island
#

ĀÆ_(惄)_/ĀÆ

upbeat otter
#

ĀÆ_(惄)_/ĀÆ

boreal ravine
#

stop chaining

maiden fable
#

Yea facts

#

Stop chaining 4552milkshrugidk

jagged root
#
async def suggest(ctx, command, *, description):
    ': Suggest a command. Provide the command name and description'
    embed = disnake.Embed(title='Command Suggestion', description=f'Suggested by: {ctx.author.mention}\nCommand Name: *{command}*', color=disnake.Color.green())
    embed.add_field(name='Description', value=description)
    channel = ctx.guild.get_channel(924998519432036393)
    msg = await channel.send(embed=embed)
    await msg.add_reaction('šŸ‘')
    await msg.add_reaction('šŸ‘Ž')```
Idk why this code aint working
valid perch
maiden fable
#

Lmao

valid perch
jagged root
maiden fable
#

Do u have an error handler?

valid perch
#

Uh huh, and have you tried debugging it yourself?

#

Does the command get called

#

etc

jagged root
#

tbh i dont know how to debug

valid perch
#

✨ print("It gets to here") ✨

tawdry perch
#

just add print statements to see which lines gets run

visual island
jagged root
#

ok

jagged root
# visual island Im guessing the command doesn't get invoked. See: https://discordpy.readthedocs....
async def suggest(ctx, command, *, description):
    ': Suggest a command. Provide the command name and description'
    embed = discord.Embed(title='Command Suggestion', description=f'Suggested by: {ctx.author.mention}\nCommand Name: *{command}*', color=discord.Color.green())
    embed.add_field(name='Description', value=description)
    channel = ctx.guild.get_channel(924998519432036393)
    msg = await channel.send(embed=embed)
    await msg.add_reaction('šŸ‘')
    await msg.add_reaction('šŸ‘Ž')
    
    await bot.process_commands(ctx)``` 
Like that?
visual island
#

do you have on_message event?

visual island
#

yea, thats all the code for the command

visual island
jagged root
#

what should i add

#

ehm idk how i check it

slate swan
#
@bot.event
async def on_message(message):``` something like that?...
#

do you such function?

jagged root
#
async def suggest(ctx, command, *, description):```
#

i have that

quick gust
#

...

quick gust
slate swan
#

im talking about all of your code , not the command particular

jagged root
#

nope

#

i dont think so

slate swan
#

just use ctrl+F , and search for on_message

jagged root
#

i dont

#

what should i do

visual island
#

now, how do you invoke the command

jagged root
#

hm

visual island
#

like "!suggest" or what

jagged root
#

ye

#

.suggest

slate swan
#

and the argument?...

#

do you supply any argument to it

#

.suggest text goes here?

jagged root
#

yep

slate swan
#

hm , do you have a on_command_error event

jagged root
#

nope

slate swan
#
logged in
i occured in  c:\Users\rrfda\OneDrive\Desktop\sublime pg version\buttons.py
Task exception was never retrieved
future: <Task finished name='discord-ui-view-dispatch-e67a5c9c3fc4fd3e697bce3b94ce65e3' coro=<View._scheduled_task() done, defined at C:\Python39\lib\site-packages\discord\ui\view.py:346> exception=AttributeError("'Interaction' object has no attribute 'send_message'")>
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\ui\view.py", line 355, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\rrfda\OneDrive\Desktop\sublime pg version\buttons.py", line 48, in callback
    await self.ctx.message.delete()
  File "C:\Python39\lib\site-packages\discord\message.py", line 1188, in delete
    await self._state.http.delete_message(self.channel.id, self.id)
  File "C:\Python39\lib\site-packages\discord\http.py", line 339, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
visual island
#

code when

slate swan
#

await self.ctx.message.delete() what's context here?

#

Will my bot get rate-limited with this?

    @commands.Cog.listener()
    async def on_member_join(self,member):
        stats_channel = member.guild.get_channel(921720659653054464)
        count = len(member.guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')

    @commands.Cog.listener()
    async def on_member_remove(self,member):
        stats_channel = member.guild.get_channel(921720659653054464)
        count = len(member.guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
visual island
#

depends on how popular your server is

slate swan
#

probably , just dont edit the channel names as soon as the member joins the server , i'd run a loop which edits the channel name

visual island
#

but using tasks.loop seems better

slate swan
#

use loop then

#

Ok

#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
graceful mulch
#

!src

unkempt canyonBOT
slate swan
#
logged in
i occured in  c:\Users\rrfda\OneDrive\Desktop\sublime pg version\buttons.py
Task exception was never retrieved
future: <Task finished name='discord-ui-view-dispatch-d3d16ef88b75f4ea0620d4587e6a202c' coro=<View._scheduled_task() done, defined at C:\Python39\lib\site-packages\discord\ui\view.py:346> exception=AttributeError("'Interaction' object has no attribute 'send_message'")>
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\ui\view.py", line 355, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\rrfda\OneDrive\Desktop\sublime pg version\buttons.py", line 48, in callback
    await self.ctx.message.delete()
  File "C:\Python39\lib\site-packages\discord\message.py", line 1188, in delete
    await self._state.http.delete_message(self.channel.id, self.id)
  File "C:\Python39\lib\site-packages\discord\http.py", line 339, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message```
slate swan
slate swan
#

Ok thanks

velvet tinsel
slate swan
#

update_data function?

velvet tinsel
#

You have 3 arguments

slate swan
#

where is it

velvet tinsel
#

It required 2

slate swan
#

read what dekriel said

shadow wraith
#

your copying code, ive seen this before

#

šŸ¤”

#

i swear i saw this code before

slate swan
#

Would this work?

    @tasks.loop(minutes=2)
    async def on_member_join(self,member):
        stats_channel = member.guild.get_channel(921720659653054464)
        count = len(member.guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
    
    @tasks.loop(minutes=2)
    async def on_member_remove(self,member):
        stats_channel = member.guild.get_channel(921720659653054464)
        count = len(member.guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
visual island
shadow wraith
#

bro why are you copying code without understanding

visual island
slate swan
#

oh

shadow wraith
#

man i just realized using apis which use json are so easy with aiohttp

slate swan
#

ghost ping , cool

shadow wraith
#

there's even a would you rather API which does that, only has 119 questions tho

visual island
# slate swan oh

The idea is:

  1. Loop every 1 minute or so
  2. Get the guild
  3. Count the members
  4. Edit the channel
shadow wraith
#

bot devs are bot creators

#

x]

#

not talking to you

heavy folio
#

dont copy code, 1) you wont learn anything from it
2) the indents are broken thebigstare
3) json isnt a db

slate swan
#

nice database bro peepoHurt

#
logged in
i occured in  c:\Users\rrfda\OneDrive\Desktop\sublime pg version\buttons.py
Task exception was never retrieved
future: <Task finished name='discord-ui-view-dispatch-d3d16ef88b75f4ea0620d4587e6a202c' coro=<View._scheduled_task() done, defined at C:\Python39\lib\site-packages\discord\ui\view.py:346> exception=AttributeError("'Interaction' object has no attribute 'send_message'")>
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\ui\view.py", line 355, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\rrfda\OneDrive\Desktop\sublime pg version\buttons.py", line 48, in callback
    await self.ctx.message.delete()
  File "C:\Python39\lib\site-packages\discord\message.py", line 1188, in delete
    await self._state.http.delete_message(self.channel.id, self.id)
  File "C:\Python39\lib\site-packages\discord\http.py", line 339, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message```
slate swan
#

oh wait no

#

I haven't

heavy folio
#

then dont ask it here

#

we dont help people who copy code

shadow wraith
# slate swan I haven't

if you can't create a bot, you can't develop it, if you don't want to develop a bot, don't create it

shadow wraith
#

wait

slate swan
slate swan
shadow wraith
slate swan
#

lmfao

shadow wraith
#

yes wrong reply

slate swan
# slate swan `await self.ctx.message.delete()` what's context here?

its passed inside the class ```py
class Delete_button(Button):
"""
Some discord button that deletes the author and the bots message if everything goes smoothly
Arguments

ctx : discord.Context should be passed
class discord.ButtonStyle
or discord.ButtonStyle.danger, discord.ButtonStyle.gray
----
"""

def __init__(
    self,
    ctx: commands.Context,
    style: Literal[discord.ButtonStyle.danger, discord.ButtonStyle.gray] = None,
) -> None:
    self.ctx = ctx
    self._style = style
    super().__init__(
        style=self._style or discord.ButtonStyle.danger,
        emoji=f"{random.choice(Emojis.trash_emojis)}",
    )

async def callback(self, interaction) -> Coroutine:
    """
    A discord.ui.button callback function returns a coroutine
    deletes the bot message and the authors message
    -----
    when the if statment fails
    it sends to the user a random error_reply with a random "pepe" sad emoji
    ephemeral=True so only the user can sees it'
    """
    if interaction.user.id == self.ctx.author.id:
        # checking if the author id meets the user interaction id
        try:
            await self.ctx.message.delete()
         # deleting the author message
         
        except AttributeError:
            #most likely they used a slash-command, so there isnt a message to delete
            pass
        return await interaction.message.delete()
        # and finally deleting the interaction message which is the bots message
    return await interaction.response.send_message(
        f"{random.choice(Replies.error_replies)} {random.choice(Emojis.pepe_sad_emojis)}",
        ephemeral=True,
    )```
shadow wraith
#

the only thing which could be considered as spoonfeeding are examples, examples are a concept of implementation

velvet tinsel
shadow wraith
slate swan
#

Is it like this @visual island?

    @tasks.loop(minutes=2)
    async def serverstats(self,member):
        while True:
            stats_channel = member.guild.get_channel(921720659653054464)
            count = len(member.guild.members)

            await stats_channel.edit(name = f'Member Count : {count}')
        await self.bot.loop.create_task(serverstats)
visual island
#

while True isnt needed

shadow wraith
slate swan
shadow wraith
#

cool cool

slate swan
#

deadass FLISH but thanks for the compliment

visual island
#

and to start a task use func.start()

slate swan
#

Ok

#
    @tasks.loop(minutes=2)
    async def serverstats(self,member):
        stats_channel = member.guild.get_channel(921720659653054464)
        count = len(member.guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
        await func.start(serverstats)
#

also does this follow pep8 guildines on naming class variables conventions ?

visual island
slate swan
#

oh

#

Ok