#discord-bots

1 messages Β· Page 455 of 1

slate swan
#

that'd be cool af

reef shell
#
@bot.group(invoke_without_command=True)
async def help(ctx):
    #stuffs```
#

and then i have some commands like:

@help.command()
async def emoji(ctx):
    #cmd des.
#

now can i use an error handler for all commands under that group?

#

I used @help.error

#

but it works only when the main help cmd raises exception

novel rampart
#

what is the error

full lily
#

you need the pynacl library

reef shell
novel rampart
#

ok

maiden fable
#

no

slate swan
#

Whats nextcord?

maiden fable
#

pip install discord.py[voice]

boreal ravine
wooden garnet
#

im backkk

#

noone helped me tho

boreal ravine
#

@wooden garnet wut u tryna do?

#

maybe I could help

wooden garnet
boreal ravine
#

u wanna add en emoki to the status? @wooden garnet

wooden garnet
#

aswell

#

but the activity doesn't show up

#

so I'm trying to fix that first

slate swan
#

i just realized something

#

do you have intents enabled??

#

more specifically the presence intents

wooden garnet
#

intents?

slate swan
#

Yep yep

slate swan
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

You'll have to enable them both in your code, and developer portal. Let me know if it works!

wooden garnet
#

guess il do that

#

what does it do tho

slate swan
#

I'm not sure how to fully explain it, but it's most likely what's causing your issue

thorny current
#

Some one help me here pls

slate swan
#

@thorny current Can you say what the attribute error is?

#

The full error isn't shown

wooden garnet
#

the switch is disabled

slate swan
slate swan
slate swan
slate swan
wooden garnet
slate swan
wooden garnet
#

and they're talking ab verification but I can't verify if my bot is in one server

slate swan
# thorny current

I'm not really getting anything from it, I'm sorry, I need the error

wooden garnet
#

@slate swan

thorny current
#

;-; I just ss the whole error part

wooden garnet
#

@slate swan this is what happens when I try to verify

slate swan
slate swan
thorny current
slate swan
#

Can you say that the attribute error is?

thorny current
#

No

slate swan
thorny current
#

I am just started so I understand very little

slate swan
wooden garnet
#

guys does anyone know what I should do?

slate swan
#

bot = commands.Bot(**kwargs, status=discord.Status.idle)

#

@slate swan

#

I'm stuck at the part where you can change the status to a custom status

wooden garnet
#

same

#

lol

slate swan
#

@wooden garnet

#

this can't be put to on for you??

#

u couldn't do that before

wooden garnet
#

theres a like street sign thing

#

its disabled lol

#

lol I went in to inspect element and enabled it and now I saved the changes but I doubt it'll work

#

yea it doesn't stay

round quarry
#

Why every time I execute the "serverinfo" command, I get "Owner: None" ?, I am occupying: {ctx.guild.owner}.

round quarry
#

what is that? shipit

slate swan
slate swan
brazen raft
slate swan
slate swan
round quarry
slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

all

#

@slate swan

slate swan
#

knew it lol

slate swan
slate swan
#

me is shiet

slate swan
#

what

#

oh

#

just above/below intents.members = True

brazen raft
#

If your bot is unverified and is in 75+ servers then it's not going to be given privileged intents.

slate swan
slate swan
#

oh bruh

#

well

#

@slate swan go to your developer portal

#

and make sure it's on as well

slate swan
slate swan
#

already it was on still not working

round quarry
slate swan
pale turtle
slate swan
slate swan
pale turtle
#

Ok

slate swan
#

Can you for the last time send your bot constructor

#

I'm sorry either i'm missing something or i don't really know why it's happening

reef shell
#

seems like nobody's gonna help me πŸ˜”

slate swan
slate swan
slate swan
#

Sorry

#

😐

#

"How to make a error handler for all commands in a command group" right?

reef shell
#

yea yea

slate swan
slate swan
reef shell
slate swan
#

that's just a command handler

#

he wants a command handler for a group

slate swan
#

sorryi thought i could be of some help

reef shell
slate swan
slate swan
#

Haven't you considered just trying on_command _error event

#

So it's global

#

Makes it a lot easier tbh

reef shell
#

mhm gotta try

slate swan
#

cool

#

it should work on all errors so should work

slate swan
stiff nexus
slate swan
slate swan
unkempt canyonBOT
slate swan
#

should be this

stiff nexus
#

how?

#

sent the error message like this if someone deletes the message which was being edited

slate swan
#

so well, if there's an error in doing that, it should be because it got deleted maybe?

#

so try making an error handler

stiff nexus
#

which error is that

boreal ravine
#

@stiff nexus how?

#

e

stiff nexus
boreal ravine
#

no tf?

slate swan
slate swan
stiff nexus
#

then from no where u come and ping me

slate swan
#

he no stock

slate swan
lunar grove
#

yooo i got a question

lunar grove
#

whats the line used to detect a member joining the server

stiff nexus
boreal ravine
#

@lunar grove on_member_join

stiff nexus
#

also guys chill with the pings

lunar grove
slate swan
unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
stiff nexus
#

i am still here

slate swan
#

enable intents.

slate swan
boreal ravine
#

@stiff nexus then?

slate swan
stiff nexus
#

ok

boreal ravine
#

e nvm

slate swan
#

Make it edit a message, and delete it, and see what error it raises

#

It's probably gonna be msg not found idk

stiff nexus
slate swan
#

help me how to find bot members in discord meaning bot accounts or bot added separate from members

#

number of bots in a guild?

#

bot_list = len(u for u in ctx.guild.members if u != bot.user)

reef shell
#

I just noticed some ghostly behavior of my bot
It sends an error message out of nowhere
and the error message is of help command group

@help.error
async def help_error(ctx, error):
    if isinstance(error, discord.ext.commands.errors.CommandError):
        #the error msg
slate swan
#

uhm

slate swan
boreal ravine
#

@slate swan wut

reef shell
slate swan
reef shell
#

wdym

boreal ravine
#

ok.

boreal ravine
#

uh

reef shell
slate swan
#

uh..

#

ok

boreal ravine
#

lol

slate swan
#

Why keep_alive.py is not making on my replit of python

slate swan
#

Yeh already did and all but still

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#

It's not and bot it's an hosting tool pithink

#

But still in others language it's COMMING

slate swan
slate swan
stiff nexus
lament mesa
#

Trying to edit a message which doesn't exist will raise discord.NotFound iirc

#

discord.NotFound can be raised for multiple reasons

lament mesa
#

no

#

!d discord.NotFound

unkempt canyonBOT
#

exception discord.NotFound(response, message)```
Exception that’s thrown for when status code 404 occurs.

Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/stable/api.html#discord.HTTPException "discord.HTTPException")
lament mesa
#

I'm not 100% sure though

#

Try and see

slate swan
#

f"{str(len(client.guilds))}"

slate swan
stiff nexus
stiff nexus
lament mesa
slate swan
stiff nexus
# lament mesa Sorry, what do you mean?
    @commands.Cog.listener()
    async def on_command_error(self,ctx, error):
      if isinstance(error, commands.CommandNotFound):
        return
      if isinstance(error,discord.NotFound):
        message = f":not: The hack ended because someone deleted the message I was going to edit"
      else:
        message = f":not: {error}"
      await ctx.reply(message)

error it gave is py Command raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message

stiff nexus
lament mesa
#

yeah, not found is raised

stiff nexus
#

but its not sending my error message

lament mesa
slate swan
stiff nexus
slate swan
#

yes

stiff nexus
#

u got ( before len

slate swan
stiff nexus
#

just {len(client.guilds)}

slate swan
#

ohk

slate swan
lament mesa
unkempt canyonBOT
#

getattr(object, name[, default])```
Return the value of the named attribute of *object*. *name* must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, `getattr(x, 'foobar')` is equivalent to `x.foobar`. If the named attribute does not exist, *default* is returned if provided, otherwise [`AttributeError`](https://docs.python.org/3.10/library/exceptions.html#AttributeError "AttributeError") is raised.

Note

Since [private name mangling](https://docs.python.org/3.10/reference/expressions.html#private-name-mangling) happens at compilation time, one must manually mangle a private attribute’s (attributes with two leading underscores) name in order to retrieve it with [`getattr()`](https://docs.python.org/3.10/library/functions.html#getattr "getattr").
stiff nexus
slate swan
# stiff nexus send raw code

status = [f" {len(client.guilds)} servers!! \n Use $help for Command List",f"{len(client.guilds)} servers!! \n Use $invite for inviting me",f" {len(client.guilds)} servers!! \n Use $vote for voting me"]

unkempt canyonBOT
slate swan
#

!e status = [f" {len(client.guilds)} servers!! \n Use $help for Command List",f"{len(client.guilds)} servers!! \n Use $invite for inviting me",f" {len(client.guilds)} servers!! \n Use $vote for voting me"]

unkempt canyonBOT
#

@slate swan :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 'client' is not defined
cinder horizon
#

reeeeeeeeeeeeeeeeeeeeeeeeee.......aight

slate swan
distant oasis
#

hey so im coding a bot for my friends server, and ofc i need to give the bot admin perms but i cant grant them, is there any way he can grant them from his account to my bot?
or does giving the bot admin role in the server just work?

cinder horizon
slate swan
slate swan
distant oasis
slate swan
#

?

distant oasis
slate swan
#

yes but

slate swan
cinder horizon
slate swan
#

I need help pls

distant oasis
#

running the command to import discord bot, (covering the token) and it opens a file instead of running, where should i save this file?

lament mesa
#

What dpy version are you using?

slate swan
#

3.7.9

lament mesa
slate swan
#

Did you install discord instead of discord.py?

#

I remember someone told me mirror package has this issue

hasty iron
#

the file is called nuke.py

#

its probably copied

slate swan
#

πŸ‘€ ..

slate swan
slate swan
slate swan
#

nuke a what

hasty iron
#

a text channel

slate swan
#

yes

lament mesa
#

Update it

#

pip install -U discord.py

hasty iron
#

wtf

slate swan
#

ok

hasty iron
#

how do you have 0.16

lament mesa
#

lol

slate swan
#

He did pip install discord.py==0.16 blobdoubt

lament mesa
slate swan
#

Imagine asking for help with pass_context

velvet crest
#

how can i disable a button once its been clicked in dpy 2.0

slate swan
#

Set the <button>.disabled = True and edit the whole message with the new view

distant oasis
#

hey so trying to just make the bot react to join and leave through the cmd but its not working like the tutorial video on yt

slate swan
#

Is there like a way to inplement a status like uptimerobot or npm2 to ur discord bot, it’s hosted on windows vps tag if u have an answer or dm me

slate swan
#

!e print('hi')

unkempt canyonBOT
#

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

hi
slate swan
#

#bot-commands @slate swan

velvet crest
slate swan
#

While initialising view, pass it in super().__init__(timeout=...)

distant oasis
#

hey so trying to just make the bot react to join and leave through the cmd but its not working like the tutorial video on yt

slate swan
distant oasis
#

ah okay, should i stop following the tutorial? i mean it worked with getting the bot online

#

from mid 2019

slate swan
#

Lucas?

distant oasis
#

yes xD

slate swan
distant oasis
#

ahhh alot of text, scary

#

okie :p im tryna make it like a ping pong bot, where if someone says something it says something back

slate swan
#

Nah that's a lot better than the current tutorial you're watching. blobpain

distant oasis
#

what do i do with all this?

slate swan
#

It's fine, just a bit poor way of doing. Read that guide

distant oasis
#

so i delete it all?

slate swan
#

You can if you like

#

This is just a poor way of doing, and many people don't like this

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

distant oasis
#

idk what any of that means

slate swan
#

Thats why your on join/leave events not working

#

Read about intents

slate swan
distant oasis
#

ill stick to tutorial like akshu said

slate swan
#

Yes

#

Good point

buoyant ore
#

i need

#

help

#

pls

#
@client.command()
async def farm(ctx):
  await open_account(ctx.author)
  user = ctx.author
  fruits = ["apples", "bananas", "oranges"]
  totalmax = random.randrange(30)
  workout = (totalmax*2.50)
  await ctx.send(f"You got {totalmax}{fruits.choice} , therefore you earned Β£{workout}")
  users = await get_bank_data()
  users[str(ctx.author.id)]["wallet"] += workout
  print(users)
  with open ("Users.json", "w") as f:
    json.dump(users,f)
distant oasis
#

@slate swan the guide doesnt rly asy how to start the bot like the other one, sorry if im not supposed to ping u

#

it just goes from creating teh bot on the website to "hello world"

slate swan
#

The "hello world" has everything related to starting and all.

distant oasis
#

im blind then xD

slate swan
distant oasis
#

so i just put the first 2 lines of code in and my bot should just boot up?

#

ik it says below to input token

slate swan
#

Continue reading, it's explained in steps

lone pelican
#

hello. where do i ask my doubts?

distant oasis
#

alsop why did u keep putting blobpain when u said lucas's name?

slate swan
lone pelican
#

thanks

slate swan
#

Don't watch yt tutorials for discord bot, most of them are not very nice.

distant oasis
#

ah k

#

lucas hasnt uploaded in 5 months AG_Wut

#

3months*

slate swan
distant oasis
#

?

clever wind
#
async def result(ctx, result):
  result = str(result)

  Team_A_channel = client.get_channel(870969338901954606)
  Team_B_channel = client.get_channel(870969338901954607)

  Team_A_members = Team_A_channel.members
  Team_B_members = Team_B_channel.members

  Team_A_members_id = []
  for member in Team_A_members:
      Team_A_members_id.append(member.id)
  Team_B_members_id = []
  for member in Team_B_members:
      Team_B_members_id.append(member.id)

  Team_A_members_mention = []
  for member in Team_A_members:
      Team_A_members_mention.append(member.mention)
  Team_B_members_mention = []
  for member in Team_B_members:
      Team_B_members_mention.append(member.mention)
  
  winning_team_lobby1 = ""

  if result in ['Team A', 'team a', 'Team a', 'team A']:
    winning_team_lobby1 = "Team A"
    cursor.execute("UPDATE main SET Price = user_elo + (?) WHERE user_id IN [?]", (elo_win, Team_A_members_id))
    db.commit()

user_elo doesn't change even after i use the cmd. no errors as well. what wrong? ping on reply

hasty iron
#

why is it an async function

distant oasis
#

it says at this point it should be working

#

@slate swan nothing

#

i ran it, the terminal is also blank if that means anything

slate swan
#

Bot is running, you're just missing on_ready event.

distant oasis
#

did i miss it on the hello world page?

slate swan
#

You don't need it

#

It's just to tell you that bot is ready

distant oasis
#

okay

clever wind
distant oasis
#

but when i type "hello" in the disc server with the bot nothing happens

lament mesa
distant oasis
#

im stupid.... xD

#

is there a way to make it withouth the !?

#

like i wanna make the bot reply to certain things, like if my friend says something itll reply back with some dumb inside joke we have

slate swan
#

I think, just set it to "", but it'll listen to every message then and spam your console probably

#

Use on_message event

distant oasis
#

i mean can i make it reply to hello without the !?

#

"!" ?*

slate swan
distant oasis
#

is there a part in the tutorial u sent me, cause idk how to do that

slate swan
#

There's a guide about listeners, read that and you'll get how to use them

distant oasis
#

k

#

dont take the reply seriousily, inside joke iwth my friends :p

#

i got that bit of code from stack overflow, but idk half the words they use lol

slate swan
#

That's not how you use listeners blobpain
Just please continue reading it, once you finish it, your most of the doubts will be cleared

distant oasis
#

so i tried reading about listeners in python, but it was just confusing, but i found a different bit of code and now it works πŸ˜„

slate swan
#

Listeners are not a part of python. If you don't know basics and a bit of oop, please stop dpy and bots and instead learn python first

distant oasis
#

meh its fine i got the bot working :p, learning python fully isnt rly a goal of mine, ill be doing bits of it in college this year, i dont rly learn from reading, i learn from watching ppl

#

so when u sent me like that page with a chunk of text, i kinda just copy pasted the highlighted parts cause reading all that was just not in my attention span

clear comet
#

I want a help of embeds..... Just I want a command like !embed <colour in hex code> <description>, I know how to get description but I want colours in hex code like (.embed #fff00 this is an embed)

vocal shoal
#

how do i get the day that a member joined a server in?

#

like when they joined.

agile goblet
#

!d discord.Member.joined_at

unkempt canyonBOT
#

A datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.

vocal shoal
#

thx pepethumbsup

slate swan
#

instead of list of names i want list of members but in numbers

waxen granite
#

i am trying to get all members with a certain permission in the guild, how can i do it?

agile goblet
agile goblet
#

or the ids of the users

slate swan
slate swan
clear comet
clever wind
#
async def result(ctx, result):
  result = str(result)

  Team_A_channel = client.get_channel(870969338901954606)
  Team_B_channel = client.get_channel(870969338901954607)

  Team_A_members = Team_A_channel.members
  Team_B_members = Team_B_channel.members

  Team_A_members_id = []
  for member in Team_A_members:
      Team_A_members_id.append(member.id)
  Team_B_members_id = []
  for member in Team_B_members:
      Team_B_members_id.append(member.id)

  Team_A_members_mention = []
  for member in Team_A_members:
      Team_A_members_mention.append(member.mention)
  Team_B_members_mention = []
  for member in Team_B_members:
      Team_B_members_mention.append(member.mention)
  
  winning_team_lobby1 = ""

  if result in ['Team A', 'team a', 'Team a', 'team A']:
    winning_team_lobby1 = "Team A"
    cursor.execute("UPDATE main SET Price = user_elo + (?) WHERE user_id IN [?]", (elo_win, Team_A_members_id))
    db.commit()β€Š

user_elo doesn't change even after i use the cmd. no errors as well. what wrong? ping on reply

agile goblet
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.

distant oasis
#

Hey, so i have 3 sets of "on_message" commands, but only the last one makes the bot reply, i tried swapping the words and its only the last in the string, can anyone help

slate swan
agile goblet
slate swan
#

see @agile goblet

slate swan
agile goblet
#

just get the length of bot.guilds and bot.users

distant oasis
#

only the bottom one works, any reason y? do i need to seperate em somehow

agile goblet
#

especially if its just 2 lines per event

slate swan
slate swan
clear comet
slate swan
distant oasis
agile goblet
#

use elif lmao

distant oasis
#

me?

agile goblet
slate swan
#

and then just leave it right there

clear comet
agile goblet
#

int(colour, 16)

#

and remove the # from the string

slate swan
#

Instead learn python basics before dpy

agile goblet
#

and please, go over the basics of python again

#

if you dont know how to use methods then dpy is only gonna confuse you more

clear comet
#

Ok

#

But for now please give me the code

slate swan
maiden fable
#

cat_headbang good for me that I ain't in their place now. I also started with dpy without even knowing how to call a function

distant oasis
agile goblet
maiden fable
slate swan
#

We don't give you the code, this is a help channel. You can ask for help but please learn python first blobpain

clear comet
#

Oh 12:00

distant oasis
#

?

maiden fable
#

Learn more Python. My path was a difficult one, and I don't recommend anyone going on it

agile goblet
#

I sent the code bruh 😭

distant oasis
#

im only here to code this one bot, im not interested in full on learning python

clear comet
distant oasis
#

not particually something i enjoy shrug

noble helm
#

anybody still know the pokΓ©cord bot? well it got that feature that a pokΓ©mon disappears after some time. how do i implement this?

slate swan
#

h-
h-
hun-
blushes

maiden fable
noble helm
#

what have i stumbled into

maiden fable
#

πŸ˜‚

agile goblet
#

hey h-hunter 😊

#

cant believe i just typed that out

vocal shoal
#

how do i get the nitro status of a member?.

maiden fable
slate swan
maiden fable
distant oasis
maiden fable
maiden fable
agile goblet
slate swan
noble helm
noble helm
#

okay

slate swan
#

I don't remember, but in this help channel notlikeblob

noble helm
maiden fable
#

!d discord.ext.commands.Bot.wait_for @noble helm

unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/stable/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
maiden fable
clear comet
#

I want to make a seperate files of command how do I make it.

maiden fable
unkempt canyonBOT
#

class discord.ext.commands.Cog```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
noble helm
#

damn my habits

clear comet
slate swan
noble helm
#

always typing check with an a

maiden fable
maiden fable
slate swan
#

Typehinting on strict mode is overkill notlikeblob

maiden fable
#

I bet most of the people say him a she cz of his pfp

slate swan
#

Maybe GWcmeisterPeepoShrug

maiden fable
slate swan
#

Most of my code is just # type: ignore coz I can't figure out how do fix blobpain

maiden fable
#

Ah mypy?

noble helm
slate swan
#

Pyright notlikeblob Idk exactly what's mypy

viscid lark
#

how to display member banner?

maiden fable
#

Available in 2.0

slate swan
#

Not available in 1.7.3

maiden fable
#

member.banner

slate swan
#

Also that only works with fetch

maiden fable
#

Hmm, idk about that. I never saw the docs for 2.0 lmao

#

even tho I am helping dev a dpy fork

#

No

slate swan
#

Discord docs in any other website..? kannaconfused I don't think something like that exists

maiden fable
#

Indeed

slate swan
#

Though discord'd docs are pretty easy

viscid lark
#

in cmd

maiden fable
#

discord.version

slate swan
agile goblet
maiden fable
#

!d discord.version

unkempt canyonBOT
#

discord.__version__```
A string representation of the version. e.g. `'1.0.0rc1'`. This is based off of [**PEP 440**](https://www.python.org/dev/peps/pep-0440).
slate swan
#

Lol

maiden fable
slate swan
#

In cmd

maiden fable
#

Breh, I use Python in cmd

reef trail
#
@commands.command()
@commands.cooldown(rate=1, per=10, type=commands.BucketType.user)
@commands.guild_only()
@commands.check(permissions.is_owner)
async def hoist(self, ctx: commands.Context):
    """Changes users names that are hoisting themselves (Ignores Bots)"""
    chars = ['!', '.', '-', '_', '*', '(', ')', '=', '+', '^', '&', '~', '#', '$', ':', ';', '?', '<', '>', '{', '}', '[', ']', '|', '\\', '"', "'", '`']
    temp = {}
    failed = 0

    initial = await ctx.send("Kk, changing peoples names. This'll take some time so please be patient!")
    async with ctx.typing():
        for member in ctx.guild.members:
            if not member.bot:
                for char in chars:
                    if member.display_name.startswith(char):
                        try:
                            await member.edit(nick=member.display_name.replace(char, ''))
                        except discord.HTTPException:
                            try:
                                await member.edit(nick="No Hoisting")
                            except discord.Forbidden:
                                failed += 1
                        except discord.Forbidden:
                            failed += 1
                        temp.update({char: temp.get(char, 0) + 1})
                    if member.display_name[0].isdigit():
                        try:
                            await member.edit(nick="No Hoisting")
                            temp.update({"numbers": temp.get("numbers", 0) + 1})
                        except:
                            failed += 1
    stats = '\n'.join([f"`{char}` - `{amount}`" for char, amount in temp.items()])
    await initial.edit(content=f"I have unhoisted `{sum(temp.values())}` nicks and failed to edit `{failed}` nicks.\nHere are some stats:\n\n{stats}")

``` whatcha think
maiden fable
#

Broooo

#

!paste please

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.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

Woah

reef trail
#

Its fine

maiden fable
#

Pretty please πŸ₯ΊπŸ˜’

slate swan
#

Lmfao

maiden fable
reef trail
#

anyway

#

what do you think

slate swan
#

I'm on phone right now sorry-

#

It's so hard to read lmao

reef trail
#

I can screenshot it for you

slate swan
#

What's that btw, Looks like a massive loop command

maiden fable
#

Same

reef trail
maiden fable
#

Anyways I'mma crash. Gn

slate swan
#

h- hun- Goodnight blushes

hasty iron
#

no

reef trail
slate swan
#

Night

#

Why this?..

#

You already got httpexception, why trying again?

#

Yeah

reef trail
#

uhhh

#

Hey you bring up a good point

slate swan
#

Also I feel like ratelimits-

clear comet
#

@slate swan I have asked you that how to set custom colour in embeds using hex code and also u answered it but please can you give me the code please I am very confused

reef trail
slate swan
#

Uh ill try I'm on phone so it's quite hard

#

bot owner or guild?

clear comet
#

K but tell me how to use it

reef trail
#

bot owner

slate swan
#

!d discord.ext.commands.is_owner

unkempt canyonBOT
#

discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
reef trail
#

so, only i and the people in my owner config can run it

slate swan
#

Why not this then?

reef trail
#

because i want it to be custom

#

my bot isnt in a team

slate swan
#

Oh okay

reef trail
#

all of my permissions are custom

#

i cant move to a team since its verified

slate swan
#

You can also customize owner_ids then in the bot constructor and will still work fine

reef trail
#

Fair, i do that with jsk

#

But its cleaner to just keep it in my config

slate swan
#

Yeah then it's good (and only option) GWcmeisterPeepoShrug

reef trail
#

anyway, idk why i have that redundant exception

slate swan
# clear comet K but tell me how to use it

@clear comet have a command with description and color args and then initialise an embed and try setting description and color to what was provided in description and color command args, except it probably raised an error of something so just return and do something or use an error handler

clear comet
slate swan
#

Use ctx, *, description, color

slate swan
hasty iron
#

you cant have 2 keyword only arguments

#

in dpy commands

hoary gust
#

Guys is there any tutorial that explains how to make a rest api with quart

clear comet
slate swan
hasty iron
#

think about it

#

if it consumes rest

#

that will happen for the description

#

but what about color

slate swan
#

Okay nevermind you are right

#

Use bot wait for or something

hasty iron
#

is it an embed command?

#

if so, i did it using some wait_fors

clear comet
slate swan
#

Or put description in speech marks will it work blanket? It should right

hasty iron
#

like this !embed "description lol" color?

slate swan
#

Yes

hasty iron
#

yeah but make it positional

#

not keyword

slate swan
#

Yeah

clear comet
#

Ok

distant oasis
#

hey so i got the bot working to an extent, it works with single words, but cant pick the word out of a sentence, can someone tell me how, or tell me what to search cause idk what to search on stack overflow either

slate swan
#

@bot.command(aliases=['ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄','ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‚ΡŒ'])
async def pay(ctx,member:discord.Member,arg:int):
    await ctx.channel.purge(limit = 1)
    with open('economy.json','r') as f:
            money = json.load(f)
    if money[str(ctx.author.id)]['Money'] >= arg:
     msg1 = await ctx.send(
         embed = discord.Embed(title = 'ΠŸΠ΅Ρ€Π΅Π²ΠΎΠ΄ Π΄Π΅Π½Π΅Π³', timestamp = ctx.message.created_at, description=f'{ctx.author.mention}, Π²Ρ‹ ΡƒΠ²Π΅Ρ€Π΅Π½Ρ‹ Ρ‡Ρ‚ΠΎ Ρ…ΠΎΡ‚ΠΈΡ‚Π΅ **ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‚ΡŒ {arg}** ΠΌΠΎΠ½Π΅Ρ‚ {member.mention}?'),
         components = [
             Button(style = ButtonStyle.green, label = 'Π”Π°', emoji = ':heavy_check_mark:'),
             Button(style = ButtonStyle.red, label = 'НСт', emoji = ':x:')
         ])
     responce = await bot.wait_for('button_click', check = lambda message: message.author == ctx.author)
     if responce.component.label == 'Π”Π°':
         #await responce.respond(content = 'Π”Π΅Π½ΡŒΠ³ΠΈ ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ ΠΏΠ΅Ρ€Π΅Π²Π΅Π΄Π΅Π½Ρ‹!')
        msg2 = await msg1.edit(
         emb = discord.Embed(title='ΠŸΠ΅Ρ€Π΅Π΄Π°Ρ‡Π° Π”Π΅Π½Π΅Π³', color=0xB700FF, description=f'{ctx.author.mention} **ΠΏΠ΅Ρ€Π΅Π΄Π°Π»** {member.mention} **{arg}** ΠΌΠΎΠ½Π΅Ρ‚!', timestamp = ctx.message.created_at),
        # #emb.set_thumbnail(url=ctx.author.avatar_url)
         β„–emb.set_footer(text='Комиссии ΠΏΡ€ΠΈ ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄Π΅ составила 5%'),
         components = [
            Button(style = ButtonStyle.green, label = 'Π”Π°', emoji = ':heavy_check_mark:'),
         ]
        )
        money[str(ctx.author.id)]['Money'] -= arg
        money[str(member.id)]['Money'] += arg - (arg / 100 *5)
        channel = bot.get_channel(876731607837458432)
        emb = discord.Embed(title='ΠŸΠ΅Ρ€Π΅Π²ΠΎΠ΄', color=0x0011FF)
        emb.add_field(name='> \*\*ΠŸΠ΅Ρ€Π΅Π²Ρ‘Π»:\*\*',value=f'\`\`\`{ctx.author}\`\`\`')
        emb.add_field(name='> \*\*ΠšΠΎΠΌΡƒ:\*\*',value=f'`\`\`{member}`\`\`')
        emb.add_field(name='> \*\*Π‘ΡƒΠΌΠΌΠ°:\*\*',value=f'\`\`\`{arg} ΠΌΠΎΠ½Π΅Ρ‚`\`\`')
        emb.set_thumbnail(url=ctx.author.avatar_url)
        emb.set_footer(text=f'Авто-Π›ΠΎΠ³ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ ΠŸΠ΅Ρ€Π΅Π²ΠΎΠ΄ΠΎΠ²')
        await channel.send(embed = emb)
     else:
         #await responce.respond(content = 'Π’Ρ‹ ΠΎΡ‚ΠΌΠ΅Π½ΠΈΠ»ΠΈ ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄.')
        emb = discord.Embed(title='ΠžΡ‚ΠΌΠ΅Π½Π° ΠŸΠ΅Ρ€Π΅Π²ΠΎΠ΄Π°',timestamp = ctx.message.created_at, description=f'{ctx.author.mention},Π²Ρ‹ **ΠΎΡ‚ΠΌΠ΅Π½ΠΈΠ»ΠΈ** ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄ **{arg}** ΠΌΠΎΠ½Π΅Ρ‚ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŽ {member.mention}')
        emb.set_thumbnail(url=ctx.author.avatar_url)
        await msg1.edit(embed=emb)
    else:
        emb = discord.Embed(title = 'Ошибка Ρ‚Ρ€Π°Π½Π·Π°ΠΊΡ†ΠΈΠΈ', color = 780000, description=f'{ctx.author.mention}, Ρƒ вас **Π½Π΅** достаточно срСдств для ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ‡ΠΈ **{arg}** ΠΌΠΎΠ΅Π½Ρ‚ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŽ {member.mention}')
        emb.set_thumbnail(url=ctx.author.avatar_url)
        emb.set_footer(text='ΠŸΠΎΠΏΡ€ΠΎΠ±ΡƒΠΉΡ‚Π΅ ΠΏΠΎΠ²Ρ‚ΠΎΡ€ΠΈΡ‚ΡŒ Ρ‚Ρ€Π°Π½Π·Π°ΠΊΡ†ΠΈΡŽ ΠΏΠΎΠΉΠΆΠ΅.')
        await ctx.send(embed = emb)
    with open('economy.json','w') as f:
        json.dump(money,f)
#

plz help

blazing beacon
#

!code

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.

blazing beacon
#

and what is the error

slate swan
#

i have a blacklist word system. Its deleting the word that is only in the string which it means if i type Word
with upper case it doesnt deleting

full lily
#

That sucks

slate swan
pale turtle
pliant gulch
#

No need for an unneeded call

#

You can just do if "lowercased word" in message.content.lower()

fringe harness
pale turtle
zinc lion
#

is there a way to send a message to a channel with id id without a command, whenever an if statement is confirmed?

#
if true:
  channel.send("true")```something like this ^
full lily
#

throw it into a function

#

and call the function whenever you wanna check

#

or you could set up a task if you'd like

zinc lion
full lily
#

indentation is a little off

#

oh i see

#

hehe

slate swan
#

!e ```py
import timeit
a = timeit.timeit("'Hello World'.lower() in 'Hi Hello World Something'.lower()", number=1000)
b = timeit.timeit("'hello world' in 'Hi Hello World Something'.lower()", number=1000)
print(a)
print(b)

slate swan
full lily
fringe harness
zinc lion
slate swan
#

!e ```py
import timeit
a = timeit.timeit("'Hello World'.lower() in 'Hi Hello World Something'.lower()", number=100000)
b = timeit.timeit("'hello world' in 'Hi Hello World Something'.lower()", number=100000)
print(a)
print(b)

unkempt canyonBOT
#

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

001 | 0.03317045792937279
002 | 0.019162433221936226
pale turtle
slate swan
#

Almost double

fringe harness
slate swan
#

Ah yea if they have db, then it's required

fringe harness
#

Is there anyway I can host in on repl.it

#

Or something

slate swan
#

Replit is not a hosting service

full lily
#

look into aws they might have a free tier available

zinc lion
full lily
#

async functions need to be awaited

#

and I think you meant async def

zinc lion
#
async def testing():
    channel = bot.get_channel(12345)
    await channel.send('test')
testing()```
full lily
#
async def testing():
    channel = bot.get_channel(12345)
    await channel.send('test')
await testing()
zinc lion
#

"await" allowed only within async function

hasty iron
#

error is clear

full lily
#

Is that from my code?

zinc lion
#

yh

full lily
#

I'm not really sure, to be honest

#

it ls an async function

manic wing
full lily
#

oh

zinc lion
#

you are using await outside

full lily
#

the outer one

manic wing
#

he did await testing() outside of an async function

fringe harness
full lily
#

I did that oops

hasty iron
#

replit is not a hosting service

slate swan
fringe harness
#

Ok

zinc lion
fringe harness
#

But what should I do then

hasty iron
#

buy a vps or self host

fringe harness
#

Vps?

#

I am new to this

slate swan
#

Get a cheap or free (trials or free tiers) vps

hasty iron
#

virtual private server

full lily
fringe harness
#

Can u send me one?

full lily
#

huh is that gonna work?

fringe harness
#

Like a link

fringe harness
#

Or soemthing

zinc lion
hasty iron
#

await is only allowed inside async functions

full lily
#

hehe usually i go from the errors

zinc lion
#

RuntimeWarning: Enable tracemalloc to get the object allocation traceback

hasty iron
#

but there you could use loop.run_until_complete but i don’t think it would work if the bot is running

full lily
#

This is vexing me a little to be honest. How are you supposed to await the function from the global scope then?

zinc lion
#

yup, already tried ^ @hasty iron

hasty iron
#

is the bot running?

zinc lion
#

yeah

hasty iron
#

do you want to run that function before starting the bot

zinc lion
#

gives this error though AttributeError: 'NoneType' object has no attribute 'send'

hasty iron
#

oh

fringe harness
zinc lion
#
async def testing():
    channel = bot.get_channel(12345)
    channel.send('test')
bot.loop.create_task(testing())```
fringe harness
#

If I use a vps

hasty iron
#

wait are you calling that function, before or after starting the bot

hasty iron
full lily
fringe harness
#

Alr

zinc lion
#

but not sending anything either

hasty iron
#

bot.run blocks

slate swan
#

Is spotify api so slow or am I doing something wrong? It's like taking 10-12 seconds for each call.. blobpain

zinc lion
slate swan
#

At last of everything

hasty iron
slate swan
#

Yeah it's spamming my console, but same time is taken for auth (client credentials)

#

Okay my vscode broke blobpain a lot of data

hasty iron
slate swan
#

rooThink It's just auth then taking time. I used search endpoint and vscode is not able to handle it

fringe harness
#

in a procfile when I have to files for my discord bot what would I do

#

do i write a comma in between them

#

or do I write another line of worker: python example.py

slate swan
#

Is there anything special I have to do at slash commands? I have installed them and now no slash commands have been created

#

Like I also added this code;

@slash.slash(name="test")
async def test(ctx: SlashContext): 
    embed = Embed(title="Embed Test") 
    await ctx.send(embed=embed)
#

And I also defined slash and everything

fringe harness
#

Is there anyway I can get multiple workers on heroku

slate swan
#
slash = SlashCommand(bot)
#

No errors, nothing ... for sure! But what do I have to do?

fringe harness
#

Is there anyway I can get multiple workers on heroku

slate swan
#

See my bot doesnt show up...

#

I restarted it too ... sooo

#

Idk

lofty mulch
#

I can't import the load_dotenv module from the dotenv for some reason, it always gives me this error:
ImportError: cannot import name 'load_dotnev' from 'dotenv'

lofty mulch
#

ooo

slate swan
#

Ohhh

lofty mulch
#

Thanks for that, wouldn't figure that out for a couple of hours

slate swan
#

wdym with "set some guild ids"?

#

Slash commands can also be created for just a guild

#

Oh and how?

#

Idk about the lib you're using, but it may have some guild_ids=[] in the slash deco

#

check the docs

#

discord_slash

#

Alright

slate swan
#

But yea Ill look at the doxs

upper egret
#

hey, what would y'all recommend as a good discord.py fork with slash commands

wicked atlas
upper egret
#

thanks I'll check it out

lofty mulch
#

Code:


import os
import discord
from discord.ext import commands
from dotenv import load_dotenv

Error:

Traceback (most recent call last):
  File "c:/Users/Maria Augusta/Desktop/Besteiras de Programador/VSCode/Python/Projetos/LasagnaBot/Main.py", line 6, in <module>
    from dotenv import load_dotnev
ImportError: cannot import name 'load_dotnev' from 'dotenv' (C:\Users\Maria Augusta\AppData\Local\Programs\Python\Python38-32\lib\site-packages\dotenv\__init__.py)```
#

What's up with this?

#

OOOOH, I DIDN'T SAVE

#

Jesus, I'm slow today

upper egret
#

yeah it was running code with a typo "load_dotnev"

slate swan
slate swan
#

I don't code bots, so no idea about any

#

Or make your own

karmic totem
#

How do I do something when a role is added to user (ping me)

slate swan
hollow agate
#
        await interaction.channel.history(oldest_first=True, limit=1).flatten()``` Is my code currently, how can I get the mention out of that message and bring the mention to a user ID? I've been working on this for for quite some time and I really need guidance to finish this. Thank you!
brittle ingot
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

lofty mulch
#

So

#

This asked me to build a bot that apparently locks the channel to a certain group of people for a certain period of time

#

Anyone willing to give me a push on how I should start building the timer?

drifting swift
#

how do i take input from a command

!command
test hi
dsklf

and get all the args including the new line

pine sluice
#

what should I swap to since discord.py is now deprecated

pine sluice
#

ok

fringe harness
#

How I add more than 1 worker in heroku

prisma torrent
#

How would i go about coding a login command? If i were to type {prefix} login i want it to say how to login and then i want it to login when i type {prefix}login <code>

agile goblet
#

catch the discord.MissingRequiredArgument exception

#

and send the message in an error handler

slate swan
#

Easier would be make that argument optional and just check if it is None or not ```py
def foo(x: Optional[Whatever_typehint] = None):
if not x:
return send_login_help()
return login_user()

reef trail
#

how can i make my commands work with partial names?

slate swan
#

hey

#

anyone wanna help me make a bot

#

are help me learn to script a bot

#

cause i need help

#

?

hasty iron
#

!d difflib.get_close_matches

unkempt canyonBOT
#

difflib.get_close_matches(word, possibilities, n=3, cutoff=0.6)```
Return a list of the best β€œgood enough” matches. *word* is a sequence for which close matches are desired (typically a string), and *possibilities* is a list of sequences against which to match *word* (typically a list of strings).

Optional argument *n* (default `3`) is the maximum number of close matches to return; *n* must be greater than `0`.

Optional argument *cutoff* (default `0.6`) is a float in the range [0, 1]. Possibilities that don’t score at least that similar to *word* are ignored.

The best (no more than *n*) matches among the possibilities are returned in a list, sorted by similarity score, most similar first.
reef trail
#

oh poggers

slate swan
#

and what does that do?

reef trail
hasty iron
#

it gets the closest matches for a word from a given list

hasty iron
pliant gulch
#

Depending on the cutoff you can receive back multiple words, you will need to handle that

hasty iron
#

and you’ll need a list of guild member names

reef trail
#

what does the cutoff mean exactly

hasty iron
reef trail
#

ah

prisma wedge
#

Command raised an exception: AttributeError: 'str' object has no attribute 'send'

#

error

#
class Misc(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

   @commands.command(name="toggle", description="Enable or disable a command!")
    @commands.is_owner()
    async def toggle(self, ctx, *, command):
        command = self.bot.get_command(command)

        if command is None:
            await ctx.send("I can't find a command with that name!")

        elif ctx.command == command:
            await ctx.send("You cannot disable this command.")

        else:
            command.enabled = not command.enabled
            ternary = "enabled" if command.enabled else "disabled"
            await ctx.send(f"I have {ternary} {command.qualified_name} for you!")


def setup(bot):
    bot.add_cog(Misc(bot))```
#

code

hasty iron
# reef trail ah

but you’ll have to also make a custom converter class to make use of it

reef trail
#

I struggle with classes as it is

prisma wedge
#

can someone tell me how to fix

flat solstice
#

Is there a way to see what position someone is in a server? i.e if they are the 50th member then it would say something like member: 50 or 50th member rather than just the full member count

slate swan
#

how do i convert a number like this: 3298761 to this: 3,298,761 in my discord bot?

slate swan
flat solstice
slate swan
slate swan
slate swan
flat solstice
slate swan
#

You could sort it out

prisma wedge
#

can someone help me?

#

i posted code and error above

kindred epoch
#

the fact that you dont know what "str" is, says it all

prisma wedge
#

i know what it is

#

i just dont know where i made the eror

#

i dont see it

kindred epoch
#

and following menu docs is probably a bad idea if you dont know basic python

prisma wedge
#

ik basic python...

kindred epoch
hasty iron
#

attribute errors are part of basic python

prisma wedge
#

i cant see it

slate swan
kindred epoch
#

if you know basic python you should be able to understand what the error means

slate swan
#

That's how you can do it, no need to store

prisma wedge
#

wait is it this

kindred epoch
#

the error literally tells you where the error is

prisma wedge
#
    def __init__(self, bot):
        self.bot = bot

   @commands.command(name="toggle", description="Enable or disable a command!")
    @commands.is_owner()
    async def toggle(self, ctx, *, command):
        command = self.bot.get_command(command)

        if command is None:
            await ctx.send("I can't find a command with that name!")

        elif ctx.command == command:
            await ctx.send(You cannot disable this command.)

        else:
            command.enabled = not command.enabled
            ternary = "enabled" if command.enabled else "disabled"
            await ctx.send(f"I have {ternary} {command.qualified_name} for you!")


def setup(bot):
    bot.add_cog(Misc(bot))```
kindred epoch
#

look at it closely and see what line it points to

prisma wedge
#

is it that

hasty iron
#

can you send the full traceback

kindred epoch
#

which line does the error point to?

slate swan
prisma wedge
#

i didnt put quotations?

slate swan
#

Yes

flat solstice
prisma wedge
#

i just removed those

#

i added em back

hasty iron
prisma wedge
#

but i dont see any error

slate swan
#

Which will return a tuple with the first value being the member's name and the 2nd being their join date which is a datetime object

hasty iron
#

my point is if two people have the same name one will override the other

slate swan
#

Why would they

#

Oh

#

Nvm i got it

#

Yeah it would be better to use their ids

hasty iron
#

yeah so wont it better to store it as a mapping of Member and datetime obj

slate swan
#

Ig

patent lark
#

if you saw this before it was edited i just made a noob mistake, sorry.

tulip oracle
#

how can i get a user obj not in the current server, tried using discord.Object() but returned nonetype

kindred epoch
patent lark
#

you're trying to get a user that the bot doesnt share a guild with?

#

@tulip oracle

slate swan
#

how do i convert a number like this: 3298761 to this: 3,298,761 in my discord bot?

kindred epoch
#

!e
print("{:,}".format(100000))

unkempt canyonBOT
#

@kindred epoch :white_check_mark: Your eval job has completed with return code 0.

100,000
slate swan
#

oh

pliant gulch
#

You don't need .format

slate swan
#

wow thx so much ❀️

kindred epoch
broken turtle
#
@bot.command()
@commands.has_permissions(manage_roles = True)
async def mute(ctx, user : discord.Member):
    roleobject = discord.utils.get(ctx.message.guild.roles, id=869784877594206249)
    await ctx.send(f":white_check_mark: {user} was mute") 

script is not giving the user the muted role

kindred epoch
patent lark
#

await user.add_roles(roleobject)

broken turtle
#

??

#

ohh

#

well

#

i stupid

slate swan
visual island
kindred epoch
#

can you show an example

visual island
#

!e
print(f"{100000:,}")

unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

100,000
visual island
#

that

kindred epoch
#

oh

slate swan
kindred epoch
#

i just didnt know where to add the number

patent lark
#

thats an f string example, they wanted to know how to format numbers correctly using an f string

slate swan
kindred epoch
pliant gulch
#

Had to dip for a sec but yea that

daring lotus
#

how do i move a role with a bot?
I've tried discord.Client.move_role() but it throws an error

visual island
#

oh edit

#

!d discord.Role.edit

unkempt canyonBOT
#

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

Edits the role.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this.

All fields are optional.

Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.
daring lotus
#

ty

patent lark
#

!e py print(f"{102938292938:,}")

unkempt canyonBOT
#

@patent lark :white_check_mark: Your eval job has completed with return code 0.

102,938,292,938
visual island
#

!e

print(f"{1029382.92938:,}")
unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

1,029,382.92938
visual island
#

cool

patent lark
#

oops

visual island
#

!e

print(f"{2663**2:,}")
unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

7,091,569
vagrant brook
#

I don't think you should be spamming commands here Β―_(ツ)_/Β―

visual island
#

s-s-sorry potatoplead

lunar grove
#

command line to set a bots about me?

visual island
#

none

lunar grove
#

wh-

visual island
#

you can only set it from developer portal

lunar grove
#

ohhhhhh

visual island
#

currently

lunar grove
#

you know where in the portal?

#

is it just the description?

#

yes, yes it is

visual island
#

mhm

#

lag

young acorn
#

You guys know how to get to a messages response to another message if it was tagged?

visual island
#

does interaction responses really doesn't have rate limit?

slate swan
#

Does someone have a code a discord bot code coded with python that make the user choose and change the prefix with

a command like "+setprefix" i searched all the day but i didnt find my phone is going low in battery if someone got that pls send me the code i will be thankful

wanton pebble
#

does someone know how to split embed messages if the fields are over 6000 letters?

empty quartz
#

Hello?

#

can i use visual studio code to code my discord bot?

agile goblet
agile goblet
#

even notepad, not that i would recommend it

empty quartz
#

thanks!

empty quartz
#

i have been learning alot of python cause of this server.

wanton pebble
agile goblet
wanton pebble
empty quartz
#

Do i need to hide my bots token if i use visual studio code?

agile goblet
#

what do you mean by that exactly?

agile goblet
wanton pebble
empty quartz
#

can someone somehow find it.

wanton pebble
empty quartz
#

Ok.

#

thanks!

agile goblet
#

otherwise im gonna have to rethink my advice

wanton pebble
empty quartz
#

hello!

obtuse egret
#

the leave command is acting as if it's part of the play command and saying theres an unexpected indent

#

ive indented it but then the ) is saying unindent does not match any level

pliant gulch
#

The abc.Messageable.send method has an embeds kwarg which you pass as a list of embeds

agile goblet
#

i guess it would work either way. What you could do is find the maximum length, cut the string there, split it by spaces and then remove the last index of the list ( except if the last index in the cut string is a space ofcourse ) and then just join the list to get a string back

pliant gulch
#

Otherwise I would suggest using a list paginator from discord.ext.menus

agile goblet
pliant gulch
#

Which uses reactions to change pages

pliant gulch
agile goblet
#

if it works it works

pliant gulch
#

Doesn't mean it works well

wanton pebble
empty quartz
#

i tried to run my bot on visual studio code it said couldnt find discord.

#

so what do i do.

visual island
reef shell
agile goblet
#

not everything has to be optimal though does it

empty quartz
#

k.

agile goblet
#

if theres no better option

pliant gulch
#

Ok, so If I have 50 embeds I have to send 50 messages?

obtuse egret
pliant gulch
#

Great solution lol

slate swan
agile goblet
#

yeah but we're not talking about 50 embeds now

pliant gulch
#

If you were using v2.0 (master) you can send 5 messages each with 10 embeds max

#

Thats very much better then sending 50 messages for a single embed in each one

agile goblet
#

never said it wasnt better though

pliant gulch
#

Which was my point

pliant gulch
#

I'm pretty sure interaction responses do have a ratelimit

#

but they aren't global rather only on that interaction

reef shell
#

wdym

visual island
pliant gulch
#

I'm not sure, best bet is to make a quick http request that does an interaction response and check the response headers

#

It should contain X-ratelimit-remaining irrc

#

And some other relevant data towards ratelimits

visual island
visual island
empty quartz
#

??????????

pliant gulch
#

As name suggests I'd assume it would generate snippets for you to use

#

Of course snippets being snippets won't make the whole thing

#

You use vsc as an IDE where you write the code

empty quartz
#

yea

#

what do i download to use my bot in vsc

pliant gulch
#

I would suggest downloading the python extension for vsc

empty quartz
#

i cant find it?

pliant gulch
#

Then just set up your vsc to use the correct python interpreter, if you are using multiple versions

#

Just go to VSC extensions, search python

#

Should be a pack of extensions