#discord-bots

1 messages · Page 810 of 1

cold sonnet
#

takes self as the first parameter

green bluff
#

yea

slate swan
#

oh yes

#

you should have used self, ctx, ..

#

didnt notice it at first sorry

green bluff
#

oh yea

#

i think this should work

slate swan
#

can someone help me with that?

slate swan
#

@neat tartan

cold sonnet
#

your downloads and imports?

slate swan
#

never mind guys

slate swan
cold sonnet
#

I couldn't have helped anyways, I would've tried

slate swan
#

The error was in this:
emb.add_field(name="**Канал:**", value=f"**<#{message.channel.id}>**", inline=False) 

kindred drum
#

and I dont think it will

cold sonnet
#

use

#

message.channel.mention

#

way easier

slate swan
#

How to find out in which channel the user was kicked and find out the channel id?

flat solstice
#

So I have this commandpy @commands.command(description="Clone emojis!", usage = "<emoji>") @commands.has_permissions(manage_emojis=True) @commands.bot_has_permissions(manage_emojis=True) async def clone(self, ctx, emoji: Union[discord.PartialEmoji, discord.Emoji]= None): message = await ctx.reply(f"Cloning please wait... {emoji}['loading']") if isinstance(emoji, discord.PartialEmoji): emo = await ctx.guild.create_custom_emoji(name=emoji.name, image=await emoji.read(), reason=f"{ctx.command.name} command used by {ctx.author} ({ctx.author.id})") await message.edit(content=f"Emoji <:{emo.name}:{emo.id}> was added!") that lets me clone emoji's but I'm getting this errorpy ERROR:cogs.error_handler:AttributeError: 'PartialEmoji' object has no attribute 'read' (In clone) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 476, in clone emo = await ctx.guild.create_custom_emoji(name=emoji.name, image=await emoji.read(), reason=f"{ctx.command.name} command used by {ctx.author} ({ctx.author.id})")how should I go about fixing it?

kindred drum
#

Yo anyone know how to get a channels current permissions

slate swan
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

slate swan
#

umm

#

!d discord.abc.GuildChannel.overwrites

unkempt canyonBOT
#

property overwrites: Dict[Union[Role, Member], PermissionOverwrite]```
Returns all of the channel’s overwrites.

This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
slate swan
#

Find out in which channel the user was kicked

slate swan
unkempt canyonBOT
#

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

Retrieves the content of this asset as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.9)") object.
slate swan
kindred drum
# unkempt canyon

so what would be the syntax to print the overwrites of the current channel

slate swan
#

🤔

slate swan
#

That is, it is impossible to find out in which channel the user was kicked?

kindred drum
slate swan
#

I mean, it is impossible if it makes any sense, but it don't. User is not kicked from any channel

#

Okay

slate swan
#

!d discord.PermissionOverwrite check this out

unkempt canyonBOT
#

class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.

Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.

The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.

x == y Checks if two overwrites are equal.

x != y Checks if two overwrites are not equal.

iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
vale wing
slate swan
#

hi guys

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.

final iron
#

Use this

vale wing
#

What's the difference bro

final iron
#

Pastebin fucks with formatting

vale wing
rancid stump
#

how to read message from discord using python ?

rocky hornet
#

use Hikari

vale wing
#

Depends how you want to read it

final iron
unkempt canyonBOT
vale wing
#

Ok seems like nobody knows how to fix that cring

lament sphinx
#

Can someone make me a very basic discord bot please

vale wing
#

Then it's time to use the power of help channels sillySmile

vale wing
lament sphinx
cold sonnet
vale wing
#

You probably need to search for somebody on freelance platform, this is the wrong place to ask

cold sonnet
#

we're all rule respecting people uuu

lament sphinx
vale wing
#

As for paid work yes

cold sonnet
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

lament sphinx
#

I’m asking for free :>

cold sonnet
#

paid work of 0mone

lament sphinx
#

you can’t pay someone 0

cold sonnet
#

bet

vocal snow
#

Spoonfeeding is generally discouraged here

final iron
vale wing
#

We can only provide you resources to learn how to make one by yourself

cold sonnet
fresh iron
#

help

cold sonnet
#

wth

slate swan
vale wing
#

Help me

cold sonnet
#

my eyes

slate swan
#

ive never seen something more cursed in my life

fresh iron
#

LOL

slate swan
#

what is that font

#

whyyyyyy

vale wing
cold sonnet
#

and it's not even python broo

vale wing
#

We only help with python bots

fresh iron
#

its a meme

#

jesus

slate swan
cold sonnet
vale wing
slate swan
fresh iron
#

i have no clue

slate swan
cold sonnet
slate swan
velvet tinsel
cold sonnet
#

that's my name

vale wing
velvet tinsel
#

also hi okimii ❤️

slate swan
velvet tinsel
velvet tinsel
#

😳

slate swan
cold sonnet
slate swan
vale wing
velvet tinsel
fresh iron
#

its my first year of studying software engineering and i barely know shite about coding

cold sonnet
#

what an L

vale wing
#

Mostly bots have the MIT or don't even have one

velvet tinsel
#

must be hell

wanton veldt
#

hi i have a question . I have a embed with a reaction and when i react i want it to change de embed ( switching pages in help command) thats what i ve got

    @commands.command()
    async def help(self, ctx):
        embed = discord.Embed(title="Commands for this bot!", description="**Prefixul acestui bot este ´.´ **", color=discord.Colour.random())
        embed.set_thumbnail(url="https://media.discordapp.net/attachments/612746705406001213/612990390907305990/avatar.png")
        embed.add_field(name="kick", value="Foloseste .kick pentru a dat kick unui membru.", inline=True)
        embed.add_field(name="ban", value="Foloseste .ban pentru a dat ban unui membru", inline=True)
        embed.add_field(name="unban", value="Foloseste .unban pentru a dat unban unui membru bannat.", inline=True)
        embed.add_field(name="clear", value="Foloseste .clear + suma pentru a sterge mesaje de pe chat.", inline=True)
        embed.add_field(name="mute", value="Foloseste .mute pentru a dat mute unui membru.", inline=True)
        embed.add_field(name="unmute", value="Foloseste .unmute pentru a dat unmute unui membru.", inline=True)
        embed.add_field(name="reload", value="Foloseste .reload pentru a debloca botul.", inline=True)
        embed.add_field(name="ping", value="Foloseste .ping pentru a vedea latency-ul la bot.", inline=True)
        embed.add_field(name="avatar", value="Foloseste .avatar + membru pentru a vedea avatarul unui membru.", inline=True)
        embed.add_field(name="color", value="Foloseste .color pentru a genera o culoare random.", inline=True)
        embed.add_field(name="poll", value="Foloseste .poll pentru a face un sondaj.", inline=True)
        embed.set_footer(text="La Plesneala")
        msg = await ctx.reply(embed=embed)
        await msg.add_reaction(":white_check_mark:")
        
lament sphinx
#

i know its not stealing but it feels like it

velvet tinsel
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

cold sonnet
velvet tinsel
#

ext shit

#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
slate swan
wanton veldt
#

ty

vale wing
velvet tinsel
#

event should be "reaction" if you want to wait for a reaction

#

wtf is my spelling today

lament sphinx
#

right now

velvet tinsel
lament sphinx
#

busy

velvet tinsel
#

you can always find time for coding 😏 10:00pm be like

lament sphinx
#

with other things

vale wing
#

Then wait until you are not busy

velvet tinsel
#

I code from 9-11, go to sleep, wake up at 6:30, code to 7, get ready for school

#

1 hour 10 mins of coding per day except tuesdays and mondays

slate swan
velvet tinsel
#

woohoo

velvet tinsel
#

for a tech fair I'm doing the frontend

#

I gave up so I'm using webflow

wanton veldt
vale wing
#

I don't understand how can you make a nice looking thing

velvet tinsel
slate swan
vale wing
#

No spatial mind or smth

velvet tinsel
# wanton veldt sorry but i dont understand it
@client.event
async def on_message(message):
    if message.content.startswith('$thumb'):
        channel = message.channel
        await channel.send('Send me that 👍 reaction, mate')

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == '👍'

        try:
            reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
        except asyncio.TimeoutError:
            await channel.send('👎')
        else:
            await channel.send('👍')

taken from here https://discordpy.readthedocs.io/en/master/api.html#discord.Client.wait_for

fresh iron
velvet tinsel
#

it's an error handler
you can use lambda for check

velvet tinsel
#

if you just want to check for the reaction

slate swan
velvet tinsel
flat solstice
# slate swan !d discord.PartialEmoji.read If it's 1.7.3, do `emoji.url.read()`

I don't think I understood you correctlypy INFO:cogs.events:POST https://discord.com/api/v7/channels/501004576866959391/messages took 1.7 seconds ERROR:cogs.error_handler:AttributeError: type object 'PartialEmoji' has no attribute 'read' (In clone) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 482, in clone emo = await ctx.guild.create_custom_emoji(name=emoji.name, image=await discord.PartialEmoji.read(), reason=f"{ctx.command.name} command used by {ctx.author} ({ctx.author.id})")I thought you meant I had to put in discord.PartialEmoji.read(), After reading your msg for the 4th time I think you were saying that instaed of emoji.read i needed emoji.url.read?

velvet tinsel
#

my resume's gonna be like

None

xD

fresh iron
velvet tinsel
#

dark humor there pithink

slate swan
velvet tinsel
vale wing
velvet tinsel
vale wing
#

Literally 2 try-excepts and it still eats the error to somewhere

velvet tinsel
#
int string = -1;
        if (letter == letter.A) {
            string = 1;
        } else if (letter == letter.B) {
            string = 2;
        } else if (letter == letter.C) {
            string = 3;
        } else if (letter == letter.D) {
            string = 4;
        } else if (letter == letter.E) {
            string = 5;
        } else if (letter == letter.F) {
            string = 6;
        } else if (letter == letter.G) {
            string = 7;
        } else if (letter == letter.H) {
            string = 8;
        } else if (letter == letter.I) {
            string = 9;
        } else if (letter == letter.J) {
            string = 10;
        } else if (letter == letter.K) {
            string = 11;
        } else if (letter == letter.L) {
            string = 12;
        } else if (letter == letter.M) {
            string = 13;
        } else if (letter == letter.N) {
            string = 14;
        } else if (letter == letter.O) {
            string = 15;
        } else if (letter == letter.P) {
            string = 16;
        } else if (letter == letter.Q) {
            string = 17;

mhm, nice

pliant gulch
velvet tinsel
#

java

pliant gulch
#

oh, theres the problem

#

Pretty sure java still have switch statements though

cold sonnet
#

yeah it does

vale wing
cold sonnet
#

I beg you to stop

pliant gulch
#

APL mixed with enchanting table text

cold sonnet
#

I beg you...

scarlet aurora
#

how do i make it so that if my bot pings someone, it responds with text

vale wing
cold sonnet
scarlet aurora
#
@bot.command()
async def (mention)(ctx):
    await ctx.send("(text)")```
cold sonnet
#

I can already see a stalker mod ruining it

vale wing
#

😳 wut

scarlet aurora
#

i want to make it so that if someone does ! and then mentions someone, it replies with something

vale wing
#

Just use on_message event

scarlet aurora
#

how do i do that

vale wing
#

!d discord.on_message

unkempt canyonBOT
#

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

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/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/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
scarlet aurora
#

how do i make it so that message is a mention

vale wing
#

!d discord.Message.mentions

unkempt canyonBOT
#

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

Warning

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

slate swan
limber plume
#

Hello. In my bot I have on_message event and when I type command, the on_message event triggers, how can I stop that?
Code:

`@bot.event
async def on_message(message):
if message.author.id == bot.user.id:
return

if message.channel.id == 927347556860702793:
    await message.channel.send('Send')
else:
    await message.channel.send("Wrong channel")
    
await bot.process_commands(message)`

I want to make **on_message ** to ignore @bot.command events.

vale wing
#

I forgot the enchantment minecraft command sorry 😦

vale wing
#

Also it's better to use a listener to get rid of process_commands

fresh iron
vale wing
#

When the database has random UNIQUE constraint

limber plume
echo wasp
#

and i did define self

vale wing
#

You put it into a decorator lol

slate swan
#

its probably not in the class

pliant gulch
slate swan
#

hi andy

vale wing
#

It should be the first arg of the method

echo wasp
wanton veldt
#

hi i have this code and this error any help

    page1 = discord.Embed(title="Bot Help 1", description="Use the buttons below to navigate between help pages.", colour=discord.Colour.orange())
    page2 = discord.Embed(title="Bot Help 2", description="Page 2", colour=discord.Colour.orange())
    page3 = discord.Embed(title="Bot Help 3", description="Page 3", colour=discord.Colour.orange())

    client.help_pages = [page1, page2, page3]


    @commands.command()
    async def help(self, ctx):
        buttons = [u"\u23EA", u"\u2B05", u"\u27A1", u"\u23E9"] # skip to start, left, right, skip to end
        current = 0
        msg = await ctx.send(embed=client.help_pages[current])
    
        for button in buttons:
            await msg.add_reaction(button)
        
        while True:
            try:
                reaction, user = await client.wait_for("reaction_add", check=lambda reaction, user: user == ctx.author and reaction.emoji in buttons, timeout=60.0)

            except asyncio.TimeoutError:
                return print("test")

            else:
                previous_page = current
                if reaction.emoji == u"\u23EA":
                    current = 0
                
                elif reaction.emoji == u"\u2B05":
                    if current > 0:
                        current -= 1
                    
                elif reaction.emoji == u"\u27A1":
                    if current < len(client.help_pages)-1:
                        current += 1

                elif reaction.emoji == u"\u23E9":
                    current = len(client.help_pages)-1

                for button in buttons:
                    await msg.remove_reaction(button, ctx.author)

                if current != previous_page:
                    await msg.edit(embed=client.help_pages[current])
    
``` error
rocky trench
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'slashes' object has no attribute 'song_queue', I'm exporting to / commands, this code works for normal prefix, but not for slash. https://mystb.in/SkiingAgeDublin.python

rocky trench
#

yh that too

wanton veldt
velvet tinsel
velvet tinsel
rocky trench
#

self? @commands.command()?

wanton veldt
#

i tried with another name too and dosent work

velvet tinsel
rocky trench
#

nvm just a class

limber plume
#

I have a question. Will the bot handle on_message event if there's about 100 messages/min ?

velvet tinsel
#

iirc

rocky trench
wanton veldt
limber plume
#

Thanks!

rocky trench
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'slashes' object has no attribute 'song_queue', I'm exporting to / commands, this code works for normal prefix, but not for slash. https://mystb.in/SkiingAgeDublin.python

wanton veldt
#

so do you guys know or i just drop it

velvet tinsel
#

instead of client.remove_command() try doing help_command=None in your commands.Bot()

#

!d discord.ext.commands.Bot || theres a help_command kwarg

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

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

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

how do I get the permissions of a channel from a channel

wanton veldt
#

client = commands.Bot(command_prefix=".", intents=intents, help_command=None)

vale wing
unkempt canyonBOT
#

property overwrites: Dict[Union[Role, Member], PermissionOverwrite]```
Returns all of the channel’s overwrites.

This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
wanton veldt
#

like that?

kindred drum
vale wing
kindred drum
#

I can't figure it out

vale wing
#

If you are fetching it with a command, just ctx.channel.overwrites

wanton veldt
#

still the same error

kindred drum
#

oh

wanton veldt
#

ok duck it

kindred drum
#

thats so easythank you bro

velvet tinsel
echo wasp
#

hmm i got another error on another command

rocky trench
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'voice_client', I dont even use this in the command it gives erorr

vale wing
velvet tinsel
velvet tinsel
echo wasp
rocky trench
#

Error occured in command play
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'voice_client'

velvet tinsel
#

no

rocky trench
velvet tinsel
#

it should have something more

rocky trench
velvet tinsel
#

well, I guess

rocky trench
#

I'm experienced in py

vale wing
rocky trench
#

so I sure know how to send an error

kindred drum
#

for x in overwrites:
something

vale wing
velvet tinsel
#

weird, does it not send the line of the error?

rocky trench
#

well how do I get the traceback

velvet tinsel
#

like line 88?

rocky trench
vale wing
velvet tinsel
kindred drum
#

right

rocky trench
velvet tinsel
rocky trench
#

I see

velvet tinsel
#

it doesnt work for dpy though

#

only works for regular errors

vale wing
#

@rocky trench in the latest versions of many dpy forks the ctx.voice_client was removed and there's no alternative to it

rocky trench
vale wing
#

And the guild.voice_client has a wrong type

final iron
rocky trench
#

and it works for my other non slash commands

velvet tinsel
vale wing
#

Pretty sure it is VoiceProtocol and you need VoiceClient

velvet tinsel
#

it depends on what error it is

#

Idk which error it should throw so I'm shooting blind

vale wing
#

!d discord.Guild.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
vale wing
#

Yeah bad

#

Dunno why they set it to this

rocky trench
#

oof

vale wing
#

I mean it's useless why not the VoiceClient

rocky trench
#

got an example?

#

if ctx.VoiceClient?

vale wing
#

You could do the same ig

#

Maybe there's a better method, but I don't know one and nobody could suggest me one when I asked

rocky trench
#
    @slash_util.slash_command(description = 'Joins the voice channel')
    async def join(self, ctx):
        if ctx.author.voice is None:
            return await ctx.send("You are not connected to a voice channel, please connect to the channel you want the bot to join.")
        if ctx.guild.voice_client:
            return await ctx.send("I am already connected to a voicechannel.")
        await ctx.author.voice.channel.connect()
        await ctx.guild.change_voice_state(channel = ctx.author.voice.channel,self_deaf=True)
        await ctx.send('I joined the voice channel!', ephemeral = True)```
#

why did this work tho?

#

the if ctx.guild.voice_client:

vale wing
#

Later in code you tried to access is_playing, in this code you are not accessing any attributes of the protocol

#

The ctx.guild.voice_client itself is valid, but ctx.guild.voice_client.is_playing() is not, as VoiceProtocol instances don't have that method

rocky trench
#

ah I see

vale wing
# kindred drum list.to_dict()

Not really

overwrites = ctx.channel.overwrites.copy() # copy may be unnecessary
overwrites[ctx.guild.default_role] =  discord.PermissionOverwrite(send_messages=False)
await ctx.channel.edit(overwrites=overwrites)```
A quick example that would change the permission for everyone role to send messages in the channel the command was used in

Note that this will **overwrite** the permission for a certain role and not modify it
tulip frigate
#

So I know this is a very weird question, but, I have this ticket bot, and I want to return on the reaction when the payload.user_id is the ones of the bots, which I do like this:

if payload.user_id == 930853710811246602:
    return```
Although, for some reason, this only keeps working on some servers, which I do not know why. Anyone knows solution to the issue?
vale wing
#

Although I don't remember correctly the param of edit lemme check it rq

#

Nvm it's fine

vale wing
#
if bot.get_user(payload.user_id).bot:
    return```
#

Recommended to fetch user if the bot is on large amount of guilds

gusty hatch
#

why do i keep getting "This Interaction failed" from my dropdown

manic wing
#

jolly good question sir

neat tartan
#

What would be the best way to grab the message history of a user in a server? ctx.author.history() doesnt seem to pull it.

sick birch
#

though it could take a while and be intensive

velvet tinsel
neat tartan
manic wing
#

you would have to loop through each channel and get every message

sick birch
#

You probably thought that would get all the user's messages

#

Unfortunately it gets the dms messages

neat tartan
#

Ya

sick birch
#

To get all the messages from a user, you'd have to loop through every single channel, get every single message in all of those channels, and filter them so it's only from the users. It would be very time costly and intensive on the mission

neat tartan
#

Aight

pliant gulch
#

There is just no good way to get a specific users entire message history

#

I'm sure the endpoint is heavily ratelimited, and it would be 100 messages per API call or under 100 messages for 1

neat tartan
#

Ok, next question. We can work with just pulling from 1 channel but we want to pull all the channel ids from the server to randomly select or not select from a specific channel

#

For overall project context it takes 2 random messages from a persons history and splices them together. Currently based on the channel the command is sent in but causes issues when something like a bot spam channel is only full of bot commands and not actual messages

serene mantle
#

Hey guys, im migrating from Discord.PY, to Disnake atm. Everything is working well but for some reason, i can't pull the users profile pictures.

#
          embed.set_thumbnail(url=member.avatar_url)```
manic wing
serene mantle
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'

#

async def info(self, ctx, member: disnake.Member):

#

member is indeed passed

neat tartan
serene mantle
#

i relaunched.

#

still nothing

manic wing
#

-_-

neat tartan
#

It’s picking it up as “avatar_url” still which means it was not changed

serene mantle
#

lol

#

i had a print statement didn't see.

#

Thank you guys 🙂

#

lol

#

im back

#

in another place im now getting

    eme.set_author(name=str(member), icon_url=member.avatar.url)
AttributeError: 'NoneType' object has no attribute 'url'```
#

eme.set_author(name=str(member), icon_url=member.avatar.url)

flat solstice
#

So I'm getting this errorpy ExtensionFailed - Extension 'cogs.info' raised an error: TypeError: Aliases of a command must be a list or a tuple of strings.but I can't see where it's coming from https://sourceb.in/vxMjyepBli

slim ibex
#

Aliases are a list not a tiple

#

tuple*

rocky trench
#

Aliases = [" "]

flat solstice
slim ibex
#

It’s the first command group decorator

flat solstice
#

Facepalm thanks

slim ibex
#

And why are you adding extra commas after the last argument in the decorator

flat solstice
#

shrug it's just my weird style of coding

rocky trench
#

Just don't

neat tartan
#

I feel like that will eventually cause an issue for you down the road

rocky trench
#

^^

rocky trench
#

If no, member.avatar_url

neat tartan
serene mantle
rocky trench
#

Oh

serene mantle
#

in the documentation there is no mention

#

of member.avatar.url

#

only avatar_url which is odd, because i had the same issue somewhere else

#

and doing .url fixed it

rocky trench
#

Also name = str(member) is unneeded. Just use name = member

flat solstice
serene mantle
rocky trench
pliant gulch
serene mantle
serene mantle
pliant gulch
#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
pliant gulch
#

Wdym? It does

slate swan
#
Ignoring exception in on_guild_join
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\client.py", line 415, in _run_event
    await coro(*args, **kwargs)
TypeError: on_guild_join() takes 1 positional argument but 2 were given
#

i have only one argument ```py
@commands.Cog.listener()
async def on_guild_join(guild):

serene mantle
rocky trench
#

It seems like it's just member.avatar

serene mantle
#

as the first argument

slate swan
serene mantle
#

when using cogs

#

you always pass self first

slate swan
#

forgot

rocky trench
#

Polar

serene mantle
#

yes

rocky trench
#

member.avatar or member_avatar or member.display_avatar

flat solstice
# slim ibex should be able to

So I tried ```py
@commands.group(name = "user", aliases = ["member"], invoke_without_command = True, case_insensitive = True,)
async def user_group(self, ctx):
await ctx.reply("You used {ctx.command.name}")
await ctx.reply("{ctx.group.name} has {len(ctx.group.commands)}")

@user_group.guild_only()
@user_group.has_permissions(manage_guild = True)
@user_group.command(description = "Show a member's permission in a channel when specified.", usage = "[member] [channel]", aliases = ["perms"])
async def permissions(self, ctx, member: discord.Member = None, channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.CategoryChannel] = None):```and got ```py

ExtensionFailed - Extension 'cogs.info' raised an error: AttributeError: 'Group' object has no attribute 'guild_only'```so do I put @commands.guild_only() decorator on the sub command instead

lament sphinx
#

hello monkey

slim ibex
#

ahh ok

slim ibex
#

Seems like put it on the group then

rocky trench
#

I don't know how disnake works, just checking docs

lament sphinx
#

mr tumble at it again

serene mantle
#

wtf

#

i got some bs now

#
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.author.icon_url: Scheme "none" is not supported. Scheme must be one of ('http', 'https').```
rocky trench
#

Ah yes

#

If the user doesn't have an avatar (basic one) it returns None

#

Use display_avatar instead

serene mantle
#

wait

#

are you trying to say, i can technically use that to check if the users pfp is default?

rocky trench
#

Display avatar is for example serverprofile avatar, or the one that's set

#

For me it would return the monkey thing

serene mantle
#

ah

rocky trench
#

If server avatar is set, it will return the server avatar

serene mantle
#

it worked 🙂

#

thank you once again guys.

rocky trench
#

GG!

#

That's the reason we're here :D

serene mantle
#

🙂

slim ibex
#

@rocky trench seems like you are learning your stuff 👀

rocky trench
slim ibex
#

mhmm

rocky trench
#

I didn't recognize you at first

slim ibex
#

yeah have a diff name here

pliant gulch
slim ibex
#

Andy 🗿

pliant gulch
#

🗿

#

I've rewritten Rin's slash commands implementation like 4 times already and I have no clue what design choice is best

slim ibex
#

lol

pliant gulch
#

😔 this is gonna be even more painful when I have to do voice

serene mantle
#

just converted from dpy to disnake

#

anyone whos looking to do it

#

just do it 🐱

rocky trench
#

I went from dpy to slash_utils

neat tartan
#

Ignore any potential formatting errors what is the correct way of listing this
I dont have an exact error message cause im asking on anothers behalf but channels is not picking up or doesnt exist within it

rocky trench
#

Which is pretty much the same

neat tartan
#

I need to probably transfer at some point but ive been holding off

rocky trench
neat tartan
#

Think we tried that and it still had an issue but ill try it

rocky trench
#

It works for me

#

¯_(ツ)_/¯

neat tartan
rocky trench
#

👍

neat tartan
#

It was the first one we initially tried and didnt work. Might have had some sort of syntax error when we first were figuring it out. Thank you

rocky trench
#

Ah I think for channel in guild.channels includes voice channels tho

neat tartan
#

It looked like the docs said it returns textchannels

rocky trench
#

For channel in guild.text_channels

#

This will be text channels

neat tartan
#

Ah ok. The notation of all of this has been super fucky

rocky trench
#

Yeah...

#

@neat tartan u can easily find this stuff in docs

neat tartan
#

The docs have been my bible for the past little bit. I was careful to try and follow it correctly but something was still going wrong so i asked in here. Its always stupid little things like that that get me

rocky trench
#

When you start helping, and you encounter a problem you won't forget it

neat tartan
#

Ya, ive been trying to help here where i canwhile ive been learning and it helps

weary mirage
#

hey so what's going on with discord py? I saw something saying that it's not going to be maintained anymore in February of 2022...?

serene mantle
#

discord being annoying

weary mirage
#

so what's that mean, what's wrong

slate swan
#

how can i use api link to post its result in embed

serene mantle
#

long story short, discord wants to re do the entire basis of how discord bots are made

#

dpy dev said, nah

rocky trench
#

Oof

serene mantle
#

and stopped

weary mirage
#

... whatttt

serene mantle
#

yeah

neat tartan
weary mirage
#

you are kidding meeeeeee

flat solstice
#

So I'm trying to get my bot to send a list of the commands inside of a group but I can't seem to get right. py AttributeError: 'NoneType' object has no attribute 'commands'with thispy group_commands = [] for command in ctx.command.parent.commands(): group_commands.append(command) #await ctx.reply(f"You used {ctx.command.name}") #await ctx.reply(f"{ctx.command.group} has {len(ctx.command.group.commands)}") await ctx.reply(" ".join(group_commands))but I tried a different variation on the if statement and got this errorpy ERROR:cogs.error_handler:AttributeError: 'Context' object has no attribute 'group' (In emoji) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 160, in emoji_group await self.ungroup(ctx) File "/home/modmail/cogs/info.py", line 23, in ungroup for command in ctx.group.commands:

serene mantle
#

this is only for verified bots tho

rocky trench
#

We have to use extern library's now

serene mantle
#

so if youre only developing for yourself, its okay

bold surge
#

4 of the biggest python discord bot libs got hit with 1k+ member raids :I

weary mirage
#

wait so, why is it only for verified bots?

serene mantle
#

privacy reasons

rocky trench
#

What only for verified bots?

serene mantle
#

the slash command

bold surge
#

message intent

serene mantle
#

what he said ^

weary mirage
#

Will they eventually get to the point where they'll end support for the now old-school discord bots?

serene mantle
#

well you cant just end support

bold surge
#

if your bots not verified and you dont plan on verifying it then you should be fine

serene mantle
#

like the api endpoints will exist, now with dpy you dont get to access to new endpoints

weary mirage
#

ugh

serene mantle
#

like i just finished converting from dpy to disnake

#

almost the exact same syntax

#

everything is almost the same

bold surge
#

if you do plan on verifying it, then i suggest switching over to slash commands or apply for the intent

serene mantle
#

but it is modern

rocky trench
#

I'm planning on verifying mine

weary mirage
#

this is going to be a giant fucking pain, considering I'm well through developing a bot for a friend

serene mantle
#

well this only applys to you if the bot is going to be in 75+ servers

#

soo, if its just for your friend, youre fine

weary mirage
#

ah oke

#

ty

serene mantle
#

np

#

take care

weary mirage
#

you too C:

waxen python
#

Does anyone know if its possible that a message isnt being passed to on_message because its not found as a command for the bot?

final iron
#

Is on_error in another file?

serene mantle
rocky trench
#

Didn't even fully release yet

rocky trench
serene mantle
#

ahh

final iron
#

Did you import it?

serene mantle
#

okay haha, what does your bot do ?

#

anyone work with the disnake Discord User Public flags

pliant gulch
final iron
#

I can't tell where its erroring

waxen python
pliant gulch
#

This as of now speaking are unprivileged intents though ^

neat tartan
#

we dont have code line numbers

waxen python
#

Alright, that doesnt seem to be the issue then

final iron
#

It's not

#

This is what you have:

            await on_error(
                ctx,
                "Invalid Option Specified",
                f"Option {val1} needs to be one of {sconf(ctx.guild.id).colors.keys()}.",
                ["!conf colors", f"!conf colors {sconf(ctx.guild.id).colors.keys()[0]} 0xe67e22"])
#

This is what the error is showing:

    await on_error(ctx, "error")
#

Unless I'm being really dumb

waxen python
pliant gulch
waxen python
#

yes

pliant gulch
#

Do you have some implementation for on_message anywhere other than the default implementation provided by the wrapper?

waxen python
#

What would an example of that be, sorry?

pliant gulch
#

Do you have an on_message event anywhere you coded, not the one provided by the wrapper by default

#

I was not replying to you

serene mantle
#

burn 🔥

waxen python
serene mantle
#

🤣

pliant gulch
waxen python
#

Oh sorry, yes I have multiple

#
    @commands.Cog.listener()
    async def on_message(self, message):
        print(message)

For normal messages, it gets the message info.
For messages beginning with ! (prefix), it doesnt

pliant gulch
#

Is this the only one?

waxen python
#

Nope. However, I think i just fixed it

#

I added an error handler for commands not found (this is like a dev bot), and it worked (passing on error for command not found)

pliant gulch
#

Odd, regardless of the error handler it should have dispatched a MESSAGE_CREATE event regardless if the message started with the prefix

waxen python
#

Either that or i was trippin before...

#

thank you, anyways :D

modest plover
#

How do I get this?

#

It isn't on my bot

flat solstice
#
async def ungroup(self, ctx):
        group_commands = []
        for command in ctx.command.parent.commands():
            group_commands.append(command)
        #await ctx.reply(f"{ctx.command.group} has {len(ctx.command.group.commands)}")
        await ctx.reply(embed = discord.Embed(title = "Commands in `{ctx.command.name}`", description = "`{}`, ".join(group_commands)))```I think something's up with my for statement here since I'm getting `AttributeError: 'NoneType' object has no attribute 'commands'`, what I want this statement to do is go through each subcommand inside a command and add that command to a list which i then format into my embeds description, the bit I'm stuck on is how to retrieve the context commands sub commands
neat tartan
modest plover
#

I mean the huge add to server button

neat tartan
#

Oh, all public bots have that by default

pliant gulch
neat tartan
#

It would be toggled in the discord dev portal

pliant gulch
#

Otherwise parent would be None

dire folio
flat solstice
#

really it ought to be no_group

pliant gulch
#

Thus, of course as to be expected it has no parent, it is the parent

#

Since it's a group, you'd go through the groups commands attribute

#

there would be all the subcommands

modest plover
modest plover
neat tartan
#

O.o

flat solstice
# pliant gulch Your `ctx` here is under `user_group`, which in-itself is a Group

so more like for command in ctx.group.commands(): bc that spits outpy ERROR:cogs.error_handler:AttributeError: 'Context' object has no attribute 'group' (In channel) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 112, in channel_group await self.ungroup(ctx) File "/home/modmail/cogs/info.py", line 23, in ungroup for command in ctx.group.commands():

pliant gulch
#

It's also not callable as it's a set of commands

#

So don't call it

flat solstice
#

woo, it works. only isses is its put the around the comma, how do I make it wrap it around the command(s) insteadpy description = "`, `".join(group_commands))

neat tartan
#

Im pretty sure it would require an f string with backticks before and after everything else so that it essentially inverses whats there

flat solstice
# neat tartan Im pretty sure it would require an f string with backticks before and after ever...

Well this failedpy ERROR:cogs.error_handler:TypeError: join() takes no keyword arguments (In channel) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 112, in channel_group await self.ungroup(ctx) File "/home/modmail/cogs/info.py", line 26, in ungroup await ctx.reply(embed = discord.Embed(title = f"Commands in `{ctx.command.name}`", description = "`{command}`, ".join(command = group_commands)))

neat tartan
neat tartan
#

Title was fine before

flat solstice
#

yeah title's fine, it's the join on the description that;s the pain

neat tartan
#

Description is where the issue was, i think it should be

description = f"`{", ".join(group_commands)}`"
neat tartan
flat solstice
#

nvm i got around it by doing py for command in ctx.command.commands: command_string = f"`{ctx.prefix + command.name}`" group_commands.append(command_string)which puts around each command, it's probs not the best way to do it but it gets the right end result

neat tartan
#

Same dif

flat solstice
#

for some reason this command```py
@user_group.command(description = "Show some information about yourself or the member specified.", usage = "[member]", aliases = ["whois", "ui"])
async def info(self, ctx, *, member: discord.Member = None):
member = ctx.author if member is None else member
roles = [f"<@&{role}>" for role in member._roles]
key_perms = ["administrator", "manage_guild", "manage_roles", "manage_channels", "manage_messages", "manage_webhooks", "manage_nicknames", "manage_emojis", "kick_members", "mention_everyone"]
has_key = [perm for perm in key_perms if getattr(member.guild_permissions, perm)]
if len(has_key) == 0:
has_key.append('No permissions')
member_status = "No status" if member.activity is None else member.activity.name
if len(roles) == 0:
roles.append("No roles")

    embed = discord.Embed(title = f"{member.name}#{member.discriminator}", description = f"Status: **{member.status}**\n*{member_status}*", colour = member.colour)
    embed.set_author(name = f"{member.id}", icon_url = member.avatar_url)
    embed.set_thumbnail(url = member.avatar_url)
    embed.add_field(name = "Joined Server:", value = f"<t:{int(member.joined_at.timestamp())}:R>", inline = True)
    embed.add_field(name = "Avatar", value = f"[PNG]({member.avatar_url_as(static_format='png')})", inline = True)
    embed.add_field(name = "Joined Discord:", value = f"<t:{int(member.created_at.timestamp())}:R>", inline = True) 
    embed.add_field(name = f"Roles: {len(roles)}",value = f"{len(roles)} roles" if len(" ".join(roles)) > 1000 else " ".join(roles), inline = False)
    embed.add_field(name =f'Key permissions', value = ", ".join(has_key).replace("_"," ").title(), inline = False)
    await ctx.reply(embed = embed)```keeps giving me this error```py

ERROR:cogs.error_handler:AttributeError: 'str' object has no attribute 'author' (In info)
Traceback:
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/modmail/cogs/info.py", line 48, in info
member = ctx.author if member is None else memberwhich I find odd bcpy
@user_group.command(description = "Show a users avatar.", usage = "[member]", aliases = ["av"])
async def avatar(self, ctx, *, member: discord.Member = None):
member = ctx.author if member is None else member
embed = discord.Embed(title = f"{member.name}#{member.discriminator}'s Avatar", colour = member.colour)
embed.add_field(name = "PNG", value = f"Link", inline = True)
embed.add_field(name = "JPG", value = f"Link", inline = True)
embed.add_field(name = "WebP", value = f"Link", inline = True)
embed.set_image(url = member.avatar_url)
await ctx.reply(embed = embed)```works without issues

neat tartan
#

Took me a moment to realize those are 2 seperate sets of code

slim ibex
#

same LMFAO

flat solstice
#

lol

neat tartan
#

I hate debugging on mobile so much

flat solstice
#

ik

neat tartan
#

Can i get those codes in screenshot format?

flat solstice
#

this the 'second' command, the one that works

neat tartan
#

Ok, and the one that doesnt?

flat solstice
#

had to do it in 2 parts

neat tartan
#

Aightthats fine. Gimme a moment to read through it

flat solstice
#

👍

neat tartan
#

Why does discord.member have to be none?

timid wagon
#

In case the member is not specified

flat solstice
#

bc if member is not given i want it to send the info for author

timid wagon
#

Also, @flat solstice you're expecting the user to only send the user, correct?

neat tartan
#

Ahh

timid wagon
#

It's a good idea to remove the * in that case

timid wagon
#

Next, you get the member's roles via member.roles, not member._roles

flat solstice
#

well both was working for me

timid wagon
#

Plus, doing "<@&{role}>" is incorrect - you're putting the discord.Role object into the string, not the role ID which is received via {role.id}

slim ibex
#

!pep3102 talks about the use of *, arg @flat solstice

unkempt canyonBOT
#

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

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

timid wagon
slim ibex
#

!pep 3102

unkempt canyonBOT
#
**PEP 3102 - Keyword-Only Arguments**
Status

Final

Python-Version

3.0

Created

22-Apr-2006

Type

Standards Track

fickle bloom
#

trying to time a user out,

In communication_disabled_until: Invalid communication disabled timestamp
    ryan = guild.get_member(ryanId)
    await ryan.timeout(duration=99999999, reason="timeout test")
#

any reason this isn't working?

slim ibex
#

are you trying to use the new timeouit feature?

#

and if so, what lib is this in

fickle bloom
#

disnake

timid wagon
#

Try printing ryan, to see if it's getting the user?

slim ibex
#

!d disnake.Member.timeout

unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
pliant gulch
#

You can't even timeout a user for 99999999 seconds, the API only supports 28 days max

fickle bloom
#

and removed two 9s

#

user was found

#

my timeout command to remove a timeout works

pliant gulch
#

Oh yea, this is totally the max allowed

fickle bloom
#

await user.timeout(duration=None)

#

this works

#

user = guild.get_member(nicholasAlt2)

timid wagon
fickle bloom
#

Yea, and it's working fine

#

but setting a timeout the same way doesn't

timid wagon
#

The error you received is clear - the duration you've specified is longer than 28 days

fickle bloom
#

ah I see

pliant gulch
#

Way over 28 days 👀

fickle bloom
#

uhm, is it in minutes?

timid wagon
#

As andy mentioned mmlol

sick birch
#

5 years infact

pliant gulch
#

It's in seconds

timid wagon
#

You could also specify a datetime object, under until

#

But yeah, you're currently trying to mute the user for half a decade

pliant gulch
#

Yea, if you want a max mute you'd do timedelta + datetime.now()

#

timdelta(days=28) + datetime.now() etc

#

Easier then calculating the seconds

flat solstice
# timid wagon Yeah it shouldn't matter, but sticking to the method the docs mention will be be...

okay so I made those changes but it still doesn't seem to be workingpy ERROR:cogs.error_handler:AttributeError: 'str' object has no attribute 'author' (In info) Traceback: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/modmail/cogs/info.py", line 48, in info member = ctx.author if member is None else memberso i think something's either wrong with the type hint or something else

dire dove
#

Is it possible to do something like this using hikari?

@client.event
async def on_message(message):
    if cond == True:
        await client.process_commands(message)

    else:
        return
bitter perch
flat solstice
# bitter perch you probably reassigned context somewhere to a string.

well it's only happening in this command```py
@user_group.command(description = "Show some information about yourself or the member specified.", usage = "[member]", aliases = ["whois", "ui"])
async def info(self, ctx, member: discord.Member = None):
member = ctx.author if member is None else member
roles = [f"<@&{role.id}>" for role in member.roles]
key_perms = ["administrator", "manage_guild", "manage_roles", "manage_channels", "manage_messages", "manage_webhooks", "manage_nicknames", "manage_emojis", "kick_members", "mention_everyone"]
has_key = [perm for perm in key_perms if getattr(member.guild_permissions, perm)]
if len(has_key) == 0:
has_key.append('No permissions')
member_status = "No status" if member.activity is None else member.activity.name
if len(roles) == 0:
roles.append("No roles")

    embed = discord.Embed(title = f"{member.name}#{member.discriminator}", description = f"Status: **{member.status}**\n*{member_status}*", colour = member.colour)
    embed.set_author(name = f"{member.id}", icon_url = member.avatar_url)
    embed.set_thumbnail(url = member.avatar_url)
    embed.add_field(name = "Joined Server:", value = f"<t:{int(member.joined_at.timestamp())}:R>", inline = True)
    embed.add_field(name = "Avatar", value = f"[PNG]({member.avatar_url_as(static_format='png')})", inline = True)
    embed.add_field(name = "Joined Discord:", value = f"<t:{int(member.created_at.timestamp())}:R>", inline = True) 
    embed.add_field(name = f"Roles: {len(roles)}",value = f"{len(roles)} roles" if len(" ".join(roles)) > 1000 else " ".join(roles), inline = False)
    embed.add_field(name =f'Key permissions', value = ", ".join(has_key).replace("_"," ").title(), inline = False)
    await ctx.reply(embed = embed)```and there;s other commands which use the same decorators and inputs which work without errors, this for example```py

@user_group.command(description = "Show when yourself or the member specified joined the {ctx.guild.name} and Discord.", usage = "[member]", aliases = ["dates", "created", "j"])
async def joined(self, ctx, member: discord.Member = None):
member = ctx.author if member is None else member
embed = discord.Embed(title = f"{member}", colour = member.colour)
embed.set_author(name = f"{member.id}", icon_url = member.avatar_url)
embed.set_thumbnail(url = member.avatar_url)
embed.add_field(name = "Joined Server:", value = f"<t:{int(member.joined_at.timestamp())}:R>", inline = True)
embed.add_field(name = "Joined Discord:", value = f"<t:{int(member.created_at.timestamp())}:R>", inline = True)
await ctx.reply(embed = embed)```

timid wagon
#

Is this in a cog or not?

flat solstice
timid wagon
#

Then ctx should work thonk

flat solstice
#

yeah that's what I was thinking

#

the weird thing is I have exactly the same code in slash command and it's working fine

ruby valve
#
    @commands.command()
    async def register(self, ctx):  

      register_questions = ['What is your Epic Games username?', 'What platform do you play on?', 'What input do you play on?', 'What region do you play on?']
      register_answers = []
      EpicUser = str(register_answers[0])
      Platform = str(register_answers[1])
      Input = str(register_answers[2])
      Region = str(register_answers[3])

  # Checking to be sure the author is the one who answered and in which channel
      def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

  # Asks the questions from the register_questions list 1 by 1
  # Times out if the user doesn't answer within 30 seconds
      for question in register_questions:
          await ctx.send(question)
          try:
              message = await self.client.wait_for('message', timeout= 30.0, check = check)
          except asyncio.TimeoutError:
              await ctx.send('You didn\'t answer in time.  Please try again and be sure to send your answer within 30 seconds of the question.')
              return
          else:
              register_answers.append(message.content)
              with open("users.json", "w") as file:
                json.dump(EpicUser, Platform, Input, Region, file)```
Everything works as intended (not done) but i get the error `EpicUser = str(register_answers[0]) IndexError: list index out of range` can someone help me fix this? I've tried a few things but nothing seems to work.
#

pretty new to discordpy and python in general

neat tartan
#

Register_answers is empty. There is nothing in the first spot

#

If you print register_answers to the console it will likely be an empty list which means whatver is supposed to be in it isnt getting into it

ruby valve
#

okay thank you

neat tartan
#

@sick birch do you know much about migrating to slash commands? Or know of any sources to help?

pallid mango
#

No dependencies to install or update /home/runner/SALRP/venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

#

what does this mean

neat tartan
#

What were you trying to do?

pallid mango
#

how do i put spaces in an embed?

#

like this

maiden fable
#

That's a new line

#

\n will do the trick

pallid mango
#

okay

#

thank you

#

how do i put space between press f8 and OR

maiden fable
#

That's \n bru

pallid mango
#

wat

#

i dont think its supposed to look like this? so how do i put an extra blank line

unkempt canyonBOT
#

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

001 | Hello
002 | World
pallid mango
#

okay, thats very helpful. but how do i put a space on line 002 and "world" on line 003

slate swan
#

you dont thats the output

pallid mango
#

bruh

slate swan
#

\n creates a new line

unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

001 | Hello
002 | 
003 | World
pallid mango
slate swan
#

gotta be specificpithink

#

just say "how do i add 2 new lines"

ruby valve
#
    @commands.command()
    async def register(self, ctx):  

      register_questions = ['What is your Epic Games username?', 'What platform do you play on?', 'What input do you play on?', 'What region do you play on?']
      register_answers = []
      EpicUser = str(register_answers[0])
      Platform = str(register_answers[1])
      Input = str(register_answers[2])
      Region = str(register_answers[3])

  # Checking to be sure the author is the one who answered and in which channel
      def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

  # Asks the questions from the register_questions list 1 by 1
  # Times out if the user doesn't answer within 30 seconds
      for question in register_questions:
          await ctx.send(question)
          try:
              message = await self.client.wait_for('message', timeout= 30.0, check = check)
          except asyncio.TimeoutError:
              await ctx.send('You didn\'t answer in time.  Please try again and be sure to send your answer within 30 seconds of the question.')
              return
          else:
              register_answers.append(message.content)
              with open("users.json", "w") as file:
                json.dump(EpicUser, Platform, Input, Region, file)```
Everything works as intended (not done) but i get the error `EpicUser = str(register_answers[0]) IndexError: list index out of range` can someone help me log the register answers properly. I've tried a few things but nothing seems to work. Im pretty new to python so dont be to harsh on me please.
pallid mango
#

wouldnt this be considered databases?

sick birch
slate swan
#

hes just storing stuff in a json file

#

and json isnt for storing data

#

a database is for storing data tho

sick birch
#

JSON is a serialization format, not for storing data yes ^

slate swan
#

i.e making a request to an api most apis format the data or response body in json

pliant gulch
#

Slash commands are so painful 😔

slate swan
pliant gulch
#

Not even using them, just trying to figure out the cleanest way to create a frontend for them

sick birch
#

Indeed, many APIs are built with javascript and obviously, javascript makes it easy to work with javascript object notation.

pliant gulch
slate swan
pliant gulch
#

I will start the 5th iteration of slash commands for Rin soon

slate swan
#

pain

pliant gulch
#

I have no clue what to do

#

By now If I found something I liked I could've been done already

#

😔

slate swan
#

bozo

neat tartan
pallid mango
#

guys, why is my error code eating my console error?

#
#  @purge.error
#  async def purge_error(self, ctx, error):
#    if isinstance(error, commands.MissingPermissions):
#      await ctx.send('**:x: | You do not have permission to use this command!**')```
sick birch
#

If the error isn't an instance of commands.MissingPermissions, it's simply ignored

#

Add an else statement, that way you can handle all other errors

slate swan
#

and why is everything a commentyert

pallid mango
#

idk

pallid mango
sick birch
#

How you would normally add an if statement

pallid mango
#

idk

sick birch
#
if(...):
  # if block
else:
  # the else statement
pallid mango
#

yes but like what would i have it do

#

like sure else:

sick birch
#

Just print out the error

pallid mango
#

idk how

sick birch
#

So it doesn't get eaten

pallid mango
#

like what the command lol

#

or "code"

pallid mango
#

i know

#

but what would i have it print?

#

💀

slate swan
#
else:
    await ctx.send(error)

for any other errors it will send them

sick birch
#

Hmm I don't like that one

#

It doesn't print the traceback

#

error.__traceback__ does iirc

sage otter
#

With formatting yea.

#

use traceback lib.
traceback.format_exception()

ruby valve
#
    @commands.command()
    async def register(self, ctx):  

      register_questions = ['What is your Epic Games username?', 'What platform do you play on?', 'What input do you play on?', 'What region do you play on?']
      register_answers = []

  # Checking to be sure the author is the one who answered and in which channel
      def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

  # Asks the questions from the register_questions list 1 by 1
  # Times out if the user doesn't answer within 30 seconds
      for question in register_questions:
          await ctx.send(question)  

          user = {
          'EpicUser' : str(register_answers[0]),
          'Platform' : str(register_answers[1]),
          'Input' : str(register_answers[2]),
          'Region' : str(register_answers[3])} 
          
          
  
          try:
              message = await self.client.wait_for('message', timeout= 30.0, check = check)
          except asyncio.TimeoutError:
              await ctx.send('You didn\'t answer in time.  Please try again and be sure to send your answer within 30 seconds of the question.')
              return
          else:
              register_answers.append(message.content)
              print (f'{register_answers}')
              await ctx.send(f'Username{user["EpicUser"]}, Platform{user["Platform"]}, Input{user["Input"]}, Region{user["Region"]}')
          with open("users.json", "w") as file:
            json.dump(user, file)```

How would I be able to log the answer to each question as an answer? Im very new to python and this is my first large project so sorry if the solution is really simple.
slate swan
#

sending the answer to question in some channel?

neat tartan
ruby valve
slate swan
#

use list.append()

#

!e py my_list =[] my_list.append("a text") print(my_list)

unkempt canyonBOT
#

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

['a text']
slate swan
#

like this^

ruby valve
#

i have answers.append but i get the error IndexError: list index out of range still

ruby valve
#

File "/home/runner/Elo-Bot/cogs/register.py", line 31, in register
'EpicUser' : str(register_answers[0]),
IndexError: list index out of range

neat tartan
#

register_answers.append(message.content) shouldnt this be register_answers.append(ctx.message.content)?

tight mica
#
      register_answers = [] # Empty list

      for question in register_questions:
          await ctx.send(question)  # sends the question in channel

          user = {
          'EpicUser' : str(register_answers[0]) # now you are asking for the register_answers[0] before appending to it```
slate swan
#

move it outseide the for loop

#

whats the best free host in which i can make my bot

#

check pins

#

^^

#

lots of messages

#

i tagged the message

#

oh so they all are free

#

thank you

#

no

#

then

#

read what it says below, there's no good free option for hosting

#

but i asked for the free one

#

google cloud and aws provide free trials

tight mica
#

there's none

slate swan
#

replit is not a host, stop calling it a host.

strong vessel
#

there is so much free servers....

tight mica
neat tartan
#

repl.it is about the only "good" absolute garbage free host

slate swan
#

fine

strong vessel
#

i mean like is the free servers not strong enough? i don't get it

#

doesn't like every thing have free servers

tight mica
#

1sec

slate swan
#

they are, but they dont have a good privacy policy
they got your token and stuff

strong vessel
#

yeah every server going to have your token

neat tartan
strong vessel
#

how else could it work

tight mica
slate swan
#

if you use a server, the panel admins have complete acess to it, whereas with a good "paid" vps, that wont be the issue

#

google cloud and aws are considerable

strong vessel
#

its too bad discord doesn't host bots

#

i don't get why they don't tbh

tight mica
#

why would they

slate swan
neat tartan
strong vessel
#

do discord bots really take a lot of load though

#

like its just processing text

tight mica
strong vessel
#

idk i'm new

tight mica
#

im leavin this chat

#

too much cringeyness for me

strong vessel
#

sorry sorry

slate swan
#

mine's take around 200 mbs memory

neat tartan
#

i dont think they take too much until its in hundreds-thousands of servers taking many requests per second

slate swan
#

100-150 only for the runtime

#

( for 83 servers)

neat tartan
#

is there an easy way to get how many servers your bots in?

slate swan
#

len(bot.guilds)

neat tartan
#

fuck, fair enough

final iron
unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

final iron
#

Uh

slate swan
#

its just Client.guilds

sage otter
#

It’s just Client

strong vessel
#

It's just

final iron
#

There is a ClientUser though

sage otter
#

Yeah

final iron
#

!d discord.user.ClientUser

unkempt canyonBOT
#

class discord.ClientUser```
Represents your Discord user.

x == y Checks if two users are equal.

x != y Checks if two users are not equal.

hash(x) Return the user’s hash.

str(x) Returns the user’s name with discriminator.
sage otter
#

But that doesn’t hold the guilds property

slate swan
#

it means the user of the Bot, so you're doing like discord.User.guilds

strong vessel
#

no way, for those bots in 3m servers how do they even run

sage otter
#

By having many resources

strong vessel
#

100TB memory? idk

slate swan
#

bots like carl bot hold gigabytes of cache

strong vessel
#

100 server=100 mb
3m server = 3m mb = 3tb ram

#

idk maybe its different

sage otter
#

that’s definitely not how that works

strong vessel
#

okie

slate swan
#

depends on members and other cache

#

if you keep all the intents off ( a RESTClient ) its barely 50 mb

strong vessel
#

oof the rabbit hole goes really far

slate swan
#

but it wont be able to interact with the gateway, only requests will be made

strong vessel
#

thanks

pliant gulch
#

People also do this with slash commands, setting up an interactions redirect URI which sends to their running servers, validating the request then returning a json object representing the interaction response

#

I'm sure you could get even lower than 50mb with some setups

#

While still being effective

strong vessel
#

cool

boreal ravine
#

the developers are planning to use py-cord now

pliant gulch
#

Splitting up the resources even more

slate swan
slate swan
strong vessel
#

hikari or disnake

#

is it possible to use the stuff like slash commands in discord py?

pliant gulch
#

The response is also limited, somewhat? Or at least hard to use in a powerful manner

#

At least from my expirences

slate swan
strong vessel
#

ok i'll do disnake because i prefer some easy way

slate swan
pliant gulch
#

Models are mostly dependent on cache and gateway events

#

You'd need to do an http request to get, modify, etc

strong vessel
#

but they're switching to rust?

#

nvm

boreal ravine
slate swan
boreal ravine
slate swan
# vocal snow why

That's what the new Devs chose , the original developer was Rewriting it in rust

unkempt canyonBOT
#

examples/basic_slash_command_bot_example.py lines 22 to 28


@bot.command()
@lightbulb.command("ping", "Checks that the bot is alive")
@lightbulb.implements(lightbulb.SlashCommand)
async def ping(ctx: lightbulb.Context) -> None:
    """Checks that the bot is alive"""
    await ctx.respond("Pong!")```
pliant gulch
#

Does hikari have slash commands natively

#

Without a 3rd party library

slate swan
pliant gulch
#

Was the bot bought or did the owners switch

pliant gulch
#

I am down bad for implementations 😔

slate swan
#

sure, lemme see if there are any examples
since i never used that in raw hikari

#

well this is the SlashCommand class

pliant gulch
#

Can't really tell the implementation

#

I have no idea about navigating this codebase

patent fiber
#

anyone how to make a command that gives a radom message every time using hikari

slate swan
#

its in the rest

pliant gulch
#

Which I'm mostly interested in finding stuff for

light violet
#

Hey how to boost ban speed

#

I couldnt increase ban spd even using api

#

Pls help

#

I want bans in 0.1 millisecond lmao

patent lark
#

you use the API anyways?

vocal snow
patent lark
#

since banning users is a coroutine

pliant gulch
#

0.1 milisecond 👁️

#

Your gonna need an ethernet connection directly to discord's servers

light violet
vocal snow
#

LOL

patent lark
#

thats a joke right?

light violet
#
@commands.Cog.listener()
    async def on_member_ban(self, guild, user):
        start = datetime.datetime.now().timestamp()
        reason = "R Anti-Nuke | Banning Members"
        logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.ban).flatten()
        logs = logs[0]
        user = logs.user.id
        async with aiohttp.ClientSession(headers = { 'Authorization': f'Bot {self.client.http.token}', 'Content-Type': 'application/json' }) as session:
                    
                async with session.put("https://discord.com/api/v9/guilds/%s/bans/%s" % (guild.id, user), json={"reason": reason}) as r:
                            took = round((datetime.datetime.now().timestamp() - start), 3)
                            
                            if r.status in (200, 201, 204):
                                logging.info("Successfully banned %s" % (user))
                                c = self.client.get_channel(940208901528363028)
                                await c.send(f"Banned %s, took: {took}" % (user))
                            else:
                                logging.error(f"Could not ban %s" % (user))                  ```
#

Here is my code how to do tgat

#

This ban in 0.4

#

Sec need 0.1 sec

#

Ban

vocal snow
#

If you want speed, python isn't the language for you

light violet
#

Which lang is for spd then

vocal snow
#

Low level languages like rust

slate swan
light violet
#

How add httpx aio

#

Pls help

#

Need help in adding httpx

pliant gulch
#

that's why I've rewritten it so many times

#

I haven't found anything good

#

For frontend use that is, everything backend is easy

light violet
#

@slate swan bro do u know how to use httpx

pliant gulch
# pliant gulch I haven't found anything good
from __future__ import annotations
import asyncio
import logging

import os
import rin

logging.basicConfig(level=logging.DEBUG)
client = rin.GatewayClient(os.environ["DISCORD_TOKEN"])

@client.once(rin.Events.READY)
async def ready(user: rin.User) -> None:
    print(f"Logged in as {user}")

    async with rin.ChatCommandBuilder(client, 837516299461591060) as builder:
        with builder.options() as options:
            options("user", type=rin.Member)

        builder.description("An example description.")
        builder.guilds(907106240537169980)
        builder.name("demo")

        @builder()
        async def callback(interaction: rin.Interaction, user: rin.Member) -> None:
            await interaction.send(f"Hey {user.mention}")

asyncio.run(client.start())
``` Heres one of them
slate swan
gleaming barn
#
import discord
import os

'''
reading key value pairs from .env
file and set them as envir variables
'''

#preventing enviroment pollution
from dotenv import load_dotenv

load_dotenv()
TOKEN_KEY = os.getenv('DISCORD_KEY')
bot_client = discord.Client()

@bot_client.event
    # changes how call will behave
    # must list event loop to run this part of code
async def on_ready(): # event handler
    print(f'{bot_client.user} is connected to discord!')
bot_client.run(TOKEN_KEY)

So i've been trying to get this dotenv to work for quite a bit and honestly don't know what is wrong I don't think I need to install anything extra? am I missing something?

pliant gulch
#

Then I scrapped that one,

slate swan
lament mesa
slate swan
#
class Ping(slash_commands.SlashCommand):
    name = "ping"
    description = "Bot's Heartbeat Latency"
    async def callback(self , ctx : lightbulb.SlashCommandContext )->None:
       ...
bot.add_slash_command(Ping)
``` another implementation
#

this one is lowkey simple

pliant gulch
slate swan
#

ChatCommand here means the application command ill assume

pliant gulch
pliant gulch
pliant gulch
#

There are different types

slate swan
#

oh ya, there are user commands too

pliant gulch
#

The slash command one would be of the CHAT INPUT one

gleaming barn
vocal snow
gleaming barn
#

oh loool

slate swan
#

just use os.getenv

gleaming barn
#

i'm dumb

slate swan
#

ah, you're using it to load

gleaming barn
#

works now thank you very much

pliant gulch
#

Thoughts on doing ```py
@Something
class Command(...):
...

#

😔 I hate it still though

gleaming barn
slate swan
pliant gulch
#

"This would be on the same level as event listeners", E.g ```py
@GatewayClient.on(rin.Events.READY)
async def ready(user: rin.user) -> None:
...

@ChatCommand(...)
class Command(...):
...

gleaming barn
slate swan
gleaming barn
#

Alright

slate swan
gleaming barn
#

still errors

slate swan
#

think what about the options? would you implement it in the decorator or as function arguments

gleaming barn
#
'''
An account
an application - allows interaction with discord API
a bot
a guild

'''
#bot.py
import discord
import os

'''
reading key value pairs from .env
file and set them as envir variables
'''

#preventing enviroment pollution
from dotenv import load_dotenv

load_dotenv()
TOKEN_KEY = os.getenv('DISCORD_KEY')
bot_client = discord.Client()

@bot_client.event
    # changes how call will behave
    # must list event loop to run this part of code
async def on_ready(): # event handler
    print(f'{bot_client.user} is connected to discord!')
bot_client.run(TOKEN_KEY)
slate swan
#

os.getenv should work normally in most of the cases

#

remove the ```py
from dotenv import load_dotenv

load_dotenv()``` part

gleaming barn
#

alright

slate swan
#

and see if it still causes an problem

pliant gulch
# slate swan this one seems kinda cool, a decorator would be handy
@GatewayClient.once(rin.Events.READY)  # NOTE: `ONCE`
async def ready(user: rin.User) -> None:
    print(f"LOGGED IN AS {user}")

    @ChatCommand(...)
    class Command(name="demo", ...):
        ... # set things here

    # ^^^ Caches internally via decorator.

@AppCommands["demo"].on()
async def callback(...) -> None:
    ...


@AppCommands["demo"].once()
async def callback(...) -> None:
    ...


@AppCommands["demo"].collect(amount=5)
async def callback(...) -> None:
    ...
``` Thoughts
#

Options would be defined inside of the classes namespace

gleaming barn
#

no problems @slate swan

#

thanks

pliant gulch
slate swan
#

since that ends the point of having seperate decos

pliant gulch
#

If slash commands inherit rin.Event they gain all the pros from rin.Event

#

There is a hierarchy between which gets called first though

slate swan
#

ah, makes sense

pliant gulch
regal pulsar
#
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import random
client = discord.Client()
bot = commands.Bot(command_prefix = '$')

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@bot.command()
async def whydidyoucry(message):
    whyICried = ['1', '2', '3']
    await message.channel.send(random.choice(whyICried))
            
client.run(token_goes_here)
#

whats with @bot.command()

#

it wont work

torn sail
#

You should only have one bot or client remove client and change client.event to bot.event and client.run to bot.run

regal pulsar
#

oh

#

i see

#

perfect it works

#

ty

frail mesa
#

Hello, could anyone tell me what I am doing wrong here? A bit new to discord.py and python in general. Looked around online a lot but can't seem to figure it out. I am getting error "member is a required argument that is missing"

@bot.command()
async def cleanup(ctx, member: discord.Member):
  big_airut_speedrun_1_id = 826189814596108378
  big_airut_speedrun_2_id = 762488902304006174
  big_airut_speedrun_3_id = 757836549361762424
  big_airut_speedrun_1 = ctx.guild.get_roles(big_airut_speedrun_1_id)
  big_airut_speedrun_2 = ctx.guild.get_roles(big_airut_speedrun_2_id)
  big_airut_speedrun_3 = ctx.guild.get_roles(big_airut_speedrun_3_id)
  if member.has_roles(big_airut_speedrun_1):
    await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3)
  elif member.has_roles(big_airut_speedrun_2):
    await member.remove_roles(big_airut_speedrun_3)
  else:
    await ctx.channel.send('None found.')
slate swan
#

you didn't mention a member while running the command

#

And member has no attribute has_role

frail mesa
#

i am trying to have it go through all users in the server

slate swan
#

member.has_roles is not a thing

frail mesa
#

yea i gotcha there, will deal with that. but i think that would be a different error no? i think this is something wrong with the arguments line?

regal pulsar
#
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import random
client = discord.Client()
bot = commands.Bot(command_prefix = '$')

@bot.event
async def on_ready():
    print('We have logged in as {0.user}'.format(bot))

@bot.command()
async def whydidyoucry(message):
    whyICried = ['1', '2', '3']
    await message.channel.send(random.choice(whyICried))
    
@bot.command()
async def spam(message):
    text_to_spam = message.content.split(' ')
    amount_to_spam = int(message.content.split()[2])
    amount_spammed = 0
    while amount_spammed > amount_to_spam:
        await message.channel.send(text_to_spam)
            
bot.run('')
#

i get this error