#discord-bots

1 messages · Page 13 of 1

slate swan
#

py-cord. uwu

gilded gust
#

lmao

maiden fable
#

wasn't that stella's og msg?

vocal snow
#

could you send your code please?

gilded gust
vocal snow
vocal snow
gilded gust
#

it edits the message with the use of a dictionary:

    # the dictionary
    msg_attrs = {
        'embed': PC_embed(interaction.user),
        'view': PC_view(),
        'file': None
    }
  # editing the message
  await interaction.response.edit_message(**msg_attrs)
vocal snow
#

and you're responding withing 3 seconds of receiving the interaction?

gilded gust
#

the embed and view change perfectly

gilded gust
vocal snow
#

are you sure the kwarg is file?

#

I think it would be attachments

gilded gust
#

i have another part of the code which uses file and it works

vocal snow
#

in edit_message?

cloud dawn
gilded gust
#

no..

unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

maiden fable
vocal snow
gilded gust
gilded gust
#

so, I should try doing attachments = []?

vocal snow
#

yep

vocal snow
#

ah yes

#

have not seen snow here in ages

sick birch
#

same

slate swan
#

i have lol

#

ive talked with snow, hes a pretty busy cool guy

sick birch
#

oh

#

not actual snow

slate swan
#

who are we talking about bro

royal bone
royal bone
royal bone
# royal bone

py```
import discord
from discord.ext import commands
import music
import os

cogs = [music]

client = commands.Bot(command_prefix='?', intents = discord.Intents.all())

for i in range(len(cogs)):
cogs[i].setup(client)

client.run(os.environ['token'])

cloud dawn
#

@royal bone We don't help with making music bots.

royal bone
royal bone
slate swan
tough lance
slate swan
royal bone
white aurora
#

replit sucks

slate swan
#

im creating a welcome command and idk why its not working, i have all intents on and the privalleged intents. Ik my cog has loaded but it still doesnt work

pastel aspen
#

this snippet of code doesn't seem to be working, and I already checked the values of the variables and they are right. Am I doing embeds wrong or something?

                emb = discord.Embed(description="Música adicionada à fila.", thumbnail=thumbnail, colour=0xc79604)

                emb.add_field(name="Música",value=f"[{title}]({link})",inline=False)

                emb.add_field(name="Duração",value=f"{duration}",inline=True)

                await ctx.send(embed=emb)```
slate swan
#

im creating a welcome command and idk why its not working, i have all intents on and the privalleged intents. Ik my cog has loaded but it still doesnt work

code:

from nextcord.ext import commands

GUILD_ID = 995268926197989396
INTRO_CHANNEL_ID = 1001024359047102514
RULES_CHANNEL_ID = 1001024359047102514
UNASSIGNED_ROLE_ID = 1002895305752190997

class WelcomeCog(commands.Cog, name="Welcome"):
    """Welcome users when they join"""

    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_member_join(self, member: nextcord.Member):
        """Welcome members when they join"""
        guild = self.bot.get_guild(GUILD_ID)
        intro_channel = guild.get_channel(INTRO_CHANNEL_ID)
        rules_channel = guild.get_channel(RULES_CHANNEL_ID)
        # send welcome message
        await intro_channel.send(
            f"Welcome to the server, {member.mention}!\n"
            f"Please read the rules in {rules_channel.mention} to gain access to the rest of the server!")

        
    @commands.Cog.listener()
    async def on_ready(self):
        print("Welcome Cog has loaded!")


# setup functions for bot
def setup(bot):
    bot.add_cog(WelcomeCog(bot))```
#

does anyone know why?

#

fixed ^

royal bone
#

how i can play audio in channel by replit ?

obsidian flicker
#

Guys I need help

#

Can someone please help me code just a BASIC command that I can view all the roles in my server

quaint epoch
obsidian flicker
#

Ok thanks

quaint epoch
slate swan
slate swan
#
"\n".join(role.mention for role in await ctx.guild.fetch_roles())
slate swan
quaint epoch
#

so you would do py source = await disnake.FFmpegOpusAudio.from_probe("song.mp3") channel = await ctx.guild.fetch_channel(int) connection = await channel.connect() await connection.play(source)

slate swan
#

and black is gonna format you

quaint epoch
#

!d disnake.VoiceChannel.connect

#

!d discord.VoiceClient

unkempt canyonBOT
#

class discord.VoiceClient```
Represents a Discord voice connection.

You do not create these, you typically get them from e.g. [`VoiceChannel.connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").

Warning

In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through [`opus.load_opus()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.opus.load_opus "discord.opus.load_opus"). Otherwise, your AudioSources must be opus encoded (e.g. using [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/latest/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio")) or the library will not be able to transmit audio.
slate swan
#

How is the installation command for my bot to work?

quaint epoch
#

i dunno

#

it's your bot

slate swan
#

isn't there a command from github?

#

i wonder why discord doesnt have a feature that displays a few lines of code in the github link you send, it would really be helpful over using bots

quaint epoch
#

no incentive to do that

#

really

#

ofc writing a bot for that isn't too hard

slate swan
#

why not? its helpful especially for devs

obsidian flicker
obsidian flicker
#

could u please help me with that, i really need it

quaint epoch
#

updated message

slate swan
#

you can just do

ctx.guild.roles[0]
#

it would return the highest role obj

obsidian flicker
slate swan
#
await ctx.send(f"The highest role in this guild is {ctx.guild.roles[0].mention}")
#

thats all you need lol

obsidian flicker
#

not highest role

slate swan
#

All roles in order?

obsidian flicker
#

yes

#

top to bottom

pliant gulch
#

The top role would be the last item of the list

slate swan
pliant gulch
#

Yes

slate swan
#

mhm cool

pliant gulch
#

roles[-1]

slate swan
#

anyways got to go, andy hes all yours🏃‍♂️

obsidian flicker
#

andy could u help me

#

@pliant gulch

grim oar
#

Who in the name of _ pinged and deleted

white aurora
#

👀

slate swan
#

and i ghost pinged snow🗿

grim oar
#

Bruh weirdos

slate swan
#

dont say that to your best friend

grim oar
#

No, the person who deleted

slate swan
#

oh cool

obsidian flicker
#

okimii

#

help lol

#

lemme give u a example

#

server roles: ```

owner
co - owner
server manager

this is a example, currently this is what i get
server manager
owner
co - owner```

#

so i need in order

slate swan
#

well in my method it just mentions all the roles in order you just need to customize it for your needs

obsidian flicker
#

idk how to do that

#

look it can be from top to bottom or bottom to top, as long as its in order idc which way.

#

await ctx.send("\n".join(role.mention for role in roles))
TypeError: 'NoneType' object is not iterable

slate swan
#

btw i would just mention their names over pinging the roles, it can lead to spam pings or just put it in the description of an embed so it doesnt ping the roles but it mentions them

obsidian flicker
slate swan
#

well im not sure how it would be done tbh

obsidian flicker
#

how does ur work?

quaint epoch
#

await ctx.send("\n".join(role.mention for role in await ctx.guild.fetch_roles()))

#

or get_roles()

slate swan
quaint epoch
#

i just prefer api calls

slate swan
#

you prefer chaos

quaint epoch
#

you prefer something that isn't preferable

#

i prefer something that is

#

we are not the same

obsidian flicker
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'get_roles'

#

@quaint epoch ?

quaint epoch
#

what

#

!d discord.Guild.fetch_roles

unkempt canyonBOT
#

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

Retrieves all [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that the guild has.

Note

This method is an API call. For general usage, consider [`roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.roles "discord.Guild.roles") instead.

New in version 1.3.
obsidian flicker
#

hm?

quaint epoch
#

just use fetch roles

#

and with an await

obsidian flicker
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'fetch_roles'

quaint epoch
#

brh

obsidian flicker
# quaint epoch just run this code directly

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In content: Must be 2000 or fewer in length.

quaint epoch
#

brhhh

obsidian flicker
quaint epoch
#

no clue then

obsidian flicker
#

if someone knows how to solve this lmk

silent portal
#

@obsidian flicker What is ur exact problem?

obsidian flicker
slate swan
#

@obsidian flicker

roles = ctx.guild.roles
order_roles = roles.reverse()
await ctx.send("\n".join(role.mention for role in roles))

that should would iirc

pliant gulch
#

.reverse() mutates the original list so order_roles is None while roles has been reversed

obsidian flicker
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not iterable

pliant gulch
#

You could just use the built in reversed()

pliant gulch
#

!e print(reversed(range(10)))

slate swan
cloud dawn
#

lol

unkempt canyonBOT
#

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

<range_iterator object at 0x7f5b88698720>
slate swan
#

this is fun to watch

pliant gulch
#

I’m on mobile at the moment

slate swan
#

its not easypithink

pliant gulch
#

!e print(*(reversed(range(10))))

unkempt canyonBOT
#

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

9 8 7 6 5 4 3 2 1 0
slate swan
#

never even knew reversed was a built in method lol

pliant gulch
#

Unpacks the iterable

slate swan
#

@obsidian flicker this should work lol

await ctx.send("\n".join(reversed([role.mention for role in ctx.guild.roles])))
#

reversed is a pretty cool method ngl

pliant gulch
#

join expects an iterator of strings

#

This will error

slate swan
#

right map needs to be used

pliant gulch
#

No?

pliant gulch
#

Unless you mean using map to str them all

slate swan
#

ik, but a list comp would be better either way

obsidian flicker
#

what then

slate swan
slate swan
slate swan
obsidian flicker
#

lmfao

slate swan
#

make the message shorter

obsidian flicker
#

how shorter

#
await ctx.send("\n".join(reversed([role.mention for role in ctx.guild.roles])))```
#

i have this.

slate swan
#

well maybe only use the names over mentions

#

to cut down the message

obsidian flicker
#

ye i dont need mentions

slate swan
#

well then change .mention to .name

inner wing
#

how add reaction on message that webhook send
there only delete and edit

slate swan
#

fetch the message to get the message obj

inner wing
#

but i dont have the id too

slate swan
#

you can also get the last message with history iirc

inner wing
scarlet aurora
#
    @commands.command()
    async def promote(self, ctx, user: discord.User = None):
        if user is None:
            await ctx.send("Please choose a user to promote")
        
        else:
            for role in user:
                print(role.name)```How do I list all roles in a user?
#
Traceback (most recent call last):
  File "C:\Users\llVll\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\llVll\Desktop\Projects\Lunar Vigil Bot\cogs\utils.py", line 94, in promote
    for role in user:
TypeError: 'User' object is not iterable```
wicked atlas
#

for role in user.roles:

scarlet aurora
#

still errors

wicked atlas
#

What error?

scarlet aurora
#
Traceback (most recent call last):
  File "C:\Users\llVll\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\llVll\Desktop\Projects\Lunar Vigil Bot\cogs\utils.py", line 94, in promote
    for role in user.roles:
AttributeError: 'User' object has no attribute 'roles'

The above exception was the direct cause of the following exception:```
wicked atlas
#

Might be because you're casting it as a User object and not a Member object

#

Try it with

user: discord.Member
scarlet aurora
#
    @commands.command()
    async def promote(self, ctx, user: discord.User = None):
        if user is None:
            await ctx.send("Please choose a user to promote")
        
        else:
            for role in user.roles:
                print(role.name)```
#

that's the full code

#

oh it works, thanks

#

why does discord.User not work?

wicked atlas
#

a User object just represents a normal discord user, with their id, name, identifier, stuff like that. a Member object inherits from User, but includes more guild-specific information, such as roles, nicknames, etc.

scarlet aurora
#

ah

wicked atlas
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
scarlet aurora
#

I see

#
        if user is None:
            await ctx.send("Please choose a user to promote")
        
        else:
            for role in user.roles:
                list.append(role.id)

            if scout in list:
                removerole = discord.utils.get(ctx.guild.roles, scout)
                addrole = discord.utils.get(ctx.guild.roles, battle)

                await user.remove_roles(removerole)
                await user.add_roles(addrole)``` ```Traceback (most recent call last):
  File "C:\Users\llVll\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\llVll\Desktop\Projects\Lunar Vigil Bot\cogs\utils.py", line 113, in promote
    removerole = discord.utils.get(ctx.guild.roles, scout)
TypeError: get() takes 1 positional argument but 2 were given``` Can someone help?
odd mango
scarlet aurora
#

when?

#

i already solved it dw

odd mango
#

do it instead of discord.utils

#

oh nice

#

guys, what if instead of a json OR some kind of db,
i store stuff in dict format in .py file? 👀

silver reef
#

i was thinking of creating a table that has 1 item for every column but that means if i want to add 50 items to the game that means 50 columns in the table which will make the table too long in a ridiculous way and the table inside the database will look sth like this :
user_id | sword| shield| potion| etc...
10 | x 1 | x1 | x5 | ..
is there any short way of doing it?

slate swan
#
class remyclient(discord.Client):
    def __init__(self):
        super().__init__(intents=intents)
        self.synced = False
    
    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync()
            self.synced = True
        print("Succesfully logged in & synced commands")

remy = remyclient()
tree = app_commands.CommandTree(remy)

is this a bad way of doing slash commands?

odd mango
#

yes, bad way of syncing

slate swan
#

What's better

odd mango
# slate swan What's better

Sync when you...

  • Added/removed a command
  • Changed a command's...
    • name (name= kwarg or function name)
    • description (description= kwarg or docstring)
  • Added/removed an argument
  • Changed an argument's...
    • name (rename decorator)
    • description (describe decorator)
    • type (arg: str str is the type here)
  • Added/modified permissions:
    • guild_only decorator or kwarg
    • default_permissions decorator or kwarg
    • nsfw kwarg
  • Converted the global/guild command to a guild/global command

Do not sync when you...

  • Changed anything in the function's body (after the async def (): part)
  • Added or modified a library side check:
    • (@)app_commands.checks...
    • (@)commands...(.check)
    • @app_commands.checks.(dynamic_)cooldown(...)

This is the same for hybrid commands

slate swan
#

Why's it so bad?

odd mango
#
@bot.command()
@commands.guild_only()
async def sync(
  ctx: Context, guilds: Greedy[discord.Object], spec: Optional[Literal["~", "*", "^"]] = None) -> None:
    if not guilds:
        if spec == "~":
            synced = await ctx.bot.tree.sync(guild=ctx.guild)
        elif spec == "*":
            ctx.bot.tree.copy_global_to(guild=ctx.guild)
            synced = await ctx.bot.tree.sync(guild=ctx.guild)
        elif spec == "^":
            ctx.bot.tree.clear_commands(guild=ctx.guild)
            await ctx.bot.tree.sync(guild=ctx.guild)
            synced = []
        else:
            synced = await ctx.bot.tree.sync()

        await ctx.send(
            f"Synced {len(synced)} commands {'globally' if spec is None else 'to the current guild.'}"
        )
        return

    ret = 0
    for guild in guilds:
        try:
            await ctx.bot.tree.sync(guild=guild)
        except discord.HTTPException:
            pass
        else:
            ret += 1

    await ctx.send(f"Synced the tree to {ret}/{len(guilds)}.")```

`commands.Greedy`
`discord.Object`
`typing.Optional and typing.Literal`

Works like:
`!sync` -> global sync
`!sync ~` -> sync current guild
`!sync *` -> copies all global app commands to current guild and syncs
`!sync ^` -> clears all commands from the current guild target and syncs (removes guild commands)
`!sync id_1 id_2` -> syncs guilds with id 1 and 2
slate swan
#

I'm too lazy to do that and I wont re run my bot a thousand times so I wont get rate limited

odd mango
#

you do you

#

¯_(ツ)_/¯

novel prairie
#
@bot.command()
async def banlist(self, ctx):
    bans = await ctx.guild.bans()
    loop = [f"{u[1]} ({u[1].id})" for u in bans]
    _list = "\r\n".join([f"[{str(num).zfill(2)}] {data}" for num, data in enumerate(loop, start=1)])
    await ctx.send(f"ini\n{_list}")```
#
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.```
#

how can i fix this?

primal fox
#

are you using a cog?

novel prairie
#

wdym

primal fox
#

you have self in your command arguments

#

if no cog, remove that

novel prairie
#

oh

#

oke

#

ok so the command works like this:

#

how can i remove the [1] [2]

#

and the other numbers

#

and how can i make the bot send this command into an embed

slate swan
unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
novel prairie
# slate swan !d discord.Embed

yea i know that but i want the bot to send this code:py @bot.command() async def banlist(ctx): bans = await ctx.guild.bans() loop = [f"{u[1]} ({u[1].id})" for u in bans] _list = "\r\n".join([f"[{str(num).zfill(2)}] {data}" for num, data in enumerate(loop, start=1)]) await ctx.send(f"ini\n{_list_}") in an embed

slate swan
primal fox
#

a simple way would be to take what the bot is sending and put it as the embed description, assuming that's what you want

slate swan
#

Yeah

#

you can't use ini in embed title, I believe

novel prairie
#

thats why im asking u guys

slate swan
#

!d discord.Embed.add_field

unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
slate swan
#

@novel prairie ^

novel prairie
#

oke

slate swan
#

I mean it's preference, I like discord.py but some may prefer py-cord instead

#

Yeah

#

typing okimii is typing...

#

most popular is discord.py, hikari is very modular and has pretty good implementations, if you want a wrapper that is the best for you, just make one for yourself, youll know each and every corner of it

slate swan
#

🤣

slate swan
#

how can i tag a specific user in an embed command?

slate swan
slate swan
#

How can I take in a file as an option for a slash command?
Discord.py

torn sail
#

I think you would typehint the parameter with discord.File

quaint epoch
slate swan
#

thx i have

rare jewel
#

Does anyone know any free lavalink servers I can use that isn’t ssl/https/wss? I’ve heard that http/ws works fine but I don’t know any

slate swan
#

Does anybody know how to fix this

#

ERROR: No matching distribution found for yaml

#

i tryed to do pip install yaml and it dosent work

maiden fable
#

What's yr python version?

#

Also, seems like the package name is pyyaml

slate swan
#

Guild count is 0

#

Even tho my bot is in 14 guilds

maiden fable
#

Nice!

#

Enable guilds intent

slate swan
#

......

#

So the bot can get guilds name without guilds intents?

maiden fable
#

Hmmmmmmmmmmmmmmmmmmmmmmmmm

#

Show yr intents

slate swan
#

Ha, great I’m not using my laptop rn

#

I remember that I had discord.Intents.default or something

#

@maiden fable How do I add adding a file as a option in slash commands?

maiden fable
#

No idea, but I think u gotta use the discord.File typehint or smth?

slate swan
#

ModuleNotFoundError: No module named 'fade'

#

when i try to install fade it says this

#

Requirement already satisfied: fade in c:\users\tcale\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (0.0.9)

#

i dont understand

slate swan
#

Traceback (most recent call last):
File "C:\Users\tcale\Desktop\NITRO REDEEMER\redeemer.py", line 3, in <module>
import fade
ModuleNotFoundError: No module named 'fade'

#

After i already installed fade

limber bison
#

Is it fade?

slate swan
limber bison
#

pip freeze to check u have this or not

slate swan
#

that seems weird what does that do?

limber bison
#

I have database entrys 1) id 2) economy , how can I add money only to a specific role 🤔

vocal snow
#

Isn't lavalink ytdl but server based

maiden fable
#

That's the crux, yea

slate swan
#

i need help with doing pip install it wont work

spare ore
#

Hello can you suggest me any bot which give auto role to bots only not members?So i dont need to remove member role always

slate swan
#

i need help fixing this somebody

spare ore
#

$pip install

slate swan
#

i do the moneysign?

spare ore
#

Ye

#

I guess..

slate swan
#

'$pip' is not recognized as an internal or external command,
operable program or batch file.

slate swan
spare ore
#

Nvm.. Try it.

jolly hound
#

hey can u tell what error im making here

slate swan
#

ERROR: You must give at least one requirement to install

vocal snow
spare ore
#

Hello can you suggest me any bot which give auto role to bots only not members?So i dont need to remove member role always

vocal snow
spare ore
#

Ye

vocal snow
jolly hound
slate swan
vocal snow
#

Install it then

spare ore
slate swan
# vocal snow Install it then

ERROR: Could not find a version that satisfies the requirement yaml (from versions: none)
ERROR: No matching distribution found for yaml

vocal snow
#

The package is pyyaml or something

#

Check on pypi, and don't you have a requirements.txt or something?

#

Some sort of dependency management

slate swan
vocal snow
vocal snow
spare ore
slate swan
vocal snow
#

Install it the same way you installed fade

vocal snow
slate swan
#

send me the way i should install it

vocal snow
#

py -m pip install pyyaml

slate swan
#

ModuleNotFoundError: No module named 'colorama'

#

@vocal snow we slowly fixing it

#

whats the install for colorma

vocal snow
#

You can google these

slate swan
random portal
#

whats colorma

scarlet pond
slate swan
scarlet pond
#

pip install colorma

#

idk it works for me

slate swan
#

i need the install for this ModuleNotFoundError: No module named 'colorama'

slate swan
# scarlet pond idk it works for me

ERROR: Could not find a version that satisfies the requirement colorma (from versions: none)
ERROR: No matching distribution found for colorma

scarlet pond
dusk dock
#

do any of you know how to do autocomplete for hybrid commands in discord.py?(it'll only work if the command is invoked via slash of course)

scarlet pond
#

how do you get the bot's username+tag 💀 I forgor

slate swan
#
@client.command(intents=intents)

async def tmm(ctx):
   await ctx.send(embed=discord.Embed(title="check", description=f"{len(client.guilds)} servers, {len(set(client.get_all_members()))}"))
#

Why members command is not working?

vocal snow
scarlet pond
#

oop

vocal snow
#

str(user)

unkempt canyonBOT
maiden fable
#

Or that, yea

scarlet pond
#

ah ok

vocal snow
maiden fable
#

Also, @vocal snow dunder methods ain't supported by Python iirc

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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.

scarlet pond
#

!d discord.Client.user

#

ah ok I was correct

maiden fable
#

You're correct @vocal snow

slate swan
#

@maiden fable

slate swan
#

Already enabled

slate swan
#

what code did u use to enable intents

#

Wait

#

you can just do discord.Intents.all() I believe

#
intents = discord.Intents.default()
intents.members = True
intents.guilds = True
timber dew
#

I want to create a help for on selfbot but his always tells me impossible to send an empty embed that can give me a little help please

vocal snow
slate swan
#

ERROR: Could not find a version that satisfies the requirement colorma (from versions: none)
ERROR: No matching distribution found for colorma

#

i need help whats the command for colorma

maiden fable
#

!pypi colorama

unkempt canyonBOT
maiden fable
#

not colorma

#

Typo

timber dew
#

!pypi embed

unkempt canyonBOT
timber dew
#

!discordpy embed

slate swan
#

when i try to do pip install colorma it dont work any other commands can someone help

maiden fable
#

Show

#

also its colorama

#

Not colorma

slate swan
#

@maiden fable what would I do with the file object after type hinting it?

#

slash command to take in file option

maiden fable
#

No idea

slate swan
#

still dont work

maiden fable
#

U didn't install it

slate swan
maiden fable
#

Then probably u installed in the wrong Python version

slate swan
#

because i have the newest one

maiden fable
#

U have multiple
Check in control panel

silk fulcrum
unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
scarlet pond
#

how come I can't generate a bot invite url?

slate swan
scarlet pond
#

Bruh

slate swan
#

How do i fix this i install colorama but when i run my .py it says no module named colorama

scarlet pond
#

It's pip install colorama

slate swan
scarlet pond
#

Make sure it's correct colorama

slate swan
#

? what do you mean how do i make sure its the correct colorama isn't there only 1 command for it?

scarlet pond
#

There can be others with same name

slate swan
scarlet pond
#

Idk

#

Read colorama docs

scarlet pond
gilded gust
#

I've got another problem with my py-cord bot. I'm sure that there is an error somewhere in my code, but it isn't showing up. My cog isn't loading and the only time I've had that happen to me before is when there is an error in the cog. However, I'm not getting any traceback to where the error might be.

paper sluice
#

do you have an error handler?

gilded gust
paper sluice
#

like some event listener for on_command_error?

gilded gust
#

no

paper sluice
#

so what part do you think errors out

gilded gust
#

honestly I don't know

paper sluice
#

maybe there is something wrong with the intents

gilded gust
#

I've confused myself with all this tangled code

#

it's like 1 part of the code links to another and that links to something else which makes it a nightmare to debug

paper sluice
#

hmm, try to use commands and see which commands don't work

outer violet
#

would this code be right before i run it? I’m trying to make it so whenever there’s an error with a command, the full traceback sends to my dm and I’m using hikari-lightbulb

@errors_plugin.listener(lightbulb.CommandErrorEvent)
async def on_error(event: lightbulb.CommandErrorEvent) -> None:
    exception = event.exception
    users = [
        event.context.cache.get_user(user) for user in [690631795473121280, 994738626816647262]
    ]  # 1: main, 2: second

    if isinstance(exception, lightbulb.CommandInvocationError):
        await event.context.respond(
            f"Something went wrong during invocation of command `{event.context.command.name}`."
        )

        for user in users:
            await event.context.respond(
                embed = hikari.Embed(
                    title=f"An unexpected `{type(exception).__name__}` occurred",
                    description=f"`/`/`py\n{''.join(format_exception(exception.__class__, exception, exception.__traceback))}`/`/`"
                )
            )```
gilded gust
paper sluice
silk fulcrum
gilded gust
#

yes

paper sluice
paper sluice
gilded gust
#
def setup(client):
    client.add_cog(PokemonRed(client))
paper sluice
gilded gust
#
bot.load_extension('game')
paper sluice
gilded gust
#

it was working just fine before i made some changes, nothing to do with the file's placement or how it's loaded. It's just an error that doesn't show up.

silk fulcrum
#

...

silk fulcrum
paper sluice
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.

gilded gust
#

gimme a min

limber bison
#

what is BucketType

#

?

slate swan
#

is there a way to make a discord bot appear offline?

limber bison
#

!BucketType

limber bison
paper sluice
#

your client is commands.Bot right?

slate swan
#

@paper sluice

#

@paper sluice

#

i need help with this

#

@slate swan

slate swan
slate swan
# limber bison change_presence
@client.event
async def on_ready():
    print(f"{client.user.name} - cached & loaded in 3s")
    activity = discord.Game(name=",help", type=4)
    await client.change_presence(status=discord.Status.online,
                                 activity=activity)
slate swan
slate swan
#

Why my client is not running?

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ".")

@client.event
async def on_ready():
  print("Bot is ready!")

@client.command()
async def ping(ctx):
  await ctx.send(f"pong! {round(client.latency * 1000)}")

client.run = ("")
slate swan
#

bro these people are gonna make me go crazy

slate swan
#

he didnt even type in python 😭

slate swan
#

I TYPED THE TOKEN

slate swan
silk fulcrum
slate swan
slate swan
silk fulcrum
#

oh he didnt even gget it

slate swan
slate swan
#

@slate swan i typed the token

#

It didn't work

silk fulcrum
#

ARE YOU ... ok

slate swan
#

@slate swan this is the funniest shit ever

silk fulcrum
#

🗿

slate swan
#

It didn't work

slate swan
silk fulcrum
#

:painnn:

slate swan
#

Bro it says i still dont have colorama when i already tryed every install command for it

#

im trying to make my bot appear offline ```py
@client.event
async def on_ready():
print(f"{client.user.name} - cached & loaded in 3s")
activity = discord.Game(name="discord.com", type=4)
await client.change_presence(status=discord.Status.online,
activity=activity)

#

It didn't work

#

use some common sense here

#

Bro it says i still dont have colorama when i already tryed every install command for it

unkempt canyonBOT
#

Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#

omg bro

#

what the hell

slate swan
#

reset your token RN

#

FAST

#

LMFAO

#

LOL 💀

silk fulcrum
#

GG

slate swan
#

Nice IQ there pal

#

done

#

Post your code without the token..

#

Bro it says i still dont have colorama when i already tryed every install command for it

slate swan
# slate swan done

Hi guys in todays video I teach you guys on how to create a discord bot using discord.py 2.0

============= Links =============
Discord.py 2.0 - pip install git+https://github.com/Rapptz/discord.py
Discord Developer - https://discord.com/developers/applications
Main Channel - https://www.youtube.com/c/CivoProHD

============= Time Stamps ====...

▶ Play video
#

please please just watch this

#

yo y9

silk fulcrum
#

utub is trash but i agree in this situation

slate swan
#

is it possiable to make

slate swan
#

a bot appear offline

#

Is there any other install commands for colorama ive tryed them all

#

but still be working?

#

!d discord.Status.offline

unkempt canyonBOT
slate swan
#

await client.change_presence(status=discord.Status.offline)

#
@client.event
async def on_ready():
    print(f"{client.user.name} - cached & loaded in 3s")
    activity = discord.Game(name="discord.com", type=4)
    await client.change_presence(status=discord.Status.online,
                                 activity=activity)
``` this my code
silk fulcrum
#

whats ur python ver

slate swan
slate swan
slate swan
#

ik

#

Replace that last line with the line I said

#

i did

#

try it?

silk fulcrum
slate swan
#

lemme test it rq

slate swan
slate swan
silk fulcrum
slate swan
#

Don't even work

slate swan
#

the console has nothing to print...

#

?????

#

Idk let me see the code your using

#

without the token though

slate swan
silk fulcrum
silk fulcrum
slate swan
slate swan
slate swan
silk fulcrum
slate swan
slate swan
slate swan
slate swan
silk fulcrum
#

or humor

slate swan
#

I've told you the SAME thing multiple times

slate swan
#

no i understand you think its funny because we dont know basic python but its hard to just "learn"

#

!resources

unkempt canyonBOT
#
Resources

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

silk fulcrum
# slate swan

= is absolutely still here and you have to replace "TOKEN" with your bot's token (not showing it here)

slate swan
#

to the same person

slate swan
#

I forgot

#

Yeah forgot.

#

Im such a dumb person

silk fulcrum
#

Yeah I forgot how to walk home

slate swan
#

lets go baby

slate swan
silk fulcrum
#

where am i supposed to go

slate swan
#

i got it working

#

after 4 hours

#

Its a variable

#

I forgot

slate swan
silk fulcrum
#

it's absolutely a function

slate swan
#

Sorry for being dumgrumpchib

paper sluice
slate swan
slate swan
#

my bad @slate swan have fun

silk fulcrum
slate swan
silk fulcrum
#

who reads tos anyway lmao

slate swan
#

it auto deleted my message nice

silk fulcrum
#

bruh i have my own problem and im sitting here and laughing

silk fulcrum
slate swan
silk fulcrum
silk fulcrum
paper sluice
#

you also need a __main__.py which will be run when you run the dir as a module

#

or if the files in tests dir is relative to the main script, just make a new file in the same directory and import the tests

limber bison
#

2nd last line

#

last word

#
embed = discord.Embed(
                timestamp=ctx.message.created_at,
                title=f"{user}'s Balance",
                color= 0xF7C906,```
i want 3-4 colors rendomly
paper sluice
#

yea, and now you import db_test.py in __main__ and do python -m tests

slate swan
paper sluice
#

do .db_test

limber bison
limber bison
slate swan
#
import random

colors = ['0x0847F7', '0xF7C906', '0xF90651', '0x08FC08']
random.choice(colors)
limber bison
#

make no difference

slate swan
#

like this..

slate swan
silk fulcrum
paper sluice
#

huh? i meant import .db_test intead of db_test

#

oh wait

#

you might have to import something from db_test

silk fulcrum
paper sluice
#

you have to do something like from .db_test import this

paper sluice
#

ok you will have to change the file structure a little

main.py
DB/
tests/

and in main.py you import stuff from tests

#

and in tests you just import as from DB import ... or from DB.file import ...

silk fulcrum
#

bruh finally

#

thanks

limber bison
#
@client.listen()
async def on_command_error(ctx, error):
 error = getattr(error, "original", error)
 if isinstance(error, commands.CommandNotFound):
    return  
 if isinstance(error, commands.DisabledCommand):
            await ctx.send("This command has been disabled." , delete_after= 2)
            return  
 if isinstance(error, commands.CommandOnCooldown):      
            await ctx.send(f"This command is on cooldown, please retry in {math.ceil(error.retry_after)}s.")   
            return   
 else:
    raise error```
why CommandOnCooldown not working
#

🤔

slate swan
#

@silk fulcrum help him

silk fulcrum
#

what do u need from me

slate swan
#

Assist LUC with his issue

silk fulcrum
#

why me(

limber bison
#
 @balance.error
    async def sm_error(self,ctx , error):
        if isinstance(error, commands.DisabledCommand):
            await ctx.send("This command has been disabled.")
            return

        # if isinstance(error, commands.CommandOnCooldown):
        #     embed = discord.Embed(
        #         title="Cooldown",
        #         description=f"This command is on cooldown, please retry in {math.ceil(error.retry_after)}s.",
        #         color=0xFF0000,
        #     )
        #     await ctx.send(embed=embed , delete_after = 2)
        #     return
        else :
            raise error```
command error handling
silk fulcrum
#

that's probably why it's not working

limber bison
#

get my point ?

#

🤔 or i explain again

silk fulcrum
silk fulcrum
limber bison
silk fulcrum
#

uhm

#

so what happened is else triggered

#

so isinstance(error, commands.CommandOnCooldown) is False

#

i have no idea why

#

maybe its commands.errors.CommandOnCooldown

grizzled badger
#

so choice = await bot.wait_for("message", check=check, timeout=None) doesnt return anything when a message is sent can someone tell me what is wrong

silk fulcrum
#

what's your check?

grizzled badger
#
    return not(ctx.author == "[BAD]OO_BOT [WIP]#0274")  and ctx.channel == "bots" or ctx.channel == "🤔preview-bots🤔"```
#

it worked yesterday but i edited it today and it stopped working so i changed it back and now idk what happened

silk fulcrum
#

first ctx.author != "..." is better than not(stuff)

grizzled badger
#

oh yeah lmao

limber bison
#

Ignoring exception in on_message , whats this

hazy oxide
#

what's the full error?

silk fulcrum
# grizzled badger ```def check(ctx): return not(ctx.author == "[BAD]OO_BOT [WIP]#0274") and c...

also you cannot check if ctx.channel is "bots" or "preview-bots" because ctx.channel returns the Channel object, not string. so you can check if ctx.channel.name == "bots" or ctx.channel.id == ID. And third: and statement is higher in hierarchy so it will be not if author is someone then check if channel is something or something, it will be if author is someone AND channel is something1, or instead of that all it can be just channel is something2

#

bruh what is that i just typed?

#

noone will read message that long

#

And also check doesn't give you ctx, it gives message object

grizzled badger
#

yeah i noticed the and or thing when rereading my message but now ik why my bot works in all channels

silk fulcrum
#

so i guess it would be thispy def check(m): return m.author.name + "#" + m.author.discriminator != "[BAD]OO_BOT [WIP]#0274" and (m.channel.name == "bots" or m.channel.name == "🤔preview-bots🤔")

limber bison
#

how can i deal with command is on cooldown , at once for reach cog

vocal snow
#

on_command_error

swift pumice
#

can i make that my bots changes his status every 24 hours?

#

but i heard you can get banned for that. is that true?

limber bison
#

want to ignore

Traceback (most recent call last):
  File "D:\ph\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\Kamal kishore\Desktop\Project 0\main.py", line 98, in on_command_error
    raise error
  File "D:\ph\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "D:\ph\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "D:\ph\lib\site-packages\discord\ext\commands\core.py", line 788, in prepare
    self._prepare_cooldowns(ctx)
  File "D:\ph\lib\site-packages\discord\ext\commands\core.py", line 772, in _prepare_cooldowns
    raise CommandOnCooldown(bucket, retry_after)
discord.ext.commands.errors.CommandOnCooldown: You are on cooldown. Try again in 3.34s```
this error
vocal snow
#

every 24 hours is fine

vocal snow
limber bison
swift pumice
limber bison
#

and its working too

#

but i dont know why terminal showing that

vocal snow
vocal snow
hazy oxide
slate swan
#

is it possible to add the game status and a picture of the game in discord.py?

#

@fierce crag 😎

slate swan
#

i seen video he was do it

slate swan
#

you cannot do that for a bot.

limber bison
#

I want bot read message after every 1 min and change database data but don't react , how can I do ?

#

@commands.cog.lisner ?

hazy oxide
#

tasks loop ig

heavy folio
#

are u on discord 2.0 or 1.7

novel prairie
#

replit lmao

heavy folio
#

yes

#

use ctx.author.avatar_url

novel prairie
heavy folio
#

!d discord.Embed.add_field use the value kwarg

unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining. Can only be up to 25 fields.
novel prairie
#

oke

novel prairie
limber bison
#

I want a on_message function which react to each and every message 😳

heavy folio
limber bison
#

Not to a specific

heavy folio
novel prairie
heavy folio
#

💀 not everyone uses replit like u

dusky pine
#

that's just abusing replit

novel prairie
#

lmao

limber bison
heavy folio
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
dusky pine
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
heavy folio
limber bison
dusky pine
#

^^ you can use it like await message.add_reaction("😳")

limber bison
odd mango
#

how can i get a list of all the permissions a guild member has?

shrewd apex
#

!d discord.Role.permissions

unkempt canyonBOT
shrewd apex
#

@odd mango

odd mango
#

thanks buddy

odd mango
#

need member permissions overall

#

[k for k,v in (dict(member.guild_permissions)).items() if v == 'True'] gives them all, but i just need the key ones
like
Administrator, Manage Server, Manage Roles, Manage Channels, Manage Messages, Manage Webhooks, Manage Nicknames, Manage Emojis, Kick Members, Ban Members, Mention Everyone

slate swan
#

In code

vocal snow
#

If you spam the api and break ratelimits often they ban you yeah

slate swan
#

Im conducting test

vocal snow
slate swan
#

Where?

#

@vocal snow

#

@vocal snow

vocal snow
#

Replit shell

slate swan
#

I cant find the shell

#

@vocal snow

vocal snow
#

That's unfortunate

slate swan
#

Where i can find it @vocal snow

vocal snow
#

I don't know, I don't use replit

#

I was just sharing what I've heard in this channel before

slate swan
#

If i spam running bot i get banned?

full lily
potent spear
#

he most likely means ratelimited

silk fulcrum
#

genius avoid of missing perms

vocal snow
#

Why is the member param's default value None

#

Why do you have roles and author as params?

novel prairie
#

idk

#

i found this code online and remake it

#

and made the code working better

vocal snow
#

Might want to learn a bit of python first

silk fulcrum
novel prairie
#

burh

#

bruh

novel prairie
#

💀

vocal snow
novel prairie
slate swan
#

How to fix this

potent spear
#

you need to READ what it says...

#

banned temporarily

#

all you can do is wait

eternal fox
# slate swan

Presd Commands then in the shell then kill 1 in the shell

#

*press

novel prairie
#

i mean i use kill 1 in shell and then it works fine

slate swan
#

No its not its an html code

eternal fox
novel prairie
#

wdym

#

lmao

silk fulcrum
slate swan
#

Its a paragraph code

novel prairie
#

oof

eternal fox
slate swan
#

Where is the shell?

eternal fox
#

Press the Commands first in the bottom right corner

novel prairie
#

press enter when you type the kill 1

slate swan
#

Done

eternal fox
novel prairie
#

yea

#

now wait

slate swan
#

How many hours?

novel prairie
#

💀

slate swan
#

Should i run now the code?

limber bison
#

What should be message.content == ? , So it conten everything , so I can use it as level up thing

silk fulcrum
slate swan
#

Wat

#

You can have it

silk fulcrum
#

lmao

slate swan
#

Because im already fucked up

silk fulcrum
#

bruh

slate swan
#

Is it my ip?

silk fulcrum
#

probably

slate swan
#

@silk fulcrum

#

What is this?

silk fulcrum
#

waht

#

what this

slate swan
#

This error?

#

Red thing

silk fulcrum
#

i cant say

#

i dont see it full

#

i see there is continuation up, cus of </div>s

slate swan
#

My bot is now dead

#

Nope

#

Its back to normal

#

@silk fulcrum

silk fulcrum
#

congrats

slate swan
#

How can i make my bot online 24 or forever like carl bot

silk fulcrum
#

.

heavy folio
#

get a vps man stop using replit

silk fulcrum
#

i guess

heavy folio
maiden fable
#

TIL

shell wing
#

and what was the cmd to check a piece of code ??

maiden fable
#

!source source

unkempt canyonBOT
#
Command: source

Display information and a GitHub link to the source code of a command, tag, or cog.

Source Code
shell wing
#
@bot.command()
@commands.has_permissions(manage_messages=True)
async def purge(ctx, amount=5):
    await ctx.channel.purge(limit=amount + 1)
    await ctx.channel.send("**Cleared `" + str(amount) + "` Messages**",
                   delete_after=1)
``` the bot would be deleting the msgs but wont send the "cleared +str " stuff
shrewd apex
#

use f strings ;-; and what's the point of even sending if u are deleting in 1 sec

vocal snow
#

Ur just slow at reading Asher yert

zealous jay
#

does the event even work? @scarlet aurora

#

like, try printing something when someone joins

#

if it doesn't you may have to activate intents

scarlet aurora
#

nvm I figured it out

zealous jay
#

oh

limber bison
#

How can I remove all roles with one statement?

#

I mean clear roles ?

scarlet aurora
limber bison
slate swan
scarlet aurora
limber bison
slate swan
#

You can freely use any amount

limber bison
#

And how can I take any message as message.content

slate swan
limber bison
limber bison
slate swan
#

use an on_message event

limber bison
#

On_message ?

limber bison
slate swan
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
limber bison
slate swan
#

yes.

#

commands.Cog though

limber bison
#

Ohhh k k , and how can I take 1 min gap in between 2 message , so level think work

#

Last question 😂

slate swan
#

!d asyncio.sleep

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
limber bison
#

Like this one is last

#

Wot for vc ?

slate swan
#

huh

limber bison
#

This one is for chat

#

😳

slate swan
silk fulcrum
#

ohkay

slate swan
unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
slate swan
silk fulcrum
#

who knows what is it doing in that html code

slate swan
paper sluice
#

dpy should make it so that lets you don't have message_contents intent and you try to get the content atleast warns

slate swan
#

How can i put permission?

silk fulcrum
novel prairie
slate swan
#

To the command?

slate swan
novel prairie
#

💀

slate swan
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

slate swan
#

ahhhhh

novel prairie
silk fulcrum
#

hhhhha

slate swan
#

d

#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
#

better to use has_guild_permissions though

novel prairie
#

WTF WAS THAT

#

@slate swan sus

slate swan
#

Wdym?

novel prairie
#

lmao

novel prairie
#

i saw your message

#

bro💀

slate swan
#

Imagine someone is hidden mod

novel prairie
#

yea lol

slate swan
#

Bon

slate swan
#

Nvm

#

No time for simping

#

Hey how can i make bot say the amount of deleted messages

lime rampart
#

Hello I am trying to add slash commands and the old regular message commands into 1 file but I cannot do it. When I setup the regular client stuff to use only slash commands but include @client.command() it gives me object has no attribute command How can I set up my bot to be able to use both regular message commands and slash commands?

robust fulcrum
#

Guys i want that when someone use the comamnd /image it extracts the text from image
How can I do that?

slate swan
lime rampart
#
class aclient(discord.Client):
    def __init__(self):
        intents = discord.Intents.default()
        intents.message_content = True
        super().__init__(command_prefix="!",intents=intents,help_command=None)
        self.tree = app_commands.CommandTree(self)
        self.synced = False

    async def setup_hook(self):
        self.tree.copy_global_to(guild=discord.Object(id))
        await self.tree.sync(guild=discord.Object(id))
        self.synced = True
        print(f"Synced Slash commands for {self.user}")

    async def on_ready(self):
        print(f"Logged in as {self.user}")
client = aclient()

@client.tree.command(name="join")
async def my_command2(interaction: discord.Interaction):
    await interaction.response.send_modal(Join(),ephemeral=True) 

@client.command()
async def ping(ctx):
    ctx.channel.send("pong")```

I'm getting error object has no attribute command. How can I get my bot to use both slash commands and regular message commands?
slate swan
lime rampart
#

But hybrid sends both no?

#

Or does it let you choose?

slate swan
#

both?

lime rampart
#

As in for example the ping command it would appear as slash command and a regular message command

slate swan
#

it's just message and slash commands but under one function

lime rampart
#

I just want to be specifically slash or message command

slate swan
lime rampart
zealous jay
#
class aclient(commands.Bot):
#

@lime rampart

slate swan
#

hi how can i remove an dropdown from the view with remove_item?

lime rampart
zealous jay
#

oh

#

i don't remember 😅

#

does it specifies the line?

slate swan
#

ded chat 😔

silk fulcrum
#

i guess that's not supposed to be in only 1 commit

silk fulcrum
#

!d discord.ui.View.remove_item

unkempt canyonBOT
#

remove_item(item)```
Removes an item from the view.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

i literally posted

slate swan
silk fulcrum
slate swan
#

also is there any better way

silk fulcrum
silk fulcrum
slate swan
#

i haven't coded in a while i forgot everything 😂

#

thanks :D

glossy flame
#
@bot.command(
  name="ping",
)
async def poo(ctx, channel: discord.TextChannel, message):
  await channel.send(message)```

currently, if two channels have the same name it will just choose the highest one and send it to that one. How do I change it so that it will ping all the channels that have that name
vocal snow
#

your code isn't pinging any channels so

glossy flame
#

no it sends a message into a channel

vocal snow
#

right

glossy flame
#

but if there is two channel with same name

#

it only sends into one, but i want to send into all

vocal snow
#

so you want the channel parameter to collect all channels with that name

glossy flame
#

yes

vocal snow
#

then in the command callback, you can iterate over ctx.guild.text_channels, and if the textchannel name == channel argument name, send message to it

glossy flame
#

oh right good idea

#
@bot.command(
  name="ping",
)
async def poo(ctx, channel: discord.TextChannel, message):
  if channel.name in ctx.guild.text_channels:
    await channel.send(message)```
if this is what u meant it does not work
potent spear
vocal snow
#

I meant, use a for loop

glossy flame
#

Ok

glossy flame
# vocal snow I meant, use a for loop
@bot.command(
  name="ping",
)
async def poo(ctx, given_channel: discord.TextChannel, message):
  print(given_channel.name)
  for channel in ctx.guild.text_channels:
    if channel == given_channel.name:
      await given_channel.send(message)``` 
is this what u meant??
slate swan
#

yesnt

#

you should be using channel.send instead of given_channel.send else it will keep sending the message in same channel multiple times

glossy flame
#

oh right

#

well it still dont work

slate swan
#

Is it because of await thing?

hazy oxide
#

Yk, replit thing

slate swan
#

@hazy oxide

#

If the variable have await its gonna be printed out?

ionic turtle
#

await has nothing to do with printing...

#

you should learn async/await before trying to use these async libraries

slate swan
#

how do i log when a user comes to my server in a specific channel?

paper sluice
#

!d discord.on_member_join

unkempt canyonBOT
#

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

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

listen for ^ event

slate swan
#

i sweae half my messages are getting deleted by autocorrect

paper sluice
#

rip

silk fulcrum
#

nice, that's absolutely what i wanted to see

maiden fable
#

Damn cool!
And The Award For The Best Error Goes To..... Master32!