#discord-bots

1 messages · Page 1095 of 1

karmic marsh
#

probably

frozen patio
#

How can I fix this?

karmic marsh
#

is there an easy way to do that other than manually?

#

probably using a foreach?

#

got it

#
for item in view.children:
  if item._provided_custom_id != "specificitem":
    view.remove_item(item)
#

is there a better way to write this?

#

actually, this doesn't quite work lol

#

it leaves one element, but not the right one

slate swan
#

!d discord.ui.Button.custom_id

unkempt canyonBOT
#

property custom_id```
The ID of the button that gets received during an interaction.

If this button is for a URL, it does not have a custom ID.
slate swan
#

why not use this?

karmic marsh
#

Uhhh

#

Idk. I thought that is what I was using lol

#

well, if I change it to custom_id it behaves even stranger

#

it now gets the correct item but also leaves one

#

so there are two items

#

how strange

#
for item in view.children:
``` skips the second element for some bizarre reason
brave flint
#

do someone know what this error mean?

raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.url: Not a well formed URL.```
brave flint
#

uh no...

#

i cant get the url value btw

sick birch
#

Okay well it's difficult to figure out what the issue is without the url

brave flint
#

it is an automatic

#

mhmm, wait lemme get it a sec

#

ah ye i cant

#

well so its a provided url error?

sick birch
#

Why can't you just print it?

#

If it's automated it should be going through your code regardless

brave flint
#

thats why

#

but maybe ill just download the image then use it mybe

sick birch
#

I'm not seeing how that has to do with printing out a variable

brave flint
sick birch
heavy folio
#

oop

sick birch
#

no prob

karmic marsh
#

Is there any way to take the UI elements and abstract them out so that I can build a UI from whichever elements I want?

#

basically this whole chunk:

@disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
    async def cancel(self, button, inter):
        button.disabled = True
        self.value = False
        self.stop()
#

I think it would have to be of type Item afaik

brave flint
scarlet aurora
#

Can someone help? ```py
if company == '1st':

        except_cr = []
        for rank_role_id in rank_ids.values():
            if rank_role_id != (rank_ids["Catulan_Reaver"]):
                rank_role = ctx.guild.get_role(rank_role_id)
                except_cr.append(rank_role)

        except_1 = []
        for rank_role_id in company_ids.values():
            if rank_role_id != (company_ids["1st Company"]):
                company_role = ctx.guild.get_role(rank_role_id)
                except_1.append(company_role)

        await user.remove_roles(*except_1)
        await user.remove_roles(*except_cr)
        await user.add_roles(ctx.guild.get_role(company_ids["1st Company"]))
        await user.add_roles(ctx.guild.get_role(rank_ids["Catulan_Reaver"]))``` These commands execute very very slowly, how can I speed up the process?
sick birch
scarlet aurora
sick birch
#

If I'm to guess something about removing those roles

scarlet aurora
#

how can I speed it up?

sick birch
#

perhaps figure out if there's a better way than to remove all those roles?

sick birch
#

Hmm that looks fine

#

Can I see the code where you construct the embed?

sick birch
#

I'm assuming you did print(a["fileurl"])?

brave flint
#

yes

slate swan
#

how can I use global cogs in my main file, and call them in my cog file

sick birch
#

🤔 maybe it's a reddit issue then

#

since the URL form looks right

brave flint
#

and it shown the image

#

all of the url printed i tried to send

#

on discord chat all of it shown too

#

i think yes i need to download it first

sick birch
#

Could be, not sure though that's strange

brave flint
#

my db like had 4k id registered "done" but like onlky 120 shown

karmic marsh
#

I have to imagine it's possible

brave flint
karmic marsh
#

And probably quite simple, I just don't know how

sick birch
scarlet aurora
sick birch
#

That's up to you, as that's a design decision

brave flint
#

bruh @sick birch

#

whats wrong with it lol

#

is it discord api error or what

gleaming pendant
#
import discord
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os
from discord_slash import SlashCommand

bot = commands.Bot(command_prefix='z!')
bot.remove_command('help')
slash = SlashCommand(bot, sync_command=True)

@slash.slash()
async def ping(ctx):
    await ctx.reply(f'Speed - {round(bot.latency * 10000)}ms')```
#

i already downloaded discord-py-slash-command

#

but i get this

#
discord-py 1.7.3 requires aiohttp<3.8.0,>=3.6.0, but you have aiohttp 3.8.1 which is incompatible.```
sick birch
slate swan
#

stop using it

gleaming pendant
#

wdym

slate swan
#

the library is unmaintained, outdated and bad

gleaming pendant
#

then, how can create slash commands

#

?

slate swan
gleaming pendant
#

whathow

slate swan
#

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

gleaming pendant
#

ok

#
import discord
from discord import app_commands
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync(guild = discord.Object(id = guild_id))
            self.synced = True
        print(f'Logged in as {self.user}.')


client = aclient()
tree = app_commands.CommandTree(client)

@tree.command(name = "help", description = 'test', guild = discord.Object(id = 602681616120414239))
async def self(interaction: discord.Interaction, name: str):
    await interaction.response.send_message(f"Hello!")```
slate swan
#

do pip show discord.py in terminal

gleaming pendant
slate swan
gleaming pendant
#

i tried to

slate swan
#

install git

gleaming pendant
#

how

#

where

slate swan
#

on ur pc

gleaming pendant
#

haha

slate swan
#

From here u can install git

karmic marsh
gleaming pendant
#

just used the pip install -U git+https://github.com/Rapptz/discord.py thing

slate swan
#

you didn't invite the bot with application commands scope

karmic marsh
#

this is the code I have now:

class UI(disnake.ui.View):
    def __init__(self,):
        super().__init__()
        self.value = None

    @disnake.ui.button(label="Confirm", style=disnake.ButtonStyle.green)
    async def confirm(self, button, interaction):
        self.value = True
        self.stop()

    @disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
    async def cancel(self, button, inter):
        button.disabled = True
        self.value = False
        self.stop()

and I'd like to abstract it out to something like this:

ConfirmButton = @disnake.ui.button(label="Confirm", style=disnake.ButtonStyle.green)
    async def confirm(self, button, interaction):
        self.value = True
        self.stop()

CancelButton = @disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
    async def cancel(self, button, inter):
        button.disabled = True
        self.value = False
        self.stop()

class UI(disnake.ui.View):
    def __init__(self,):
        super().__init__()
        self.value = None

    @ConfirmButton

    @CancelButton
#

actually wait

#

this might be way less complicated than I'm making it

gleaming pendant
#

cuz if i want it to work i need to use /help something

#
import discord
from discord import app_commands
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.default())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync(guild = discord.Object(id = guild_id))
            self.synced = True
        print(f'Logged in as {self.user}.')


client = aclient()
tree = app_commands.CommandTree(client)

@tree.command(name = "help", description = 'test', guild = discord.Object(id = guild_id))
async def self(interaction: discord.Interaction, name: str):
    await interaction.response.send_message(f"Hello!")```
karmic marsh
#
async def self(interaction: discord.Interaction, name: str):

should be:

async def self(interaction: discord.Interaction):
#

you're telling it that it needs a string called name

gleaming pendant
#

thx

sick panther
karmic marsh
#

alright, I've gotten this working somewhat as intended

#
CancelButton = disnake.ui.button(custom_id = "cancelitem", label="Cancel", style=disnake.ButtonStyle.grey)

ConfirmButton = disnake.ui.button(custom_id = "confirmitem", label="Confirm", style=disnake.ButtonStyle.green)

class UI(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    @CancelButton
    async def cancel(self, input, inter):
        self.value = 0
        self.stop()

    @ConfirmButton
    async def confirm(self, input, inter):
        self.value = 1
        self.stop()
#

the buttons themselves are defined outside of the View

#

but their actions are still defined locally

#

how can I move the actions outside of the UI class?

karmic marsh
#

okay... this is bizarre

#
import disnake
from disnake.ext import commands

CancelButton = disnake.ui.button(custom_id = "cancelitem", label="Cancel", style=disnake.ButtonStyle.grey)
async def cancel(self, input, inter):
        self.value = 0
        self.stop()


ConfirmButton = disnake.ui.button(custom_id = "confirmitem", label="Confirm", style=disnake.ButtonStyle.green)
async def confirm(self, input, inter):
        self.value = 1
        self.stop()

class UI(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    @CancelButton
    @cancel

    @ConfirmButton
    @confirm

class Ask(commands.Cog):
#... etc

this does not work. the class keyword in the last line errors with:

Expected function or class declaration after decorator
however, if I simply replace @confirm with

async def confirm(self, input, inter):
        self.value = 1
        self.stop()

it works just fine

#

it doesn't have to do with the specific function definitions, just whichever one is last errors out if it's using the @ syntax

#

uhh

#

at least I thought it worked

#

it doesn't now lmao

visual island
#

You probably want to use View.add_item() in your view's __init__

lyric apex
#

How to create page?

#

Like if someone click > so page + 1?

dim sentinel
#

uhhh so

#

i am running the bot on replit

karmic marsh
#

well then there's your problem

dim sentinel
karmic marsh
#

pins in bot-hosting thread

sick panther
dim sentinel
#

also how am i supposed to make my bot get unbanned 💀

lyric apex
lyric apex
sick panther
dim sentinel
#

doesnt work anymore

sick panther
#

Well, youre ratelimited ofc it wont

dim sentinel
sick panther
#

yup

dim sentinel
#

thanks

tough lance
#

Ofc

slate swan
#

tbh just don't use replit, there are many cons

sick panther
#

But I suggested you to ditch replit, as theyre using shared IPs

dim sentinel
sick panther
#

what no

dim sentinel
sick panther
#

ye

lyric apex
slate swan
dim sentinel
slate swan
#

still, don't do this

dim sentinel
lyric apex
#

YeahZz_okie

dim sentinel
lyric apex
#

It should

dim sentinel
sick panther
#

vps>

dim sentinel
#

is it free?

lyric apex
lyric apex
dim sentinel
#

sad

slate swan
#

kill is basically a command used to end process, for replit the 1st process is the repl itself so its fine to use this there, but in a general system it can be anything

slate swan
dim sentinel
slate swan
dim sentinel
slate swan
#

still not suggested to use replit for hosting :)

dim sentinel
#

so when's my bot gonna run again 💀

slate swan
lyric apex
slate swan
dim sentinel
slate swan
#

oop, so you're blocked by the api, wait is the only option for you :/

dim sentinel
#

🥲

slate swan
#

maybe, there's no specific time limit

#

if you're just testing code do it on some other bot lol

maiden fable
#

Since that service is what runs other services iirc

slate swan
maiden fable
#

Thought so

slate swan
#

ded chat

#

hi

paper sluice
#

hi

maiden fable
#

hi

slate swan
#

i have remove command

async def remove(self,ctx:commands.Context,name):
 pass

i want like check if name is a channel or a role in mention like #discord-bots or @role

#

like we do : name : disnake.channel

#

something like that

#

you can use typing.Union

maiden fable
#

or make a custom converter

slate swan
#

typing.Union[discord.Channel, discord.Role], raises an error if its None of them

#

okay

#

what hunter said is more extendable tho

#

basically a class with an async convert function

maiden fable
#

yes

slate swan
#

ofcourse

#

thanks 👍

formal basin
#
@client.event
async def on_member_update(before, after, member):
        if after.guild.id == 964841408257200179:
            if before.activity == after.activity:
                return

            role = get(after.guild.roles, id=984560896460357633)
            channel = get(after.guild.channels, id=984561160953139231)

            async for message in channel.history(limit=200):
                if before.mention in message.content and "is now playing" in message.content:
                    if isinstance(after.member.activity, discord.Game):
                        return

            if isinstance(after.member.activity, discord.Game):
                await after.add_roles(role)
                playing_service = member.activity.name_split[1]
                playing_service = member.activity.name.capitalize()
                await channel.send(f"{before.mention} is now playing {playing_service}")
            elif isinstance(before.member.activity, discord.Game):
                await after.remove_roles(role)
                async for message in channel.history(limit=200):
                    if before.mention in message.content and "is now playing" in message.content:
                        await message.delete()
            else:
                return

#

I’m trying to make a notification bot that sends something in the chat when a user is playing something

slate swan
formal basin
#

Ok

formal basin
slate swan
slate swan
#

youre trying to access an attribute, which the Member class doesnt have.

formal basin
formal basin
#

User?

#

Could I do user?

slate swan
#

check the documentation, e.g all the attributes the Member class has/contains.

#

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

code pls

formal basin
#
@client.event
async def on_member_update(before, after):
        if after.guild.id == 964841408257200179:
            if before.activity == after.activity:
                return

            role = get(after.guild.roles, id=984560896460357633)
            channel = get(after.guild.channels, id=984561160953139231)

            async for message in channel.history(limit=200):
                if before.mention in message.content and "is now playing" in message.content:
                    if isinstance(after.member.activity, discord.Game):
                        return

            if isinstance(after.member.activity, discord.Game):
                await after.add_roles(role)
                playing_service = after.member.activity.name_split[1]
                playing_service = after.member.activity.name.capitalize()
                await channel.send(f"{before.mention} is now playing {playing_service}")
            elif isinstance(before.member.activity, discord.Game):
                await after.remove_roles(role)
                async for message in channel.history(limit=200):
                    if before.mention in message.content and "is now playing" in message.content:
                        await message.delete()
            else:
                return

formal basin
#

I put activity

#

Hello?

marble rampart
#

someone know if i can run two bots at the same time ?

#

like from the same python file that i will run

vale wing
#

Use asyncio.gather on start methods of your bot instances

#

I think that should work

#

Except you might have loops conflicts

#

In that case use threads

slate swan
#

i created a music bot and it's not playing music

#

it says ffmpeg was not found.

#

should i download the ffmpeg as an app on my pc

#

and if i do how do i extract it's files

#

and where do i extract it

#

hi

honest shoal
slate swan
#

um i need to know that if someone pinged my bot so how do i reply the info the bot

honest shoal
#

can we edit ephermal messages?

slate swan
#

pls tell me the exact code

honest shoal
stark fable
#

hi guys, what's the endpoint to get the list of all the servers that i'm in ? (not the bot's server, the account that's in the servers)

slate swan
#

lemme try message

honest shoal
slate swan
honest shoal
honest shoal
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.
spring flax
honest shoal
slate swan
#

!d discord.ext.commands.Context , ctx is not a thing

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

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

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

idts, ephemeral messages can only be created by an interaction and the response are webhooks, which I don't think can be edited

honest shoal
#

webhooks can be edited

slate swan
#

so your ephemeral responses can be edited as well, except for they can't be changed to normal message

spring flax
#

If I want to make a bot where it for example has an interactive system where it can mass-edit channel permissions for roles or members what would be an ideal approach?

honest shoal
lyric apex
#

How to use message to reference?

honest shoal
#

I tried it, and got an attribute error, console AttributeError: 'NoneType' object has no attribute 'edit'

honest shoal
#

was editing ephermal message, without any other interaction

lyric apex
#

There's Something Wrong In Your Code

odd mango
#

how do i fix this

    for i in embeds:
        if len(embeds) == 1:
            await ctx.send(embed=i)
        else:
            for j in embeds:
                menu.add_page(j)
            await menu.start()```
#

i mean it works fine but due to for loops messed up i get errors

slate swan
slate swan
#

thats not gonna work

#

!d discord.InteractionResponse

unkempt canyonBOT
#

class discord.InteractionResponse```
Represents a Discord interaction response.

This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").

New in version 2.0.
honest shoal
#

but I don't want any other interaction at that place

slate swan
#

theres some method here, just check and use it

lyric apex
odd mango
honest shoal
#

@slate swan I checked it, it is editing the original message which I was already doing, let me explain my process

❯ There's a message containing some information with button in a channel.
❯ I click on the button to refresh the information and bot replies with an ephermal message 🔃 Refreshing
❯ After the refresh is done and the original message is edited I want that ephermal message also to be edited to Refreshed. because there's very high chance I'll get same information in the main message

slate swan
honest shoal
#

already doing that

#

I want to edit another msg as well

slate swan
#

How to display the number of participants on the server

paper sluice
#

!d discord.Guild.members

unkempt canyonBOT
paper sluice
#

get the len from that

slate swan
#

ok

rocky hornet
slate swan
rocky hornet
#

um.. ok?

#

could you answer my question please?

maiden fable
#

Nvm, my bad

honest shoal
heavy folio
#

hunter could you answer in #discord-bot-hosting if youve used gh edu and if you can ty

maiden fable
rocky hornet
#

thx

slate swan
#

ok do i just move ffmpeg to PATH and it'll work?

#

@honest shoal

slate swan
#

to where exactly?

#

in the lib folder

#

or just in python's folder

exotic kite
#

Hello guys

#

can someone tell me what is the error in this

slate swan
exotic kite
#

no error

#

but when i try command it doesnt work

slate swan
#

run it using windows powershell

exotic kite
#

yk what nvm it

#

i was just trying new commands, it isnt what i need mainly so dont worry

slate swan
#

ok

lyric apex
#

How to get the msg id of excuted cmd not by using

msg = await ctx.send(...)
print(msg.id) ```
Is there any other method?
lyric apex
slate swan
#

uh?

lyric apex
#

Like i wanted to delete the command executed by that msg id but not using that i mentioned in that msg @slate swan

spring flax
#

there is a delete_after kwarg in send

slate swan
#

^

#

or use the delay kwarg in the delete method of the Message object

lyric apex
#

By fetching that message*

#

No way?

maiden fable
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
maiden fable
#

The delay kwarg

lyric apex
maiden fable
#

Wym

maiden fable
#

U need the message ID...

lyric apex
#

Yeah

maiden fable
#

And the text channel id

#

To fetch the msg

lyric apex
#

Yep

maiden fable
#

Sooooo?

lyric apex
#

How to do thatZz_okie

#

||Ashley||zz_Sad_Cat

slate swan
green bluff
#

can someone help me with my code? a kind of lib im trying to make (makes coding for me easier)

slate swan
green bluff
#

im trying to make coding for me easier

maiden fable
#

Doesn't dpy already do that for u?

green bluff
slate swan
#

I'm already crying after seeing the naming conventions

maiden fable
#

And Python being a high level language also does that

lyric apex
#

That message that is replied by the bot

maiden fable
#

msg = await ctx.send bro

lyric apex
maiden fable
#

Why tf will u want to do an API call if u easily have access to the msg

slate swan
maiden fable
#

Because he wants another way

slate swan
#

but why

maiden fable
#

¯_(ツ)_/¯

lyric apex
#

zz_Sad_Cat I said The Reason is ||G.K||

slate swan
#

wth is G.K

maiden fable
maiden fable
slate swan
#

ew

#

imagine msg.delete()

#

un-danny-ific

#

basically what the delete_after kwarg does

lyric apex
maiden fable
#

Stop overusing emojis now

slate swan
#

use their escaped names instead

maiden fable
#

Yup

#

Let everyone feel like they are in the discord bots dev channel and get the vibe

slate swan
#

nobody ever forbid to use emojis

lyric apex
#

What does to_reference does?

slate swan
#

wot object's method is that

#

related to replies/mentions iirc

maiden fable
#

Replies

slate swan
#

Imagine not using robo danny

slate swan
lyric apex
#

Can we find msg id referenced to that bot command

maiden fable
slate swan
maiden fable
#

Hunter*

slate swan
#

smarty hunter

lyric apex
# maiden fable Wym

Like if i use a command hi my bot replies me hello so i want to get that hello message id by using reference? Is it possible

pure void
#
@bot.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=5):
    await ctx.channel.purge(limit=amount + 1)

When an unauthorized person uses this code, I want him to send a warning message. How can I do that?

You dont have ....permissions.

slate swan
#

!d discord.ext.commands.Command.error

unkempt canyonBOT
#

@error```
A decorator that registers a coroutine as a local error handler.

A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.

Changed in version 2.0: `coro` parameter is now positional-only.
slate swan
#
client.load_extension(f"cogs.{filename[:-3]}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

what is this error?

lyric apex
#

Then?

slate swan
maiden fable
# lyric apex Then?

Like, I replied to yr message, so now when I do ctx.message.reference (assuming my msg is the command msg), then I get yr msg object

slate swan
#

!d discord.Message.reference

unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

lyric apex
#

if it is none?

maiden fable
#

Nothing was replied to

heady sluice
magic pond
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object of type 'NoneType' has no len()
                em.add_field(
                  name='**Badges**',
                  value=f'{"  ".join(get_badges(user)) if len(get_badges(user)) > 0 else "`None`"}')
pure void
#
@bot.command()
async def clear(ctx, amount=5):
        await ctx.channel.purge(limit=amount + 1)
        await ctx.send(" deleted messages")

How can I delete " deleted messages" after 5 seconds?

magic pond
#

it works for a person who has a badge but doesnot work if i dont hv any badge

slate swan
slate swan
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 | AttributeError: 'NoneType' object has no attribute '__len__'. Did you mean: '__le__'?
rocky hornet
#

if guild has 1 million members

#

are they all cached?

dull terrace
#

can someone explain to me why one random function in my entire code would refuse to recognise a variable as global

#

unless i explicitly declare it as global

rocky hornet
#

global is shit

dull terrace
#

very helpful tooru

rocky hornet
#

i tried

slate swan
#

until your memory usage max's out and the not crashes

dull terrace
#

if you can tell me a better way than using globals to access database cursors and connections i'd like to hear it

slate swan
unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

dull terrace
rocky hornet
slate swan
rocky hornet
#

do you know python basics?

livid hinge
#

kinda

dull terrace
rocky hornet
#

btw even better way is ```py
async with Connection() as bot.db:
await bot.connect()

slate swan
paper sluice
dull terrace
slate swan
#
class Foo:
   bar: str = "x"
``` is same as  ```py
Foo().bar = "x"
rocky hornet
#

after the second one, Foo class still doesnt have bar, only that instance has it

livid hinge
#

like i usually put in __init__

self.cursor = connect(...).cursor()```
rocky hornet
#

shouldnt u create a new cursor for each query?

livid hinge
#

class prob fine too if you dont need instances

#

you dont have to

#

afaik

dull terrace
#

welp, i can say that i use the same cursor for every query and it works fine

rocky hornet
#

also i would suggest to utilize dependency inversion pattern

#

and pass db connection to bot's init

#

rather than creating it inside

#

how can i run an arg against a Union of Converters?

#

much like dpy param parsing

rocky hornet
#

functionally

slate swan
rocky hornet
#

sure

#

in the end we create bot instance only once

dull terrace
#

also the global was messing up because i was using the same variable name for something later in the function for something else

slate swan
#

thats the reason for which you shouldn't be using globals

granite parcel
#

how to create pages

paper sluice
#

Cellulose fibers are extracted from a variety of sources and converted to pulp.
Pulp is combined with water and placed on a paper making machine where it is flattened, dried, and cut into sheets and rolls.

rocky hornet
paper sluice
fallen mica
#

any possible way of making a music bot with spotify links?

rocky hornet
#

define possible

fallen mica
#

under 100 lines of code which doesn't require me to download 20 web pages

rocky hornet
#

no kekw

fallen mica
#

damn, welp i tried

granite parcel
rocky hornet
#

be more specific in discord's context

#

embed? codeblock?

granite parcel
#

page1 = ""

rocky hornet
#

what library

rocky hornet
#

well

granite parcel
#

like that so on

rocky hornet
#

if its a string, then Message.edit

granite parcel
#

yeah but i want if someone click on next then it change

rocky hornet
#

what lib

paper sluice
granite parcel
#

dpy 2.0

rocky hornet
#

WHAT LIB

#

ok

slate swan
#

basically a paginator wut

granite parcel
#

yep paginator

rocky hornet
#

i only know disnake examples terided

slate swan
#

discord has some inbuilt pagination class iirc

#

!d discord.ext.commands.Paginator

paper sluice
# granite parcel dpy 2.0

u can store the "pages" in a list and change the index on button click, or if u want something better use discord.menus.ListPageSource

unkempt canyonBOT
#

class discord.ext.commands.Paginator(prefix='```', suffix='```', max_size=2000, linesep='\n')```
A class that aids in paginating code blocks for Discord messages.

len(x) Returns the total number of characters in the paginator.
rocky hornet
paper sluice
#

rip embed code blocks

granite parcel
#

i think there are so many way to do that

rocky hornet
#

yeah the builtin one works with strings, what you want

#

although it doesnt use buttons afaik

slate swan
#

||kannapoggy lightbulb got inbuilt paginators with button and reaction types||

rocky hornet
granite parcel
#

hikari?

rocky hornet
#

give some love to the other command impl

slate swan
#

im unsure, but im quite sure they don't have it

rocky hornet
#

everyone uses lightbulb

slate swan
#

not true, im kinda interested in crescent now

rocky hornet
#

isnt tanjun supposed to be more "advanced"

#

havent heard of crescent

slate swan
#

Released recently

rocky hornet
#

and i've not even used hikari myself, so i dont know a lot about it

slate swan
#

it got a cleaner interface

slate swan
rocky hornet
#

yea the only thing i know its good KEKW

slate swan
#

Especially about their code bases

rocky hornet
#

trust me u dont wanna know their code base

granite parcel
#

page += 1

#

what does it mean?

slate swan
rocky hornet
slate swan
#

i dig a lot into pycord's, just to answer "why not use" pycord question.

paper sluice
granite parcel
rocky hornet
#

my very simple embed paginator

slate swan
rocky hornet
#

oh thats a good idea to remove buttons after timeout, ill add that

#

dont sue me pls

slate swan
#

its open source anyways so~

paper sluice
#

lol, i yanked mine from danny

slate swan
#

i find danny's paginator kinda overkill

#

especially for my purposes

rocky hornet
#

you are using a mutable default value

#

embeds is a list

#

so when you call init again, it uses the same list, which could already be non-empty

paper sluice
rocky hornet
#

i find danny's paginator utter crap

#

ugliest thing i've seen on discord

#

codeblocks.. really?

maiden fable
paper sluice
#

codeblocks?

rocky hornet
#

without any highlighting whatsoever

rocky hornet
minor totem
#

Any tips or advice when developing Discord bots on replit?

odd mango
#

how do i fix this

    for i in embeds:
        if len(embeds) == 1:
            await ctx.send(embed=i)
        else:
            for j in embeds:
                menu.add_page(j)
            await menu.start()```
i mean it works fine but due to for loops messed up i get error
rocky hornet
#

i guess he took pages too literally

rocky hornet
minor totem
#

No

rocky hornet
#

yes

maiden fable
minor totem
#

I am using interactions, I am literally using replit for what it was made for

rocky hornet
minor totem
maiden fable
#

Oh

minor totem
#

👌

rocky hornet
#

wow

maiden fable
#

Why tho 🤨

paper sluice
minor totem
# maiden fable Why tho 🤨

Discord requires HTTPS. Either this, or I use like Ngrohk/localtonet (iffy), or somehow set up my own domain with certification 😅

rocky hornet
vernal fog
#
from discord.ext import commands

@commands.command()
async def status(ctx):
    await ctx.reply(f"{bot.user.name}")

def setup(bot):
    bot.add_command(status)
``` I'm working with extensions in discord.py, but I'm wondering how to include the bot class from my "main.py"-file so that i can call {bot.user.name} like above. Could anybody help me?
minor totem
#

Replit is the easiest way to do this because you get an HTTPS URL

rocky hornet
#

hi

slate swan
paper sluice
rocky hornet
#

Class() calls __init__ automatically

slate swan
#

it is... but wdym by init again

rocky hornet
slate swan
#

then you create another instance of the paginator ez

rocky hornet
#

u dont get it

#
class A:
    def __init__(self, b=[]):
        b.append(2)
        print(b)
A() # [2]
A() # [2, 2]
#

@slate swan

slate swan
#

oop

#

1 min

odd mango
#

👍

rocky hornet
odd mango
#

i thought you were looking for a better paginator?

rocky hornet
#

no?

odd mango
#

uh okay...

paper sluice
summer bough
paper sluice
#

install it

#

and dont use replit

rocky hornet
#

inbefore pip install discord

#

💀

summer bough
rocky hornet
summer bough
#

Oki

rocky hornet
#

what

odd mango
rocky hornet
#

they didnt say they wanted dpy specifically, so i saw no reason to install an inferior lib

#

ah, my bad pip install disnake[discord]

#

now it works

#

and you're using a better library

#

only upsides dem

minor totem
#

Replit interactions 👍

slate swan
rocky hornet
#

lol

brave moth
#

im trying to make an embed generator but when i tried, nothing comes and there is no error

rocky hornet
#

this is a very helpful error message

#

@slate swan 1v1 me in RL to decide if dpy is better than disnake

brave moth
#

if someone wants a message sent in embed including an image and want to add extra fields. ive tried with from_dict but nothing shows

rocky hornet
#

uhhh i play from pc, can i give you my epic games tag?

wide thunder
#

Is there any free hosting doesnt matter if its slow or bad i just wanna host my bot in one server

brave moth
#

im talking about generating it but with a json

odd mango
#

halp

    for i in embeds:
        if len(embeds) == 1:
            await ctx.send(embed=i)
        else:
            for j in embeds:
                menu.add_page(j)
            await menu.start()```
i mean it works fine but due to for loops messed up i get error
brave moth
#

can i just send my code here?

#

bot related

#

theres no traceback or anythig

wide thunder
rocky hornet
#

party chat is cross-platform, also im currently at work and will return home in about 3.5 hours. is it fine if i dm you my id?

wide thunder
#

Any idea?

minor totem
brave moth
#
from json import loads
from nextcord import *
from nextcord import slash_command as jeanne_slash
from assets.errormsgs import admin_perm
from asyncio import TimeoutError
from nextcord.ext.application_checks import *

    @jeanne_slash(description="Main say command")
    async def say(self, ctx: Interaction):
        pass

    @say.subcommand(description="Type something and I will say it in embed")
    @has_permissions(administrator=True)
    async def embed(self, ctx: Interaction, channel: GuildChannel = SlashOption(description="Which channel should I send the message?", channel_types=[ChannelType.text, ChannelType.news])):
            ask = Embed(
                description="Type something")
            await ctx.followup.send(embed=ask)

            def check(m):
                return m.author == ctx.user and m.content

            try:
                msg = await self.bot.wait_for('message', check=check, timeout=300)
                embed_text = Embed.from_dict(loads(msg.content))
                await msg.delete()
                await channel.send(embed=embed_text)
                
                await ctx.followup.send("Sent", ephemeral=True)
            except TimeoutError:
                timeout = Embed(
                    description=f"Guess you have nothing to say", color=0xFF0000)
                await ctx.followup.send(embed=timeout, ephemeral=True)```
minor totem
#

I host my bot on Google Cloud for free. Although... it has 40K members 😅 So you'll do fine there

brave moth
#

well crap...

paper sluice
#

loads makes it a json object from str....

#

a dict basically

brave moth
#

ive been doing that for long but now, i want it to be generated. the user can add own fields and color

#

i know someone who did that but their bot is coded in c#

#

well, my first guess was json then it converts to embed

slate swan
#

!d discord.Embed.from_dict this or what....?

unkempt canyonBOT
#

classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") provided it is in the format that Discord expects it to be in.

You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
slate swan
#

or am I taking it the wrong way

#

who knows

boreal ravine
#

They could use flags

chrome apex
#

can someone tell me how to host a discord bot on aws

boreal ravine
brave moth
#

thx

#

will try it

slate swan
#

guys, I am trying to install discord.py, but when I try, it returns errors? What do?

paper sluice
#

how are you installing it?

slate swan
#

using the python terminal, lemme get the error up.

#

python terminal?

#

imagine using python.exe directly

paper sluice
slate swan
#

ohhhh

#

that would be CMD then

rocky hornet
#

when i use (self, ctx, *args) does dpy simply use str.split on message content to give me a list?

paper sluice
rocky hornet
#

if you denote a parameter like that, yes

odd mango
#

is a json file good to use for a custom prefix command?

rocky hornet
#

*, text will return it as 1 string

odd mango
#

or do i need a db

paper sluice
#

i thought i was just a tuple like normal

rocky hornet
#

other than that u want a db

odd mango
#

so db right

#

cause set prefix command can be ran anytime

#

so json data is dynamic

rocky hornet
#

could be a tuple

#

i thought u meant list as a data structure

rocky hornet
#

what if 2 people use this command at once

boreal ravine
boreal ravine
rocky hornet
#

or a db 😅

boreal ravine
#

Yes

odd mango
#

the help command though, i am using the minimal help command. will the help command content also update [in only different prefix server] with prefix change?

rocky hornet
#

you need your own logic to grab prefix(es) from your own function

odd mango
#

oh okay

odd mango
slate swan
#

How do I run the file to start my bot, now I have it setup?

livid hinge
#

i dont see why youd need separate db

paper sluice
odd mango
livid hinge
odd mango
#

isnt sql in tabular form?

#

so i just need another table?

livid hinge
#

just store in same db

#

you have a table for options or smth

#

key/value store

#

you could put it there

odd mango
#

yeah

#

also

slate swan
#
  • wdym where am I running it
odd mango
#

is it fine to use json for storing data which is static, and file opened only on initialization?

livid hinge
#

py yourfile.py

odd mango
#

does it fine work even with command spam?

livid hinge
#

should work

odd mango
slate swan
#

Should I do it from CMD or Terminal?

slate swan
shrewd apex
slate swan
#

How can I make 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.

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
slate swan
#

I already understood how to do it

#

Ex:

embed1 = discord.Embed(title="Hello world",description="some description")
await ctx.send(embed=embed1)
slate swan
slate swan
#

👍

soft lynx
#

hey, i keep getting this error (im using replit as the ide). my project was working yesterday, went to rerun it today and bam this error appeared - any idea as to why its saying too many redirects?

warm sand
#

ok so im looking for a way to make my bot ping a role on use of (?vc) while having a global cooldown of 4 hours

warm sand
#

the code i spent 1 hour doing is trash

soft lynx
livid hinge
#

hm

soft lynx
#

ill try it again

livid hinge
#

theres a pip.cnf , you could delete

soft lynx
#

alright this time i used kill 1,

#

there was a module with that name yesterday

livid hinge
#

is that from discord-interactions or smth

soft lynx
#

yeah

livid hinge
#

thats in your pyproject

#

could try venv/bin/python -m pip install discord-interactions in shell

#

or just rm -rf venv and start over

#

very buggy tool imo

soft lynx
#

i was thinking of using pip freeze and then seeing what moduels are important

#

than making a requirements file

#

ill try that first tho

livid hinge
#

yeah i get rid of the poetry crap coz it never works right in replit for me

#

requirements.txt does

slate swan
#

how do i make only admins able to run this command

shrewd apex
#

!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
slate swan
unkempt canyonBOT
#

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

Note that this check operates on the permissions given by [`discord.Interaction.permissions`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.permissions "discord.Interaction.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/interactions/api.html#discord.app_commands.MissingPermissions "discord.app_commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure").

New in version 2.0...
slate swan
#

wrong reply nvm

shrewd apex
#

oh he was using slash commands never saw my bad thanks ashley

slate swan
#

New Discussion Topic: Why do people have "Discord Bot Developer" in their bio and ask basic and stupid questions in this channel? Comment.

pure void
#

I want to put a picture of the person using the command on the right side, how can I do that?

slate swan
slate swan
#

lmao

shrewd apex
pure void
# slate swan embed.set_thumbnail(url=avatarurl)
@bot.command()
async def embed(ctx):
    embed = discord.Embed(
        title='This is a title! you can customise this!',
        description='This is a description!',
        colour=discord.Color.green(),
        timestamp=datetime.datetime.now()

        ).add_field(
        name='This is non inlined field 1!',
        value='This is a value!',
        inline=False
        )
    await ctx.send(embed=embed)

sorry i don't understand can you show me on this code?

shrewd apex
#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

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

In that case, I'm a Quantum Mechanics professor

slate swan
#

guys

#

im try open cd command

#

and im open my file say this error

#

help me ?

slate swan
potent spear
slate swan
#

but this would be like judging people, so nvm

#

lmao

#

thinking I should put it too

quaint epoch
slate swan
#

😔 leave mah man alone!

livid hinge
#

wdym ?

#

i dont always talk

#

and no probly not as often as some ppl

potent spear
#

doesn't matter too much, David
you're almost an Ed Sheeran lookalike if you had curls I think

livid hinge
#

so many ppl tell me so lmao

#

better than being a murderer lookalike ig

#

i like poetry just not in replit

slate swan
#

poetry is cool and handy

paper sluice
slate swan
#

i believe replit messes with poetry only because of their outdated py version (3.8.2/4) and auto lib installations

pure void
slate swan
#

the exact thing would be ctx.author.avatar_url

livid hinge
#

whats the () at the end, is that part of it

slate swan
#

Don't call

slate swan
paper sluice
livid hinge
#

lol i didnt realize you can init Embed like that

slate swan
livid hinge
slate swan
#

suggest some games for discord bot

paper sluice
quaint epoch
#

makes sense, right?

livid hinge
#

someday maybe

slate swan
#

how does the number of messages he sent matter?

paper sluice
pure void
slate swan
pure void
slate swan
#

tetris?

#

What's that

pure void
#

nvm

slate swan
# slate swan tetris?

you can't possibly create tetris within the discord app so it isn't possible anyways

potent spear
slate swan
paper sluice
slate swan
potent spear
#

wow, we're getting old

slate swan
#

or steal tic_tac_toe.py from Rapptz/discord.py -> examples/

#

lol no

paper sluice
#

or just steal @lament depot

wicked atlas
#

ratelimits might keep you to one player at a time but probably possible

formal basin
#

Or just here

wicked atlas
formal basin
#

Ohhh ok

potent spear
slate swan
wicked atlas
#

same

slate swan
#

arrow functions in js are basically like lambdas right?

wicked atlas
#

yeah

slate swan
wicked atlas
#

.name.split()[1]

#

not sure why you're splitting though

#

and you even override the value the line after it

slate swan
#

checking the 2nd word in the activity ig

formal basin
slate swan
unkempt canyonBOT
#

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

['word1', 'word2', 'word3']
formal basin
#

Comma?

wicked atlas
#

or if theres only one word

#

!e print("word".split())

unkempt canyonBOT
#

@wicked atlas :white_check_mark: Your eval job has completed with return code 0.

['word']
wicked atlas
#

nvm, that was something else

slate swan
formal basin
#

So I don’t need split

wicked atlas
#

!d str.split

unkempt canyonBOT
#

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

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

For example:
narrow grail
#

how to remove a item on timeout in a class?

slate swan
#

!d discord.ui.View.on_timeout

unkempt canyonBOT
#

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

A callback that is called when a view’s timeout elapses without being explicitly stopped.
slate swan
#

!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.
narrow grail
formal basin
#

Yay thanks guys it’s working

slate swan
#

im guessing you are looking for self.clear_items

narrow grail
# slate swan show code and full traceback
  def __init__(self,ctx):
    super().__init__(timeout=10)
    self.ctx = ctx
  @discord.ui.button(label='next', style= discord.ButtonStyle.gray)
  async def button_callback(self,button, interaction):
    
    await interaction.response.edit_message(content='test')
  
  async def on_timeout(self):
    await view.clear_items()```
narrow grail
# slate swan .

I tried and it says: Traceback (most recent call last): File "main.py", line 34, in on_timeout await self.clear_items() TypeError: object NoneType can't be used in 'await' expression

slate swan
#

because you don't await it.

narrow grail
#

oh ok

narrow grail
slate swan
#

that just clears the items from your view, not your message

narrow grail
#

no I want to delete the button, the message should stay there

#

@slate swan

slate swan
#

that just clears the items from your view, not your message

#

!d discord ui.View.stop

#

!d discord.ui.View.stop

unkempt canyonBOT
#

stop()```
Stops listening to interaction events from this view.

This operation cannot be undone.
slate swan
#

hse this

narrow grail
#

so self.stop()?

slate swan
#

nvm it wont work either

cloud dawn
#

Just edit the message and pass an empty view aka None lmao

narrow grail
#

hm

unkempt canyonBOT
#

examples/views/disable_view.py lines 45 to 49

# Defines our view so that we can use the message in on_timeout to edit it
view = MyView()

# Sends a message with the view
view.message = await ctx.send("These buttons will be disabled or removed", view=view)```
`examples/views/disable_view.py` lines 12 to 18
```py

async def on_timeout(self):
    # Once the view times out we disable the first button and remove the second button
    self.children[0].disabled = True  # type: ignore
    self.remove_item(self.children[1])
    # make sure to update the message with the new buttons
    await self.message.edit(view=self)```
slate swan
cloud dawn
#

Wait i got sum code.

slate swan
cloud dawn
#

Perfect valid response.

slate swan
paper sluice
#

just do self.message = interaction.message (after interaction)

slate swan
#

yeah, thats what the example above basically did ( in a message command though)

paper sluice
#

ah i didnt notice

lyric apex
#

Fetching users with name in client guilds member?

cloud dawn
lyric apex
#

How to do that

cloud dawn
unkempt canyonBOT
#

await wait()```
Waits until the view has finished interacting.

A view is considered finished when [`stop()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.stop "discord.ui.View.stop") is called or it times out.
cloud dawn
#
Returns
If True, then the view timed out. If False then the view finished normally.
lyric apex
slate swan
slate swan
cloud dawn
cloud dawn
narrow grail
cloud dawn
slate swan
#

yeah panda, dealing with extra methods and an additional interaction is just making it an extra deal 😔

slate swan
cloud dawn
wicked atlas
slate swan
cloud dawn
narrow grail
pure void
#
        title=f'hello {member.mention} ',

Why does the mention look like this?

#

how can i fix this?

slate swan
#

you can't mention someone in author, title, field names and footers

narrow grail
#

so actually non of this works

#

my button is still there

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.

narrow grail
# paper sluice !paste show code
  def __init__(self,ctx):
    super().__init__(timeout=10)
    self.ctx = ctx
  @discord.ui.button(label='next', style= discord.ButtonStyle.gray)
  async def button_callback(self,button, interaction):
    
    await interaction.response.edit_message(content='test')
  
  async def on_timeout(self):
    await self.clear_items()```
slate swan
#

now you didn't do the await self.message.edit

timber forum
narrow grail
timber forum
#

Who could solve it?

odd mango
#

what all errors i MUST be handling in on_command_error function

odd mango
paper sluice
#

interactions come before buttons

narrow grail
odd mango
#

ohh

paper sluice
odd mango
narrow grail
paper sluice
#

ya but u need the send a message/edit the message for it to show up on the screen

slate swan
slate swan
paper sluice
narrow grail
paper sluice
narrow grail
#

ok

paper sluice
#

like UserInputErrors, CommandNotFound, many more

odd mango
#

yeah i need a list of them

#

which happen often

slate swan
#

the first thing I'd do is not handle or raise thr commands.CommandNotFound, then a mixed response for UserNotFound, MemberNotFound and ChannelNotFound, then MissingRequiredArgument

paper sluice
narrow grail
odd mango
paper sluice
#

i already gave the two most common ones, rest are those

slate swan
#

mixed response not in any programming related term lol, basically same if/elif block for all these errors.

narrow grail
#

finally got it, thanks @slate swan @paper sluice

paper sluice
slate swan
#

Adding, Did u mean? Is better

odd mango
# slate swan mixed response not in any programming related term lol, basically same `if/elif`...

yeah thats what, i wanna do sm like

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        await ctx.send("**Invalid command. Try using** `help` **to figure out commands!**")
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send('**Please pass in all requirements.**')
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("**You dont have all the requirements or permissions for using this command :angry:**")```
paper sluice
slate swan
slate swan
slate swan
odd mango
#

okayy

odd mango
slate swan
#

Bruh dc lagged

odd mango
#

command not found happens a lot cause bots with same prefix exist

paper sluice
slate swan
# odd mango so which all main ones i need to do

​    ​BotMissingPermissions​,
​    ​MissingPermissions​,
​    ​MissingRole​,
​    ​DisabledCommand​,
​    ​ChannelNotFound​,
​    ​MemberNotFound​,
​    ​UserNotFound​,
​    ​TooManyArguments​,
​    ​CommandOnCooldown​,
​    ​MissingRequiredArgument​,
​    ​PrivateMessageOnly​,
​    ​NoPrivateMessage​,
NotOwner,
CommandOnCooldown is what i handle

odd mango
#

nvm

odd mango
# slate swan .

so is it okay if it spams red on my console if i do a wrong command ?\

slate swan
#

you are aware of pass and return statements right?

odd mango
#

yeah what of those?

#

just this?

    if isinstance(error, commands.CommandNotFound):
        return
    raise error```
shrewd apex
#

no

#

u have to create specific handlers for these events

odd mango
#

come at your server

slate swan
#

what does anyone know how to create a webhook with a picture

warm torrent
#

hello I'm trying to create a command in which people can get the bot to dm a user whose id is specified as well as the message itself but my code wont work and i returns the error "AttributeError: 'NoneType' object has no attribute 'send'
Here is the code

async def sendid(ctx, userid, Message):
 await ctx.channel.send("debug")
 id = int(userid)
 user = bot.get_user(id)
 await user.send(Message)````
can you help please ?
lyric apex
#

!d discord.Member | If you want it only for ctx.guild.members then replace User with 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.
devout iris
#

How can i make live server count???

paper sluice
#

draw?

warm torrent
slate swan
#

Dear please tell me what is wrong

    @commands.Cog.listener()
    async def on_member_join(member):
        channel = client.get_channel( 977252614498582538)

        role = discord.utils.get ( member.guild.roles, id = 977252174964871258)

        await member.add_roles (role)
        await channel.send ( embed = discord.Embed (description = f"``{member.name}``, добро пожаловать на сервер", color = 0xffffff))
dawn shard
sick birch
slate swan
#

oh right. just got another error


    @commands.Cog.listener()
    async def on_member_join(self, member: discord.Member):
        channel = client.get_channel( 977252614498582538)

        role = discord.utils.get ( member.guild.roles, id = 977252174964871258)

        await member.add_roles (role)
        await channel.send ( embed = discord.Embed (description = f"``{member.name}``, добро пожаловать на сервер", color = 0xffffff))
sick birch
#

Your client is not an instance of discord.Client, but an instance of http.client for some odd reason?

#

If you have this import, delete it:

from http import client