#discord-bots

1 messages · Page 42 of 1

shrewd apex
silk fulcrum
#

bruh I just didn't mind a speed up if it's possible, didn't expect this much problems

shrewd apex
#

sed

slate swan
#

🐈 just use hikar~

#

yea sure

shrewd apex
#

i get bad feeling about this i feel like it not gonna end well

slate swan
silk fulcrum
shrewd apex
elder storm
silk fulcrum
#

Censored August 31

#

why tf

shrewd apex
#

devs i manage to find are even lazier than me my luck too bad😔

slate swan
slate swan
silk fulcrum
slate swan
#

i can't code for more than 100 lines a day without motivation

shrewd apex
#

i managed to get u to work once a week

elder storm
shrewd apex
#

he broke ur record yesterday

slate swan
slate swan
shrewd apex
#

😭

silk fulcrum
#

How can I do this in my readme?

shrewd apex
slate swan
#

why is this giving this error

slate swan
silk fulcrum
shrewd apex
#

he is almost done tho

slate swan
shrewd apex
#

he got it done pretty fast

slate swan
#

there are many sites

elder storm
slate swan
#

!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.

silk fulcrum
#

remove token @elder storm

#

when pasting here

slate swan
shrewd apex
# slate swan show full code

sarth btw if u free tonight can u make the code latest dpy compatible u have to like make the paginator again...

shrewd apex
shrewd apex
slate swan
elder storm
shrewd apex
silk fulcrum
shrewd apex
#

i have been kinda lazy so didn't fix these

shrewd apex
#

i figured it i don't soon it gonna pile up

slate swan
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

slate swan
#

!d discord.ext.commands.Context.from_interaction

unkempt canyonBOT
#

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

Creates a context from a [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction"). This only works on application command based interactions, such as slash commands or context menus.

On slash command based interactions this creates a synthetic [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") that points to an ephemeral message that the command invoker has executed. This means that [`Context.author`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.author "discord.ext.commands.Context.author") returns the member that invoked the command.

In a message context menu based interaction, the [`Context.message`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.message "discord.ext.commands.Context.message") attribute is the message that the command is being executed on. This means that [`Context.author`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.author "discord.ext.commands.Context.author") returns the author of the message being targetted. To get the member that invoked the command then [`discord.Interaction.user`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.user "discord.Interaction.user") should be used instead.

New in version 2.0.
slate swan
#

just use this

#

can someone help as to why im getting this error

silk fulcrum
# elder storm ?

do ```py
intents = discord.Intents.default()
intents.message_content = True

client = discord.Client(intents=intents)```

shrewd apex
shrewd apex
slate swan
dense fiber
#

hey

dense fiber
#

this code doesnt show my user avatar

silk fulcrum
#

🗿

dense fiber
slate swan
#

whats the load_image_async function

shrewd apex
dense fiber
#

legit

dense fiber
slate swan
vocal snow
silk fulcrum
slate swan
#

ctx do be short

slate swan
shrewd apex
#

oh ok 👍

dense fiber
#

can yall help me or????

slate swan
vocal snow
slate swan
shrewd apex
slate swan
shrewd apex
dense fiber
#

@slate swan

slate swan
#

Asher's so smart

shrewd apex
#

kek i wish i clear in first try or i am gonna go be neighbours with sarth

slate swan
#

probably some issue with the paste part

slate swan
#

🗿 imagine asher knocking at my door "code when"

shrewd apex
#

this guy not even using pil he is using a third party for pil which is named something like easy_pil

shrewd apex
shrewd apex
slate swan
slate swan
#

!pip easy_pil

unkempt canyonBOT
shrewd apex
shrewd apex
#

from some yt tutorial a guy asked before

#

same question

slate swan
#

how about rewriting discord.py with HTTPX and mypy typechecking

#

asher gonna kill me

shrewd apex
lone lichen
#

are app commands supposted to be slash commands?

slate swan
#

eh no typing stuff is really easy if you do it from the base

dense fiber
#

huh

shrewd apex
slate swan
slate swan
shrewd apex
dense fiber
shrewd apex
#

yeah

dense fiber
#

is it supposed to be easy_pil??

shrewd apex
#

the name is easy_pil but u install it like easy-pil

dense fiber
shrewd apex
#

u installed correct package

dense fiber
#

oh hmmm

#

then why it didnt work?

shrewd apex
slate swan
#

ty , ill go study nowww

dense fiber
#

do i need to reinstall?

shrewd apex
dense fiber
#

oh

shrewd apex
dense fiber
#

how do i go about fixing it?

shrewd apex
#

ok it loaded

#

why not just use pil tho

dense fiber
#

idk

#

i'm still new so dk much

vocal snow
shrewd apex
#

hmm i don't see much wrong except just do member.display_avatar.url

dense fiber
#

k

shrewd apex
#
image = await load_image_async(ctx.author.display_avatar.url)

    # Initialize the editor and pass image as a parameter
editor = Editor(image).circle_image()
dense fiber
#

try this?

shrewd apex
#

just the first line use member. whatever i said

dense fiber
#

k

vocal snow
#

Or maybe he wants to buy Lamborghini

slate swan
shrewd apex
vocal snow
#

It's literally just more math !!!

slate swan
#

this channel should be moved to ot

shrewd apex
slate swan
#

and should be kept there

shrewd apex
#

too much math

slate swan
vocal snow
#

BCA has more business stuff but BSc CS is btech without physics and chem

shrewd apex
#

i mean if i would have to take a drop it would prolly only be if i am sure shot to get into iit in my next trypithink

vocal snow
#

Do that IIT Madras BSc online thing

slate swan
#

BSc has too less programming in practice when compared to Btech
they focus more on theory

#

and applications

shrewd apex
#

otherwise as long as i get a good course and college i am good

vocal snow
#

that is true

#

Depends on the institute too

shrewd apex
#

in any semester

#

rest all still gonna be maths and all

shrewd apex
slate swan
#

ok im gonna shove the memo in your face, go to one of the ot channels please

vocal snow
shrewd apex
#

ooh nice 🎉

#

course?

vocal snow
shrewd apex
#

pog

vocal snow
shrewd apex
#

i mean technically next year

#

this academic year

shrewd apex
vocal snow
#

Just a local one nothing special

vocal snow
#

Well wanting to do cse

shrewd apex
#

cse is good no matter which college

shrewd apex
#

gonna try

vocal snow
#

nice nice

glad cradle
#

is better psicopg3 or Sqlalchemy?

#

for a Discord Bot

vocal snow
#

do you want an ORM

#

if so sqlalchemy, prisma, tortoise are nice

#

otherwise asyncpg best prolly

glad cradle
#

what's ORM

vocal snow
#

object relational mapping

glad cradle
#

do you have any resources that explain the benefits of ORM?

sick birch
sick birch
#

Prisma is my personal favorite

glad cradle
sick birch
#

Yes and data is returned in nice dicts

#

You use methods and classes to interact with the database

#

It’s pretty cool honestly

glad cradle
#

which one do you think is the best between asyncpg and motor?

sick birch
#

Those are not ORMs

glad cradle
#

motor is not a ORM?

sick birch
#

No they’re connectors

vocal snow
#

no it's just a database wrapper

glad cradle
#

I wanted to say sqlalchemy

vocal snow
#

ah yes connector is the proper term

sick birch
glad cradle
vocal snow
#

sqlalchemy does have an async interface

sick birch
#

That’s great then use that

vocal snow
#

in my experience prisma is the most fun to use

#

the prisma python maintainer is awesome too

slate swan
vocal snow
#

yes thats what i said

#

ashley moment !!

slate swan
#

I red that wrong my bad

vocal snow
#

are you going to make the embed text formatting gist thing

slate swan
#

absolutely not

vocal snow
#

😭

glad cradle
vocal snow
#

yes

glad cradle
#

do you think that prisma is easier than sqlalchemy?

vocal snow
#

yes

#

if you don't like the prisma schema lang you can make it in sql and then generate it with prisma generate or something

#

aside from that I think prisma is more intuitive

glad cradle
#

ok thx, then I'll use prisma

silk fulcrum
#

seems kinda good

#

idk why am I doing this for just myself, I'm an idiot

glad cradle
#

Share the link

silk fulcrum
#

what link

glad cradle
#

isn't this github?

silk fulcrum
#

nop

#

pycharm readme preview

glad cradle
#

ah

silk fulcrum
#

i feel like someone asks me: who asked?

slate swan
#

the errors & bugs: nothing part is something i can never relate to

slate swan
#

-U -r = -Ur

silk fulcrum
#

checked: actually works

slate swan
#

yea

slate swan
silk fulcrum
slate swan
#

what part of Code does this warning come.from?

silk fulcrum
#

come.from

silk fulcrum
slate swan
#

reason for the warning

silk fulcrum
glad cradle
#

you could do

name, value, inline = ("Content",  message.content, False)

tuple unpacking

slate swan
# silk fulcrum uhm? no current even loop

yea in newer python versions its functionality will change

Deprecated since version 3.10: Deprecation warning is emitted if there is no running event loop. In future Python releases, this function will be an alias of get_running_loop()

so you might consider using creating a loop manually first

silk fulcrum
glad cradle
silk fulcrum
#

well at least it will work... but.. nothing...

slate swan
#

use dict based cursors when

silk fulcrum
#

if i have to do it manually...

valid glacier
#

Hello, I have kinda weird problem, lets say that I have this piece of code

@client.command()
@commands.cooldown(RATELIMIT, PER_SECONDS, commands.BucketType.default)
async def getdifficulty(ctx):    
request = requests.get("https://blockchain.info/q/getdifficulty")    print(request)    
print(request.content)   
await ctx.send(request.content)

When I call the command, it prints the response on discord and in my terminal, but when i change the code, for example like this

@client.command()
@commands.cooldown(RATELIMIT, PER_SECONDS, commands.BucketType.default)
async def getdifficulty(ctx):    
request = requests.get("https://blockchain.info/q/getdifficulty")    print(request)    
print("Test")    
await ctx.send("Test")

save it and then run it again, it still prints the same thing as before. What should I do? Thanks

slate swan
unkempt canyonBOT
silk fulcrum
#

bruh, that's only for ifs ig :(

silk fulcrum
#

im just unsure if there is gonna be a problem

#

probably i should tias

slate swan
#

put it at the entry point of your program, where the first async function needs to be called

#

because this should be called only once

silk fulcrum
#

hm... okay, got it

primal token
gusty shard
#

how can i make the fields values look like names

#

i mean white instead of grey

silk fulcrum
#

**text**?

slate swan
#

why not use description so all can be same

golden tapir
#

how could i make slash commands any documentaion?

gusty shard
#

because there's a loop that changes every horse

gusty shard
#

i know its possible

#

but im not enoguh talented for that

slate swan
#

its literally just embed.description+= "part to add"

silk fulcrum
#

oh... my... gosh...

golden tapir
#

i want a rep kind of thing for my bot i just dont know how i can keep track of everyones rep what should i do put have a var for every single one?

golden tapir
#

like a file

#

but dont those cost money?

valid glacier
golden tapir
#

how do i create a data base

#

and how do i know who said what

sick birch
valid glacier
winged coral
#

SQLite works

golden tapir
#

does mongoDB cost money

primal token
#

"google it" how useful

winged coral
golden tapir
#

could i just store them all in a file

winged coral
#

Can use json, not ideal

valid glacier
# primal token "google it" how useful

well, 1) learn how to make database 2) come with a specific problem rather then "how do i create database", this seems like a good plan dont you think

winged coral
#

Cannot be read twice at once, overwriting errors, speed etc

#

DB > JSON if possible

primal token
#

should use SQLite with an async driver

winged coral
#

^

golden tapir
#

wat is a async driver

sick birch
# golden tapir wat is a async driver

Connection to a database is I/O, so you'll need it to not block the asynchronous event loop. Async drivers let you connect to your database without blocking

primal token
golden tapir
#

me?

primal token
sick birch
#

You're right that "How do I create a database" is a bit open-ended, I think definitely do a little bit of research, narrow your questions down, and we can help you out

pale turtle
#

How do I get the token for my bot? I am at the bot page yet there is no copy token only reset token

valid glacier
sick birch
#

Or if you're like me just reset it every time

golden tapir
#

i do that

#

^^

primal token
golden tapir
#

like robin said i reset it everytime i lose it

primal token
#

securityducky_beer

golden tapir
#

clearly ineffecient but it works for me

primal token
#

just save it in an env file or a python file or a json config file

glad cradle
#

if no one sees it then why reset it every time 🦆

pale turtle
sick birch
#

The one time being lazy pays off

pale turtle
#

Anyone has a link for that? It doesn't work for me

#

Or he just deleted it

slate swan
pale turtle
#

Thanks

junior verge
#

Anyone that could help with with my VPS, I just got it and got some problems with it. It's for my discord bot

#

Really need it Please

graceful turtle
#

is there a way to set the api version you want through aiohttp? i've done it before but forgot how

pale turtle
junior verge
#

I already got it to work, thanks anways.

sick birch
light night
slate swan
#

can emoji strings be in embed responses to buttons

glad cradle
#
async def get_json_info():
  json_path = Path("/home/runner/disnake-testing-playground/IrusuBot/config.json")
  async with aiofiles.open(json_path, mode='r') as f:
    data = await f.read()
  return json.loads(data)

def get_prefix(bot, message):
  loop = asyncio.get_event_loop()
  data = loop.run_until_complete(get_json_info())
  loop.close()
  return data[str(message.guild.id)]["prefix"]
Traceback (most recent call last):
  File "/home/runner/disnaketest/venv/lib/python3.8/site-packages/disnake/client.py", line 612, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/disnaketest/venv/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 618, in on_message
    await self.process_commands(message)
  File "/home/runner/disnaketest/venv/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 614, in process_commands
    ctx = await self.get_context(message)
  File "/home/runner/disnaketest/venv/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 518, in get_context
    prefix = await self.get_prefix(message)
  File "/home/runner/disnaketest/venv/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 457, in get_prefix
    ret = await disnake.utils.maybe_coroutine(prefix, self, message)
  File "/home/runner/disnaketest/venv/lib/python3.8/site-packages/disnake/utils.py", line 578, in maybe_coroutine
    value = f(*args, **kwargs)
  File "./IrusuBot/main.py", line 30, in get_prefix
    data = loop.run_until_complete(get_json_info())
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 592, in run_until_complete
    self._check_running()
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 552, in _check_running
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running

today these two functions were working fine

slate swan
limber bison
#

how can i make , !help and ! help both work ?

glad cradle
slate swan
slate swan
#

discord.py allows both normal functions and coroutines for that kwarg

glad cradle
#

await keyword can be used only inside function, how can i do that

glad cradle
unkempt canyonBOT
slate swan
#

you aren't calling the function there sir, you are just providing the function object, discord.py calls it for you ```py
async def get_prefix(bot, message):
return "..."

bot = commands.Bot(command_prefix= get_prefix)

glad cradle
#

ah

#

it works

#

thx

wicked atlas
# slate swan

Usually for custom emojis, you need to provide an ID too, in this format:

<:name:id>

slate swan
#

thats the thing

wicked atlas
#

Does it still just show as text?

slate swan
#

yep

#

um try using the emoji object instead bot.get_emoji(id)

sick birch
#

!d discord.Client.get_emoji try this

unkempt canyonBOT
#

get_emoji(id, /)```
Returns an emoji with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
slate swan
#

okay ill try

wicked atlas
#

I don’t think that’ll make much of a difference, it just makes the same string

slate swan
#

did you use \ and get the escaped name of the emoji or copy the ID with some other method?

#

yep

#

i did slash

#

\

#

then :emojiname:

#

and it gives me this for example \🚁

#

bad example

#

like that and i copy n paste that

#

and the bot is in the server where emoji is from?

#

no its not

#

i thought it didnt have to be

#

it doesnt with webhooks

#

well, it does for bots

#

rip

#

thats okay ig

#

ye it works now

#

thanks sarth

#

can someone help with how to make a button within a button

#

i want to have this button but after they've pressed on it they can go back to the main button they started with

sharp geode
#

https://paste.pythondiscord.com/qotezovave
Hello, I have this slash commands code with the discord_slash module (i don't like to use discord.py v2 and all my bot is with that module) and when I put the options the command does nothing even if i put all the fields in it

limber bison
#

what hosting plan a music bot need for a single server 24*7 ?

winged coral
alpine swan
winged coral
#

How are you subclassing it?

alpine swan
#
class CustomCog(commands.Cog):
    def __init__(self, bot):
winged coral
#

I mean how are you subclassing the cog_load method?

alpine swan
#
    async def cog_load(self):
winged coral
#

And this cog is being loaded? Commands belonging to it work?

alpine swan
#

yea

winged coral
#

Then it should definitely be firing

alpine swan
#

this is what it's doing

    async def cog_load(self):
        print("cog_load")
        print(self.bot.guilds)
#

frustrating then =T

winged coral
#

A weird one. Not sure what else could be happening

alpine swan
#

"the cog gets loaded" means when you do

self.add_cog(CustomCog(self))

right?

#

oh I guess i could do

    @commands.Cog.listener()
    async def on_ready(self):
        print('Custom Command Online')
vocal snow
#

make sure you're awaiting it

winged coral
alpine swan
#

yeah my cog is created in a custom bot

#

not quite sure if that's a good pattern, still trying to figure things out

limber bison
#

which is best for a 24*7 music + modration + economy in 300k single server ?

alpine swan
#

anyone mind linking me an example of await self.add_cog? all examples are non coro

limber bison
full lily
#

is there a list of events somewhere?

#

I feel like i'm always looking for that

full lily
vocal snow
limber bison
#

like 160 ?

vocal snow
#

the 320$ one is the best

#

which is why it's also the most expensive

limber bison
vocal snow
#

what suggestion? You asked which is the best VPS

limber bison
#

24*7 music + modration + economy in 300k single server ,,, things

#

i mean effecent

#

like 100% use

vocal snow
#

If you mean which would be adequate for your use

limber bison
#

if i buy 160 or 320 most of CPU will be uselesss

limber bison
vocal snow
#

depends on how well you've coded it. But the third one should be sufficient

limber bison
#

lol

vocal snow
#

well you should go for the 320$ one then

limber bison
#

3rd ok

limber bison
#

this is how i code commads

alpine swan
#

oh, didnt know 2.0 just got released, stuff workin now I updated

limber bison
#

now suggest me 😂

austere vale
#
class MusicCog(commands.Cog, name='Music'):
  '''play'''
  def __init__(self, bot):
    self.bot = bot
  async def node_connect(self):
    await self.bot.wait_until_ready()
    await wavelink.NodePool.create_node(bot=self.bot,host= 'lavalinkinc.ml',port=443,password='incognito',https=True)
  @commands.Cog.listener()
  async def on_ready(self):
    self.bot.loop.create_task(node_connect())

can someone help me with my music code? it says that node_connect() is undefined in the last line of code, and im not sure where to move it

vocal snow
#

and we're not really allowed to help with wavelink and ytdl stuff because of rule 5

austere vale
#

oh-

#

is it illegal to have music bots?

full lily
#

depends where you get the music from

vocal snow
#

!ytdl has the fine details if you want

alpine swan
#

updated to 2.0, awaited my add_cog, now commands not working -.-

import os
import json
import discord 
from discord.ext import tasks, commands
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

class CustomCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    
    async def cog_load(self):
        print("cog_load")
        
    @commands.command()
    async def test(self, ctx):
        print('test invoked')
        await ctx.send('test')

class CustomBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.members = True
        intents.messages = True
        super().__init__(command_prefix='!', intents=intents)
        
    
    async def on_ready(self):
        print(f'{bot.user} has connected to Discord!')
        await self.add_cog(CustomCog(self)) 

bot = CustomBot()

bot.run(TOKEN)
drifting arrow
#

Uhh

drifting arrow
#

whoops. replace staffapps to whatever your class is called

vocal snow
#

It's not an extension though, just a cog

drifting arrow
#

I assume he merged them just for the paste

vocal snow
#

He's using the class in on_ready

drifting arrow
#

the whole thing confuses me tbh

vocal snow
alpine swan
#

this is why I asked for examples and people just said, "just add await to it"

#

it's printing login message and cog_load

drifting arrow
alpine swan
#

it isnt responding to !test

#

sure

vocal snow
#

nothing to do with the cog

buoyant flame
#

!e

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval [python_version] <code, ...>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

By default your code is run on Python's 3.11 beta release, to assist with testing. If you run into issues related to this Python version, you can request the bot to use Python 3.10 by specifying the python_version arg and setting it to 3.10.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

buoyant flame
#

!e print(1)

#

!e while True: print(1)

#

wow

rustic onyx
#

does discord have an invite api? to track invites?

vocal snow
#

track in what way?

rustic onyx
#

well to know who invited who

pliant gulch
#

Discord discourages invite tracking

rustic onyx
#

why so?

pliant gulch
#

In their official API server they tell people not to do it

#

iirc it's due to some advertising stuff or whatever

#

You can join the server to check it

rustic onyx
#

hmm, do you have the link of it with you?

vocal snow
rustic onyx
#

tysm

pliant gulch
#

Ah here it is

limber bison
#

how can i check wather the input is url or not ?

cursive barn
heavy swift
slate swift
#

can someone help

quaint epoch
#

!traceback ?

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

alpine swan
slate swift
heavy swift
slate swift
heavy swift
#

also you should take ctx as the first arg 🤨

slate swift
quaint epoch
#

the message context is always passed first

heavy swift
#

also ur parenthesis arent enclosing the desc

quaint epoch
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
slate swift
#

wait what

#

one person please

heavy swift
#

Some basic python would really help 😓

quaint epoch
heavy swift
#

Not knowing what an arg is

slate swift
heavy swift
#

your parenthesis arent enclosing the desc

quaint epoch
#

you haven't closed the outer most brackets

#

well, you have, but you put description out of the brackets

quaint epoch
heavy swift
#

😇

quaint epoch
#

best to change it

#

(sudden urge to run the token)

heavy swift
#

I believe in communism

#

Our account

slate swift
#

fixed it i think

quaint epoch
#

yes

eager hill
#

how would i get my bot to change a nickname without using client.command

#

because client.command always breaks for me lol

quaint epoch
#

!d discord.ext.commands.Bot you need to use thsi @eager hill

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
quaint epoch
#

so what happens

slate swift
quaint epoch
slate swift
# quaint epoch you need to do `text='test'`
async def snipe(message):
  if snipe_message_content == None:
    await message.channel.send("There is nothing to snipe")
  else:
      embed = discord.Embed(color=discord.Color.random(), description=f"{snipe_message_content}")
      embed.set_footer(test=f"Requested by {message.author.name}#{message.author.discriminator}")
      embed.set_author(name=f"Sniped the message deleted by {message.author}")
      await message.channel.send(embed=embed)
      return```
eager hill
# quaint epoch so what happens

nothing ```py
bot = Bot("!")

@bot.command(pass_content=True)
async def changenick(ctx, member: discord.Member, nick):
await member.edit(nick=nick)
await ctx.send(f'Nickname was changed for {member.mention}')

eager hill
#

when i try !changenick @eager hill test, it would never work

eager hill
#

no idea what that is

slate swift
quaint epoch
#

that code looks ancient

eager hill
#

i just tried off a video dawg

#

i have no idea what im doing and i learn off doing yk

quaint epoch
#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.command()
async def nick(ctx: commands.Context, member: discord.Member, *, nick: str):
  await member.edit(nick=nick)
  await ctx.reply(f'Changed the nickname of {member.mention} to `{nick}`')```
slate swift
#
async def snipe(message):
  if snipe_message_content == None:
    await message.channel.send("There is nothing to snipe")
  else:
      embed = discord.Embed(color=discord.Color.random(), description=f"{snipe_message_content}")
      embed.set_footer(test=f"Requested by {message.author.name}#{message.author.discriminator}")
      embed.set_author(name=f"Sniped the message deleted by {message.author}")
      await message.channel.send(embed=embed)
      return```
quaint epoch
#

the tutorial is outdated, you shouldn't use it

slate swift
#

can u explain what i did wrong

quaint epoch
slate swift
quaint epoch
#

you did test= instead of text=

slate swift
#

oh

past heath
#

i switched to dpy 2.0 and my bancount command isnt working anymore it returns a error saying "object of type 'async_generator' has no len()"

#
@commands.command()
    async def bancount(self, ctx):
        bancount= len(ctx.guild.bans())
        embed=discord.Embed(description=f"There are `{bancount}` bans in this server", color=0x6666FF)
        await ctx.send(embed=embed)```
eager hill
quaint epoch
unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
eager hill
#

theres no error but nothing happens when i try !nick @eager hill test

quaint epoch
#
@commands.command()
    async def bancount(self, ctx):
        bancount= len(await ctx.guild.bans())
        embed=discord.Embed(description=f"There are `{bancount}` bans in this server", color=0x6666FF)
        await ctx.send(embed=embed)```
quaint epoch
past heath
eager hill
quaint epoch
eager hill
#

!pastebin

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.

past heath
#

but it still dosent work

quaint epoch
past heath
#

i remember it saying await cnt be used in this expression

#

object async_generator can't be used in 'await' expression

quaint epoch
#

kk

#
bancount = 0
async for i in ctx.guild.bans():
  bancount += 1``` do this instead
eager hill
#

(im black btw)

quaint epoch
eager hill
#

ok

past heath
#

alright

heavy swift
#

what

#

💀 Why did that needed to be clarified

quaint epoch
#

so

#

you need to do

eager hill
heavy swift
#

😭

#

I figured he had the n word in his code if he was saying that lol

past heath
quaint epoch
daring olive
#

can we not post slurs here please

eager hill
quaint epoch
#

clients don't have commands

#

only bots

eager hill
heavy swift
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change...
daring olive
slate swift
#
async def avater(ctx, *, member: discord.Member = None):
  member = ctx.author if not member else member
  embed = discord.Embed(title=f"{member.name}'s avatar, color = member.color , timestamp= ctx.message.created_at")
  embed.set_image(url=member.avatar_url)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=ctx.author.avatar_url)
  await ctx.send(embed=embed)```
#

Can you tell me why it says command avatar not found

eager hill
#

i know that it now has to use ! but it says py Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "hello" is not found

mild lava
#

is there a method to get a channel from a guild by id in d.py 2.0.0?

#

docs are a bit confusing

#

or actually, a list of all the channel ids in the guild

limber bison
#

def check( m):
return m.content == ('yes'or'Yes'or'T'or 't'or'Y'or'y') and m.channel == ctx.channel and m.author.id == ctx.author.id

why Yes and all not working ?

slate swan
unkempt canyonBOT
slate swift
mild lava
# unkempt canyon

to check if a channel is in a particular guild would it be faster to get all the ids first and then check my channel id against them or first get the channel and see if its in guild.channels?

limber bison
mild lava
#

like ids = [channel.id for channel in guild.channels]

slate swan
slate swift
pliant gulch
heavy swift
limber bison
pliant gulch
#

But also the second choice isn't the most optimal\

mild lava
pliant gulch
#

For an example if you use Guild.get_channel(id) you can check if it's None

#

Meaning that Guild has no channel with the specified ID

mild lava
#

oh so Guild does have a get_channel method

pliant gulch
#

It does

#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.

Changed in version 2.0: `channel_id` parameter is now positional-only.
mild lava
#

thank you

pliant gulch
#

So just check if it returns None, if it did it's either not cached or it doesn't exists to that guild

#

Much better than checking against a list of IDs that you create solely for that purpose

slate swift
heavy swift
mild lava
#

another question. to detect when a member is either banned, kicked, leaves, or otherwise removed from the server, would i need to use both on_member_remove and on_member_ban?

#

the two events are a little inconsistent in their args

slate swift
pliant gulch
heavy swift
pliant gulch
#

The other handles all three that you want

mild lava
slate swift
# heavy swift 🤨 How did you write it and what does the error look like now
async def avater(ctx, *, member: discord.Member = None):
  member = ctx.author if not member else member
  embed = discord.Embed(title=f"{member.name}'s avatar, color = member.color , timestamp= ctx.message.created_at")
  embed.set_image(url=member.display_avatar.url)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=ctx.author.avatar_url)
  await ctx.send(embed=embed)
pliant gulch
mild lava
#

!d discord.Member

sick birch
heavy swift
#

also u made a typo

mild lava
heavy swift
#

ur function name is called avater not avatar

#

@slate swift

pliant gulch
#

!d

unkempt canyonBOT
pliant gulch
#

It's alive

mild lava
slate swift
#

i dont see it

heavy swift
#

you haveter and not tar

slate swift
heavy swift
#

async def avater(ctx, *, member: discord.Member = None):

#

the name of the function

slate swift
#

oh yea

#

what did u mean by you didnt fix icon_url

heavy swift
slate swift
#

in the {} right?

heavy swift
#

it's the part that's next to it

slate swift
#

i meant yea

slate swift
heavy swift
#

icon_url = ctx.author.display_avatar.url

grizzled reef
slate swift
#
async def avatar(ctx, *, member: discord.Member = None):
  member = ctx.author if not member else member
  embed = discord.Embed(title=f"{member.name}'s avatar, color = member.color , timestamp= ctx.message.created_at")
  embed.set_image(url=member.display_avatar.url)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=ctx.author.display_avatar.url)
  await ctx.send(embed=embed)```
heavy swift
#

oh oops, you should have author after member, so keep everything you have now just make it member.author.display_avatar.url, that's my bad

slate swift
#

Nvm

slate swift
#

that happens

#
async def avatar(ctx, *, member: discord.Member = None):
  member = ctx.author if not member else member
  embed = discord.Embed(title=f"{member.name}'s avatar, color = member.color , timestamp= ctx.message.created_at")
  embed.set_image(url=member.display_avatar.url)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=member.author.display_avatar.url)
  await ctx.send(embed=embed)```
heavy swift
#

I'll specify, embed.set_image(url=member.author.display_avatar.url) and you can change your footer back to what it was before

grizzled reef
#

Why my bot says it has no attribute send

heavy swift
#

how are u sending

grizzled reef
#

Nvm

slate swift
#
async def avatar(ctx, *, member: discord.Member = None):
  member = ctx.author if not member else member
  embed = discord.Embed(title=f"{member.name}'s avatar, color = member.color , timestamp= ctx.message.created_at")
  embed.set_image(url=member.author.display_avatar.url)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=member.author.display_avatar.url)
  await ctx.send(embed=embed)```
shrewd apex
#

u don't need the * tho pithink

#

just do member or CTX.author

#

embed.timestamp = datetime.datetime.utcnow()

#

just do member.display_avatar

#

for image

#

icon_url also just do member.display_avatar

slate swift
# shrewd apex icon_url also just do member.display_avatar
async def avatar(ctx, member: discord.Member = None):
  member = ctx.author if not member else member
  embed = discord.Embed(title=f"{member.name}'s avatar, color = member.color , = datetime.datetime.utcnow()")
  embed.set_image(url=member.display_avatar)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=member.display_avatar)
  await ctx.send(embed=embed)```
#

so this?

shrewd apex
#

umm no

heavy swift
slate swift
shrewd apex
#
@client.command()
async def avatar(ctx, member: discord.Member = None):
  member = member or ctx.author
  embed = discord.Embed(title=f"{member.name}'s avatar", color = member.color)
  embed.timestamp = datetime.datetime.utcnow()   embed.set_image(url=member.display_avatar)
  embed.set_footer(text=f"Requested by {ctx.author}",icon_url=member.display_avatar)
  await ctx.send(embed=embed)
hushed galleon
# slate swift

btw this error means you dont have dpy 2.0 installed, the equivalent code for dpy 1.7 would be member.avatar_url

plucky vector
slate swift
#

@shrewd apex

#

I did this and there's errors

shrewd apex
#

?

grizzled reef
#

Guys I wanna get a message object, so in on_message I wanna get the message and store it, then in a command I wanna make it so it replies to that message but how do I make it know the exact message I want it to reply to?

shrewd apex
#

u didn't even copy paste properly

slate swift
slate swift
shrewd apex
#

sigh just learn some python

slate swift
slate swift
shrewd apex
#

bruh import date time

#

put that set_image in new line

heavy swift
shrewd apex
grizzled reef
#

I wanna have an on_message filtering a word in specific. Then I want it so when I do a command my bot replies to the message that it identified

shrewd apex
#

import datetime

#

thats a lib

slate swift
#

when i imported it turned into that

shrewd apex
#

yeah fine now

#

also hopefully u have 2.0

slate swift
shrewd apex
#

u didn't upgrade

#

update it to 2.0

plucky vector
#

@shrewd apex

slate swift
hushed galleon
heavy swift
# grizzled reef Its in another command

In the on_message, store the message author id & message id in a dictionary whenever ur check is called. Then in your command, if your dictionary has things in it, get that message id and ctx.reply to it

grizzled reef
heavy swift
#

1stly You'd use the author as a key in your dictionary then store their message id as a value:

stored_msg = {}

@on_message(message)
  if message.content = "hey":
    stored_msg[message.author.id] = message.id
grizzled reef
#

Oh

slate swift
heavy swift
#

pip install -U git+https://github.com/Rapptz/discord.py

grizzled reef
#

Now the hardest part lol

#

Its stored in the dict

sick birch
slate swift
#

because I need 2.0 for my cmd to work

sick birch
#

pip install -U discord

grizzled reef
#

Now to reply to it

@client.command()
async def dls(ctx):

@heavy swift how would I do this?🧐

slate swift
#

I already have?

hushed galleon
#

discord on PyPI is a mirror of the actual package discord.py, and it seems to be out-of-date for now

#

pip uninstall discord and pip install discord.py and you should get 2.0

hushed galleon
#

hm i wonder how those packages would have conflicted

silk fulcrum
#

already 2.0

grizzled reef
#

Now I wanna reply to that message in a command

#

Like I want to do the command and the bot responds to that message

silk fulcrum
slate swift
#

😭😭😭😭😭😭😭😭😭😭

#

So sorry

hushed galleon
# slate swift

you're using a not exactly up to date version of 2.0 but if it managed to install correctly that's alright, though maybe its better to reinstall with the -U option again

slate swift
grizzled reef
hushed galleon
#

2.0 just dropped so id figure most youtube tutorials for dpy are out of date now

#

if they werent already before...

slate swift
hushed galleon
#

try it with the -U flag

slate swan
#

the bot's role is above my highest role tho

silk fulcrum
slate swift
grizzled reef
#

Ohhhh

hushed galleon
slate swift
hushed galleon
#

i dont see a typo there so something seems very screwed with your installation still...

silk fulcrum
#

make sure you restarted your bot or reloaded your cog

heavy swift
#

reload vsc too ig

hushed galleon
#

yeah a bot restart is necessary if you havent done that

silk fulcrum
#

if yes.... the only thing I could imagine of is reinstall discord.py, maybe it'll help

hushed galleon
#

IDE reloading isnt needed

heavy swift
#

true, it's not an extension

hushed galleon
#

if restarting your bot doesnt work, can you show the output of pip list to check if there's any libraries that might be conflicting with dpy?

pliant gulch
hushed galleon
#

oh good catch

pliant gulch
#

In your screenshot where you pip install it goes to your python 3.9 installation

silk fulcrum
#

ill kms if there is py**-**cord 😭

pliant gulch
#

And in your error it says python 3.10

#

So just set your IDE's interpreter to 3.9 or install to 3.10

silk fulcrum
#

ok

pliant gulch
silk fulcrum
#

39

pliant gulch
hushed galleon
#

huh, i never thought of what vscode doesnt do when different global interpreters are selected

silk fulcrum
#

just use venvs 😫

heavy swift
#

Love how we've found like 20 errors trying to fix 1 lol

silk fulcrum
#

wth is this

heavy swift
#

🤨

pliant gulch
#

Not snaps 💀

silk fulcrum
#

disruptions

#

what does that mean

heavy swift
#

You have 11 days left 😔

silk fulcrum
#

btw how to close the app

#

i closed discord, I exited it completely, I exited both of my discords

#

nothing removes this

grizzled reef
#

I got temporarily blocked from accessing the api due to trying to fix an error in my code(got rate limited) around how much it would take to go away?

pliant gulch
#

Is this linux? O'

silk fulcrum
#

yes

pliant gulch
#

Okay just pkill discord

grizzled reef
pliant gulch
heavy swift
silk fulcrum
#

im not sure what that does

pliant gulch
#

My window manager closes it properly but sometimes it doesn't

silk fulcrum
#

oh, i thought it would delete it completely

pliant gulch
#

Pkill (process kill)

silk fulcrum
#

because i did snap remove discord

pliant gulch
#

Your using snapcraft so

silk fulcrum
#

but snap is stupidness

#

so my discord is still here

pliant gulch
#

Sounds like snaps 💀

hushed galleon
pliant gulch
#

I just use prebuilt binaries from AUR or use app images

heavy swift
#

Also just as an fyi, fetch_message is an api call so extensive use could get you ratelimited (50 in a second, which is hard to hit alone) but replit, as you may or may not know uses shared ip address, so if 1 person abuses the api, everyone on that ip gets temp banned @grizzled reef

grizzled reef
heavy swift
#

Are u still ratelimited?

grizzled reef
#

Let me see

silk fulcrum
grizzled reef
silk fulcrum
heavy swift
#

It can be used multiple times, but as long as you aren't sending the message like 50 times in a second you're fine

grizzled reef
#

Ohh lmao

heavy swift
#

but since replit uses shared ips, you could be reaching that threshold a lot easier

pliant gulch
#

Fetching messages are 5/5s

grizzled reef
#

Ok ok

grizzled reef
pliant gulch
#

Message fetching ratelimits also depend on buckets

#

So it's pretty much gonna be very hard to get ratelimited just fetching messages alone

heavy swift
#

Yeah there's also sending the message on top of that

pliant gulch
#

It'll depend on the bucket

#

If you were to send a message in, lets say CHANNEL1 it'll take a request out of x-ratelimit-remaining for that channel bucket, e.g CHANNELS/:CHANNEL_ID/MESSAGES

#

Then if you were to send a message in CHANNEL2 it'll be a different bucket, so it'll have a different limit pool

heavy swift
#

Oh I get you

silk fulcrum
#

POV: no

pliant gulch
#

when you need sudo just to remove snaps that speaks a lot

silk fulcrum
#

lolmao

pliant gulch
#

Imagine trying to share requests over many guilds

silk fulcrum
#

now when I do sudo apt remove discord it says me to install it via snap

#

i think that's just unreachable :(

pliant gulch
#

sudo apt?

silk fulcrum
#

i think i found something nice

silk fulcrum
pliant gulch
#

I don't know much about ubuntu

heavy swift
#

Am I understanding this correctly

silk fulcrum
grizzled reef
pliant gulch
#

Buckets are based on the endpoints of the API

#

The messages endpoint has it's own bucket, a response callback has it's own bucket

#

ETC, Your wrappers' will form buckets off major parameters

#

Major parameters being defined from the discord API as channel_id, guild_id and webhook_id

heavy swift
grizzled reef
#

Oh ok

unkempt canyonBOT
#

discord/http.py line 308

return f'{self.method} {self.path}:{self.metadata}'```
pliant gulch
#

Heres what discord py does IG

silk fulcrum
heavy swift
#

got you, I'll research it once I have time

grizzled reef
#

I do ;test

heavy swift
#

author_id isn't defined

limber bison
heavy swift
#

ctx.author.id

limber bison
grizzled reef
heavy swift
#

that variable isn't defined though, you're accessing the key in the dict by using ur own id

#

because that key is the same as ur id

grizzled reef
#

So how should I do it then?

robust fulcrum
#

Guys i saw many people have a folder called utilis in their discord bot . Whats use of that?

heavy swift
#

just replace author_id to ctx.author.id

vocal snow
heavy swift
#

@grizzled reef How do you have your on_message and dictionary setup btw, just so I know there's no issues there

grizzled reef
#

Hm it didnt run, let me send full

limber bison
#

I use view as

Class MyView(view)
@button.... {Stuff}

@bot.command()
{Stuff}
view = MyView()
Await ctx.send("ok" , view =view)

Is this good way or i missing some batter way ?

grizzled reef
#

@client.event
async def on_message(message):
    msg = message.content
    if "not" in message.content:
        print("hi")
        msgs[message.author.id] = message.id

@client.command()
async def test(ctx):
    print
    message_id = msgs[ctx.author.id]
    print("1")
    message = await channel.fetch_message(message_id)
    print("2")
    await message.reply("fck")
    print("3")```
heavy swift
#

replace channel with ctx *

#

hold up

grizzled reef
#

await ctx.fetch_message?🧐

heavy swift
#

correct, but it looks like you want to reply regardless of the channel

grizzled reef
#

Looks weird

grizzled reef
#

I mean its only gonna be in ine channel

#

One*

robust fulcrum
heavy swift
grizzled reef
#

It dont send the prints

#

OH

heavy swift
grizzled reef
#

Oh yeah right below the event

heavy swift
#

yep

hushed galleon
pliant gulch
#

Would love if discord.py added a cache driver class so you could, for an example just write an async redis cache

#

Well you would need to serialise which is no big problem, but discord.py objects are at best half serialisable for some reason iirc

#

Plus you could also add a weakref cache instead of the normal one for memory efficiency

grizzled reef
heavy swift
#

shouldnt be in the if statement

grizzled reef
#

🤦‍♂️

#

Whats going on w my brain today lol

grizzled reef
#

Finally

heavy swift
#

nice u got it to work?

grizzled reef
#

Yeah im testing some other stuff

limber bison
#

What client.process_commands dose ?

heavy swift
#

It lets you use other commands without having on_message have all the spotlight

#

I believe you can just use @bot.listen() without having to worry about that

alpine swan
#

there any place that lists all the global discord emojis? keep getting sights that want to give you emojis...

#

(other then discord itself, kinda hard to get a good look at them all)

vocal snow
alpine swan
#

thanks!

robust fulcrum
#

Guys how to fix this cogs error?

vale wing
robust fulcrum
#

Ye

vale wing
#

Don't

#

Remove the try-except and you will see the actual traceback

robust fulcrum
vale wing
#

What's the point of handling cog loading exceptions anyway, all components must function

vale wing
alpine swan
#

mmm i'm trying to do slash commands ( / ) because i guess that's the way to do them nowadays? but when I try and use them in DMs with the bot i get this

silk fulcrum
#

completely uninstalled snap, if now rich presence won't work ill... idk what ill do

#

how....

slate swan
silk fulcrum
slate swan
slate swan
silk fulcrum
#

I guess something out of this list:

  • Your bot doesn't have these permissions (need at least one to work): Administrator, Manage Server, Manage Roles
  • Your bot's role is lower than your's in hierarchy
#

if not that, send the code

slate swan
silk fulcrum
slate swan
#

k wait

#
class PersistentView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(emoji=":blackOne:", style=discord.ButtonStyle.grey, custom_id='persistent_view:green')
    async def green(self, interaction: discord.Interaction, button: discord.ui.Button):
        button.disabled=False
        try:
          eman = interaction.user.guild.get_role(960601299529904218)
          if eman in interaction.user.roles:
              await interaction.user.add_roles(eman)
              embed = discord.Embed(description="You'll shortly recieve <@&960601299529904218> role.", color=0xffffff)
              await interaction.response.send_message(embed=embed)
          else:
              if eman not in interaction.user.roles:
                await interaction.user.remove_roles(eman)
                embed = discord.Embed(description="Removed <@&960601299529904218> role from you.", color=0xffffff)
                await interaction.response.send_message(embed=embed)
        except discord.Forbidden:
            await interaction.response.send_message("I don't have enough permissions to give you the role oryour highest role is above my role.", ephemeral=True)
silk fulcrum
#
  • this if (screenshot) is completely useless
  • You are doing exactly the opposite of what you want to do (i think so): if user HAS a role it will GIVE it to him, and if the user DOESN'T HAVE a role it will REMOVE it
silk fulcrum
#

lol

slate swan
# silk fulcrum lol

Still I’m getting this :

I don't have enough permissions to give you the role oryour highest role is above my role.

limber bison
#

How can I remove view from a message?

robust fulcrum
#

Do view=None

silk fulcrum
limber bison
robust fulcrum
#

What you trying to say?

limber bison
#

Like msg.edit(view = none)

#

This right ?

robust fulcrum
#

No

limber bison
#

Need to pass content ?

robust fulcrum
#

msg.edit(view = None)

#

n is to be capital

silk fulcrum
limber bison
#

Hahaha

silk fulcrum
#

and if remove view completely then yes .edit(view=None)

alpine swan
#

man discordpy is so convoluted, spending so much time trying to figure out permissions issues, patterns using bots/cogs -.-

silk fulcrum
alpine swan
#

trying to use slash commands, dont know if discordpy supports them?

alpine swan
#

dont know what permission that requires to get a list of slash commands in a DM

#

I'll check that stuff out tho thanks

silk fulcrum
alpine swan
#

what does self.tree.copy_global_to supposed to do here?

    async def setup_hook(self) -> None:
        await self.add_cog(MySlashCog(self))
        self.tree.copy_global_to(discord.Object(id=123456789098765432))
        await self.tree.sync()
slate swan
silk fulcrum
#

shock: owner of gist replies

slate swan
#

lmao

alpine swan
#

I tried reading the explanation, I dont see anything exactly on that, but I might be looking at the right area -.-

slate swan
#

it just makes the slash commands private to one guild

alpine swan
#

oh, i was reading explanation for cog

#

thus why I said might not have been in the right area heh

slate swan
#

ufff that's why it is recommended not to skip the reading part

alpine swan
#

eh I try and read as much as I can, but need to read the parts that are pertinent to ensure I'm looking at the right solution for my problem heh

#

kinda hot and frustrated as it is heh

slate swan
#

yeah most of the explanation is in the SlashClient example so

heavy swift
#

@grizzled reef why without fetch

slate swan
#

fine, tinme to bel;dn back into the shadows

#

professional phyone typo moment

robust fulcrum
#

Guys i want to make such that all the commands can be used by the bot owner and i can provide it ids even the owner have member role it can use all command
How can I do that?

heavy swift
#

you need a check function

#

have a list containing all the ids that u want to have perms

silk fulcrum
#

If you use check decorators such as @has_permissions you can customise them and add something like if ctx.author.id == bot.owner_id: return True

robust fulcrum
silk fulcrum
#

what does that owner func do

robust fulcrum