#discord-bots

1 messages · Page 933 of 1

stuck oyster
#

the channel isn't being deleted

slate swan
#
@tasks.loop(seconds = 5)
    async def loop(self):
        for channel in self.guild.text_channels:
            if channel.name == "batt-done":
                print('test')
                await channel.delete()

use this see if it even is finding the channel

stuck oyster
#

didn't print

#

that means theres a problem

slate swan
#

yup so self.guild isnt working

stuck oyster
#

what should I use

#

because guild isn't defined

slate swan
#

try

async def loop(self, ctx):
  for channel in ctx.guild.text_channels:
    if channel.name == "batt-done":
      print('test')
      await channel.delete()
#

idk if u can call more arguments

stuck oyster
#

did not bring

#

event

#

ctx didn't work

#

they told me to use task

#
    @tasks.loop(seconds = 5)
    async def loop(self, ctx):
        for channel in ctx.guild.text_channels:
            if channel.name == "batt-done":
                print('test')
                await channel.delete()```
slate swan
#

yeah something like this

@client.event
async def on_guild_channel_delete(channel):
  #do sum
stuck oyster
#

I am confused

#

how would it loop

hushed totem
#

Hello, I have an error and I don't know how to solve it, can someone help me please?

slate swan
stuck oyster
#

huh

slate swan
#

its an event

hushed totem
#

Exception has occurred: ModuleNotFoundError
No module named 'discord.ext'; 'discord' is not a package

During handling of the above exception, another exception occurred:

File "D:\Hack\Visual studio code\discord.py", line 2, in <module>
from discord.ext import commands
File "D:\Hack\Visual studio code\discord.py", line 1, in <module>
import discord

slate swan
#

only when it gets triggerd it runs

stuck oyster
#

It is supposed to delete automatically whenever a channel is renamed to #batt-done

hushed totem
stuck oyster
#

how would I put a timer, it needs to be checked every 30mins

hushed totem
#

where ?

spice shore
#

What does this mean
IndentationError: unindent does not match any outer indentation level

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

stuck oyster
#

well what if someone renames it and still need to do something in the channel, it will just get deleted

hushed totem
#

yes, the discord.py extension is installed on my visual studio code

spice shore
slim ibex
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

stuck oyster
#

someone renames the channel, then they want to log something which is in the channel. Since it has no timer it will just delete immediately when it is renamed

#

no every 30mins

spice shore
#

ups 20 - 21 - 22

slate swan
#

yeah so after it gets renamed if its X it will remove

#

ohh the argument

hushed totem
#

how can i solve my problem please?

stuck oyster
#

yes, after 30mins the bot should delete the channel #batt-done

slate swan
#
@client.event
async def on_guild_channel_update(after):
  if channel.name == "test":
    await channel.delete()
#

this?

#

yeah i forgot

slate swan
#

yh

spice shore
slate swan
#

oh okay

dull sorrel
#

Anyone knows why this is not working?
if message.content == f"<@{client.user.id}>":

   await message.channel.send("Hello", reference = message)

The bot does not send the text when mentioned.

slate swan
#

in brackets

stuck oyster
#
    @commands.Cog.listener()
    async def on_guild_channel_update(before, after):
        if isinstance(after, discord.TextChannel):
            if after.name == "batt-done":
                asyncio.sleep(5)
                await after.delete()```
Channel wasn't deleted. I changed it to 5 to test it
slate swan
#
@commands.Cog.listener()
    async def on_guild_channel_update(self,before, after):
        if isinstance(after, discord.TextChannel):
            if after.name == "batt-done":
                asyncio.sleep(5)
                await after.delete()
#

it should be self

stuck oyster
#

did not print

#

oh yes

dull sorrel
#

I don't want to just mention it. I want to make it like if someone says, "Hi @mybot", the bot will reply.

stuck oyster
#

no

slate swan
stuck oyster
#

no

#
import disnake as discord
import asyncio
from disnake.ext import commands


class Tracking(commands.Cog):

    def  __init__(self, client):
        self.client = client


    @commands.Cog.listener()
    async def on_guild_channel_update(self, before, after):
        if isinstance(after, discord.TextChannel):
            if after.name == "batt-done":
                asyncio.sleep(5)
                await after.delete()
    




def setup(client):
    client.add_cog(Tracking(client))```
slate swan
#
@commands.Cog.listener()
    async def on_guild_channel_update(self, before, after):
        if isinstance(after, discord.TextChannel):
            if self.after.name == "batt-done":
                asyncio.sleep(5)
                await self.after.delete()
hushed galleon
#

wdym no need to await the sleep

slate swan
stuck oyster
#

ok

slate swan
stuck oyster
#
    @client.event()
TypeError: event() missing 1 required positional argument: 'coro'```
slate swan
#

You do

#

!d asyncio.sleep | it's a coro

unkempt canyonBOT
#

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

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

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

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

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

Example of coroutine displaying the current date every second for 5 seconds:
hushed galleon
#

if asyncio.sleep worked without awaiting, that would completely break the purpose of the event loop

slate swan
#

u do tho

#

That may just process without raising an error, but won't do it's job :p

stuck oyster
#

?

hushed galleon
#

no parentheses after event

stuck oyster
#

oh

slate swan
#

yeah

stuck oyster
#

still did not work

slate swan
hushed galleon
#

can you show the intents you passed to your bot's constructor if you have any?

stuck oyster
#
@client.event
async def on_guild_channel_update(before, after):
  print('test')
  if isinstance(after, discord.TextChannel):
    if after.name == "batt-done":
      asyncio.sleep(5)
      await after.delete()```
#

oh

slate swan
#

it's enabled by default tho

#

oh yeah i forgot that too

hushed galleon
#

yeah, but its still a possible cause

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

hushed galleon
slate swan
hushed galleon
#

since when

slate swan
#

what

hushed galleon
#

dpy 2.0 and <2.0 still assume the default() intents

slate swan
hushed galleon
#

yes, all the non-privileged intents

slate swan
#

ah ic

slate swan
stuck oyster
#

uh

slate swan
hushed galleon
#

several forks are based off of dpy 2.0/master branch

slate swan
#

from the official dpy team?

stuck oyster
slate swan
slate swan
unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

okay

stuck oyster
#

yes it is enabled

slate swan
stuck oyster
#

no

slate swan
#
        data = dataz.split(":",1)```

dataz won’t split
stuck oyster
slate swan
#

I just enable all intents

slate swan
#

is it printing test?

#

at least

#
        data = dataz.split(":",1)```

dataz won’t split
hushed galleon
#

assuming you've called requests.Response.json(), it returns a dict object so what is there to split

slate swan
slate swan
stuck oyster
slate swan
#

It’s requested from api

#

And api uses json

#

I just wanna split man part

slate swan
hushed galleon
slate swan
#

So I’ve got hello:man

hushed galleon
#

what endpoint are you using

slate swan
#

A paid one

stuck oyster
#

nope

slate swan
hushed galleon
#

wait so not even discord API we're talking about...

stuck oyster
#

visual studio code

slate swan
#

No I’m not

slate swan
# stuck oyster nope

invite the bot to another server i was having the same issue with the guild not getting triggerd

#

bot.run-

stuck oyster
#

python main.py

slate swan
slate swan
slate swan
stuck oyster
slate swan
#

rip

slate swan
#

And put token

stuck oyster
#

yes

#
import disnake as discord
from disnake import Intents
import asyncio
from disnake.ext import commands

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



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


@client.event
async def on_ready():
    print(f"Live: {client.user}")


@client.event
async def on_guild_channel_update(before, after):
  print('test')
  if isinstance(after, discord.TextChannel):
    if after.name == "batt-done":
      asyncio.sleep(5)
      await after.delete()```
hushed galleon
# slate swan No I’m not

regardless their documentation should explain how the response looks like for the API endpoint you've requested, and if not you can just print the json response and figure out how to index the value you're looking for

stuck oyster
slate swan
#

disnake as discord peepocry

stuck oyster
#

yes

#

no

unkempt canyonBOT
#

disnake.on_guild_channel_update(before, after)```
Called whenever a guild channel is updated. e.g. changed name, topic, permissions.

This requires [`Intents.guilds`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.guilds "disnake.Intents.guilds") to be enabled.
stuck oyster
#

are you sure its not supposed to be a task loop

#

did not work

#

should we try task

slate swan
stuck oyster
#

i did

#

let me just explain my motive

hushed galleon
#

for your purpose of deleting a channel on rename, reacting to an event is much more responsive/efficient than running a loop

silent ermine
#

How do I set this datetime to a UTC Timezone? date = datetime(year=year, month=month, day=day, hour=hour, minute=minute)

#

kkty

#

whats a fold

stuck oyster
#

So... I want the bot to automatically delete a channel when it is renamed to a specific name (#batt-done or #am-done). Then there will be a log channel which once the channel is delete, the bot will edit its message or embed (log) to Battbattling - 1. So each time the channel is deleted it will be logged in the log channel which the number keeps increasing

hushed galleon
#

timezones are a bitch

silent ermine
silent ermine
stuck oyster
#

indeed

hushed galleon
#

i believe the python docs mentions an example of ambiguity with timezones

south jetty
#

can someone send the discord doc or something on timestamps

silent ermine
unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
stuck oyster
#

if its not being printed then the problem is py @client.event async def on_guild_channel_update(before, after):

stuck oyster
#

man

stuck oyster
#
import disnake as discord
from disnake import Intents
import asyncio
from disnake.ext import commands

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



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


@client.event
async def on_ready():
    print(f"Live: {client.user}")


@client.event
async def on_guild_channel_update(before, after):
  print('test')
  if isinstance(after, discord.TextChannel):
    if after.name == "batt-done":
      asyncio.sleep(5)
      await after.delete()



client.run("")```
#

this is everything

umbral condor
#

bc I want to try it

tough lance
#

Firstly asyncio.sleep is a coroutine

#

You need to await it

hushed galleon
#

did you enable the bot scope when you invited your bot?

stuck oyster
#

do I have to update after the bot is running

#

so it wont work if the channel is already renamed?

tough lance
#

Are the intents enabled to developer portal also?

stuck oyster
#

ow

#

ok hold on

slate swan
#

fr

hushed galleon
#

a misunderstanding of how events work

tough lance
#

Lol

slate swan
#

i didnt scroll the entire docs for this keka

stuck oyster
#

well... That was the problem 😁

hushed galleon
stuck oyster
#

also py RuntimeWarning: coroutine 'sleep' was never awaited asyncio.sleep(5)

tough lance
#

Wait I didn't get it how did the event work?

hushed galleon
#

it only fires when a channel is updated

stuck oyster
#

alright

hushed galleon
#

issue here was that they... didnt update it

tough lance
#

Oh

stuck oyster
#
if after.name == "batt-done":```
I want to fit in multiple channel names
#

how would I do that

hushed galleon
#

multiple string comparisons, either py if name == 'a' or name == 'b': or more preferably py if name in ('a', 'b'):

stone moon
#

How do I find the user Id of someone who reacted a certain reaction to a message?

hushed galleon
#

given by the on_reaction_add event or just checking a message?

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
stone moon
#

I want my bot to check for reactions on messages in a certain channel on ready

tough lance
#

That really sucks lol

south jetty
#

no in the developer portal

hushed galleon
slate swan
#

heroku gives only 550 hours run time for bot

#

then it wants Fee

hushed galleon
#

i think he means the dev docs

slate swan
#

😩

south jetty
#

I don't know I remembed seeing something like that but I cant find it

tough lance
slate swan
#

is there any way to host my bot for free lifetime ?👉 👈

south jetty
#

or is there something related to %d or smth

south jetty
#

yes

hushed galleon
#

basically the same documentation as format_dt

slim ibex
tough lance
#

Best imo

slim ibex
#

you can host on a vps for cheap. If you want free get and old pc and host there

slate swan
slate swan
slate swan
#

or a pc that is laying around

#

i'll try replit

#

okay

tough lance
#

That also doesn't mean replit would be good for you. Wou would face latency issues

hushed galleon
#

or disconnection from discord, when other bots on the same datacenter send too many API requests

tough lance
#

Nichijou

slow fog
#

is there a way to make a timeout limit for a specifc command function, i found something working with python in general but since discord bots are dealing with async def it cant be called

azure depot
#

yes

tough lance
#

!d discord.ext.commands.Cooldown

unkempt canyonBOT
tidal hawk
#

How do Mee6 n other big bot's hold so many configurations for other servers? They are certainly not using Json.. right?

tough lance
#

No why'd they

tidal hawk
#

no reason

tough lance
#

Your best option for big bots is PostgreSQL

#

Or sqlite if your bot isn't that big

tidal hawk
#

will aiosqlite going to burn out or what

hushed totem
hushed galleon
hushed totem
#

this error and i have good discord.py to install on visual studio code

#

thks

hushed galleon
# tidal hawk will aiosqlite going to burn out or what

burn out as in it starts becoming a bottleneck? afaik you should consider a client-server db once you start doing a lot of concurrent reading/writing in your bot
sqlite's default mode uses a rollback journal which is less efficient for concurrency, but you can change it to a write-ahead log using PRAGMA journal_mode = WAL; which improves performance and i believe avoids database is locked errors (https://sqlite.org/wal.html) (the asqlite library by Danny turns this on automatically)

hushed totem
#

now I have this error normal?

Exception has occurred: PrivilegedIntentsRequired
Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

During handling of the above exception, another exception occurred:

During handling of the above exception, another exception occurred:

File "D:\Hack\Visual studio code\lrd.py", line 187, in <module>
client.run("TOKEN")

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

#

of course instead of TOKEN I have the token of my bot

hushed galleon
#

well its telling you what to do

#

members, presences, and message_content are privileged intents

hushed totem
#

what a privilege ?

hushed galleon
#

privileged intents have to also be turned on in discord's website

#

if you click the Bot tab in your application and scroll down you'll see them there

hushed totem
#

indeed I have activated everything and it seems to work thank you very much however I had tried just before

#

thanks !!!

#

my bot does not appear online even though it is start

stuck oyster
#

ok so now, How would I make the bot update logs anytime the channel (ticket) is deleted

hushed galleon
#

you'd get the log channel and send a message to it

stuck oyster
#

what should I use to get channel

#

self.get_channel?

hushed galleon
#

if self was a variable that contained an instance of discord.Client sure

#

but you defined client = commands.Bot() earlier so you probably mean client.get_channel(id)

#

or self.client if you defined it in a cog...

stuck oyster
vale wing
#

get_channel is a method of Bot and Guild

#

Not of the Cog

slate swan
#

Why is my bot not saying This cant be blank silly. if he didnt put a nickname after the mention?

vale wing
#

1 space indent?

#

Wth

cold sonnet
#

nick can't be None indeed

slate swan
#

put that in the param

slate swan
hushed galleon
#

yeah your nick parameter needs a default value, otherwise dpy will raise MissingRequiredArgument if the user doesnt type it

cold sonnet
#

or maybe it can cuz it's a kwarg

cold sonnet
stuck oyster
#
    @commands.Cog.listener()
    async def on_guild_channel_update(self, before, after):
        if isinstance(after, discord.TextChannel):
            if after.name in ["batt-done", "am-done"]:
                await asyncio.sleep(5)
                await after.delete()

                log = self.client.get_channel(957281408924139601)

                await log.send("Tracking\n\n `BattBattling` - `0`")```
hushed galleon
#

i dont see them implying that

#

could very well be that the error was suppressed by an improper on_command_error

hushed galleon
slate swan
cold sonnet
#

no

hushed galleon
#

get_channel is only used with IDs

#

looking up by name would be done with discord.utils.get or similar

slate swan
#

Can u use discord.utils.get

stuck oyster
slate swan
cold sonnet
#

log is a static channel for sure

stuck oyster
#

when someone renames random channel to batt-done it will be deleted and be logged +1 in log channel. so the bot will edit it to BattBattling - 1 and goes on

stuck oyster
slate swan
stuck oyster
#

yes

slate swan
#

Oh okay

stuck oyster
#

not only batt-done I plan on making other in the logs different user

hushed galleon
#

well since you need to track that count across restarts, you need some form of data persistency

#

if you have a database then you'd store the count in that

stuck oyster
#

but it should be edited in the log

hushed galleon
#

yeah an alternative could be having one message that stores the count, then every time you start your bot you'd fetch that message to retrieve the current count

stuck oyster
#

which database

#

i see people json

#

they say its simple to use

final iron
#

Json isn't a database

hushed galleon
#

i would suggest something SQL-based since if you decide to add more features like inventories or currency, SQL will be really suited for that kind of consistent format

final iron
#

And it's definitely not simple to use

stuck oyster
hushed galleon
#

SQLite via the asqlite or aiosqlite library is a good place to start since its all stored in one file

stuck oyster
#

also would I need to worry about this event crashing with othee events/commands

hushed galleon
#

you store just the channel and message id, which is all you need to edit it

hushed galleon
stuck oyster
hushed galleon
#

wym

stuck oyster
#

would it add the +1 in the log channel

hushed galleon
#

not by itself, you need to create the new message somehow

#

hence why you'd use a database to store the count

hushed totem
#

hello I have this error: Exception has occurred:
ModuleNotFoundError No module named 'discord'
can help me please?

maiden fable
slate swan
hushed galleon
stuck oyster
#

ok

river swift
#

hi guys i have this problem

#

@bot.command(pass_context=True)
async def embed(ctx):
embed = discord.Embed(title="Titulo", description="Descripcion", color=0xffffff)
embed.set_footer(text="sub-texto")
embed.add_field(name="info1", value="Hola", inline=True)
embed.add_field(name="info2", value="Chao", inline=True)
await ctx.send(embed=embed)

#

I wrote this code but it gives me an error

#

File "main.py" , line 15
await ctx.send(embed=embed)
^
syntaxerror : "await" outside function

hushed galleon
#

those last four lines arent indented in your command

river swift
hushed totem
hushed galleon
#

... indent them inside your command

river swift
maiden fable
hushed galleon
#

if you search up dpy documentation it defaults to the stable branch so you'd have to mention that caveat too

slate swan
#

uh yeh

stuck oyster
#

is this correct?

final iron
river swift
final iron
river swift
minor totem
# river swift ok

You can also press the TAB key in most editors. Which one do you use?

cold sonnet
cold sonnet
#

yeah, that one converts tabs to spaces

#

wait, not VS Code?

tough lance
#

Visual studio code

minor totem
bold hedge
#

Hey, I'm using discord_slash and I'm having trouble with reacting when users pick an option of a select, the event is simply not firing, am I maybe waiting for the wrong one?

minor totem
#

It never prints success?

bold hedge
#

yes

#

when I change the event to typing and start typing it fires tho (and prints success)

minor totem
#

Have you waited for interactions previously? As in, are you sure that interaction_create is the right name?

bold hedge
#

no

#

I wasnt able to find a list of events anywhere

minor totem
#

Which version of discord.py are you using this with?

sick birch
#

Pretty sure it’s on_interaction

slate swan
#

you can someone help me im using disnake api,

class MyModal(disnake.ui.Modal):
    def __init__(self) -> None:
        components = [
            disnake.ui.TextInput(
                label="Name",
                placeholder="The name of the tag",
                custom_id="name",
                style=disnake.TextInputStyle.short,
                max_length=50,
            ),
        ]
        super().__init__(title="Moderator Application", custom_id="ModApp", components=components)

    async def callback(self, interaction: disnake.ModalInteraction) -> None:
        embed = disnake.Embed(
           title=f"New Mod Application",
           description=f"<@{interaction.author.id}> Submitted This Application ",
           color=0xDC143C
        )
        await interaction.response.send_message(embed=embed)

    async def on_error(self, error: Exception, inter: disnake.ModalInteraction) -> None:
        await inter.response.send_message("Something Went Wrong Here...", ephemeral=True)

this is my code, if anyone knows how, can you help me pull the name from this, i cant figure it out

bold hedge
bold hedge
slate swan
#

i just learned about modals today, and the example code is confusing me a lot

austere solstice
#

somebody help

narrow grail
#

how to play an audio file with my bot?

austere solstice
#

you cant strait play a audio file you need certain librarys

narrow grail
#

I mean with ffmpeg

orchid smelt
#

I'm trying to get my bot to display a photo in discord but when I give the command my bot returns "<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1000x983 at 0x202DBEAAB90>"

#

Any idea how i can get my bot to display the actual image instead of the data?

boreal ravine
#

Show how you send it

austere solstice
boreal ravine
austere solstice
boreal ravine
#

no

#

it's a random module error

daring olive
austere solstice
#

@boreal ravine

daring olive
boreal ravine
minor totem
austere solstice
boreal ravine
austere solstice
orchid smelt
bold hedge
austere solstice
#

worked thnks @boreal ravine

radiant wing
#
client = discord.Client()

player1 = 0
player2 = 0
playerOneIn = False

@client.event
async def on_message(message):
    messageContent = message.content.casefold()

    guildChannel = message.channel

    if message.content.startswith('hm!player1'):
        playerOneIn = True
        player1 = message.author.id
        print(player1)

        await guildChannel.send(f'<@!{player1}>, wait for Player 2 to use `hm!player2`.')

    elif message.content.startswith('hm!player2'):
        print(player1)
        if message.author.id == player1:
            await guildChannel.send(f'<@!{player1}>, you are already playing as Player 1!')
#

How do I make it remember player1 variable?

boreal ravine
#

what do you mean by remember?

radiant wing
#

Check my code above

#

I want to compare it when another command is used

boreal ravine
boreal ravine
radiant wing
#

But for the first print(player1), it prints user's id, and for the second, it prints 0

#

So it doesn't remember it

orchid smelt
#

thanks again

bold hedge
minor totem
#

Depends on the version of discord.py you use with discord_slash.

#

Which do you use?

boreal ravine
bold hedge
slate swan
#

hey, I have a question, in discord.py I imported another file to generate a random room in 2D using recursive generation the thing is, the function in the other file returns a string so I only had to call the function from the command and send the output, but it is giving me an error and I can not find any info about it

slate swan
bold hedge
final iron
bold hedge
stuck oyster
#

is it like this?

slate swan
stuck oyster
slate swan
stuck oyster
#

alr so now im still confused how I am going to make the logging

stuck oyster
#

he said its correct

slate swan
#

Did u try it at least

stuck oyster
#

yes it worked

#

I am moving on to the logging

slate swan
stuck oyster
#

no not like that

slate swan
stuck oyster
#

hold on real quick

slate swan
#

a list i assume?

#

Ye

#

that would be wrong.

stuck oyster
#

so if another channel batt-done is renamed it will be deleted, and the message in the log channel will be edited to BattBattling - 2

slate swan
stuck oyster
slate swan
#

!d discord.Guild.channels

unkempt canyonBOT
slate swan
#

just iterate through the list

#
for channel in ctx.guild.channels:
    if channel.name == "":
        ...

something like this

stuck oyster
#

?

slate swan
# stuck oyster ?

bro you want to find all channels in a guild which such name right?

stuck oyster
#

Im talking about logging it

slate swan
#

logging as sending actions to another channel?

stuck oyster
#

or a tracker

slate swan
stuck oyster
#

ah I wish i had an example of what i am trying to do but they kicked me from the server

slate swan
#

yeah as said you have gotten the channel obj from cache?

stuck oyster
#

well, when someone renames the channel to batt-done it will be deleted and be logged +1 in log channel. so the bot will edit it to BattBattling - 1 and goes on

#

so it will be BattBattling - 1

#

if another channel renames and get deleted with the same name it will be BattBattling - 2

#

and keeps on going

#

more like a tracker than logging

slate swan
#

then just look for 2 names and set values to variables?

#

So if u rename a channel it will be deleted and named to bat-2

stuck oyster
slate swan
#

not sure what you want as the explanation isnt quite clear

slate swan
#

no

#

But i dont get why u r doing this ur the owner and only mods can change the channel name whats the point

#

just use aiosqlite as youre using it in your bot

slate swan
slate swan
#

Or what is this

#

Cuz i dont get why u or anyone would rename a channel for it to be removed and then create a channel called BattBattling - X

stuck oyster
#

When someone renames a random channel to batt-done it will be deleted. Then in the log channel there will be a message BattBattling - 0 it will be then edited to BattBattling - 1 and if another channel renamed to batt-done gets deleted and then BattBattling - 2 and keeps on going

stuck oyster
slate swan
#

Im using json to store my ticket system stuff😅 😅 🥲 🥲 🥲

stuck oyster
slate swan
#

Can anyone suggest me any simple db for dc bot

stuck oyster
# slate swan Okay

So back to it, since we are done with the delete, I should make a database for the log?

slate swan
stuck oyster
#

i dont know what to do next

#

how I am supposed to get the user

slate swan
thorn ore
#

Hi

slate swan
#

Oh i see

#

Sqlite is good for me

slate swan
#

!pypi aiosqlite

unkempt canyonBOT
slate swan
#

and ofc you meed to know SQL

#

Lol then ill learn sql first

#

um.

#

most people cant afford a server to host there pg server and sqlites only down side is it gets stored in a file so its not the best for big bots like mee6 but if the bot was big then yes pg should be your choice as some companies use it as well.

#

dont you have to host the server?

#

...

#

then how the heck would you access the db does it localhost?

#

yeah true

#

+im new to db stuff

#

what makes pg hard its queries ive heard theyre a bit difficult?

cloud dawn
cloud dawn
slate swan
#

ik but ive heard they had changed some stuff on it im not sure

cloud dawn
#

In PG it's just easier to go more advanced but you don't need to if you don't want to.

cloud dawn
slate swan
#

mhm thats nice

cloud dawn
#

I mean yeah ofc.

#

But if your bot isn't as big as groovy you won't need a separate database host.

slate swan
#

yeah

#

sqlite is good for beginners so they can get a grasp on a query etc

#

Ok.

spring flax
#

over how many guilds should you be considering switching from SQL?

slate swan
#

Im already using

#

broAG_WorryStab

slate swan
stuck oyster
spring flax
#

why?

slate swan
#

I was storing a large about in a json object thats why i thought to shift to db

spring flax
#

it's pretty straightforward

slate swan
#

Lol

stuck oyster
#

how am I supposed to know it was after the bot was running no one told me

hushed galleon
#

well its not often someone assumes that an event can trigger while the bot is offline

spring flax
#
def can_execute_action(ctx, user, target):
    return user.id == ctx.bot.owner_id or \
           user == ctx.guild.owner or \
           user.top_role > target.top_role

what do the \ do here?

hushed galleon
#

line continuation character, it just lets you write a long expression across multiple lines

#

as in manually making a request to discord?

spring flax
#

oh i see thank you

hushed galleon
#

if its part of your discord bot you can use the internal HTTPClient and Route class to make the request, that way dpy handles the authorization and ratelimiting for you

#

its internal

#

you'd have to figure it out from the source code and its usage in other dpy methods

slate swan
final iron
hushed galleon
final iron
#

Name the function something else and use the name kwarg in the command decorator

hushed galleon
#

an example usage would look like this py route = discord.http.Route('POST', '/channels/{channel_id}/messages', channel_id=343944376055103488) payload = {'content': 'my message'} await bot.http.request(route, json=payload)

final iron
#

!d discord.ext.commands.Bot.command

unkempt canyonBOT
#

@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
slate swan
#

ok let me try it, thx

hushed galleon
#

or at least thats what i did once last year to try out the voice activities which weren't yet public

scarlet aurora
#

i want to make my discord bot have a command where it sends ur message embedded

#
    @commands.command()
    async def embed(self, ctx):
        msg = discord.Embed(
            title='message',
            description=msg,
            colour=0xffffff,
        )
        await ctx.send(embed=msg)``` something like this but idk how to do it
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`.
spring flax
#

why are you putting the embed instance as the description??

scarlet aurora
#

the description should be whatever the user says

#

for example, ?embed hello

#

then the bot sends hello embeded

spring flax
#

put message as an argument to the function and put description=message

slate swan
#

how do i read the message history of a channel with a bot if i just give the bot an id

scarlet aurora
#
    @commands.command()
    async def embed(self, ctx, message):
        embed = discord.Embed(
            title='message',
            description=message,
            colour=0xffffff,
        )
        await ctx.send(embed=embed)``` so like this?
spring flax
#

yes

slate swan
#

the channel

spring flax
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
scarlet aurora
#

how do i fix that

spring flax
scarlet aurora
#

oh yes ofc

#

ty

hidden coyote
#

hey guys i have problem my problem ```py
with open("data.json") as file:
data = json.load(file)

#

error SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

vale wing
scarlet aurora
#
        now_utc = datetime.now(timezone('UTC'))
        await bot.say (now_utc.strftime(fmt) + " (UTC)")``` why does bot error?
#

bot underline

#

nvm i figured it out

spring flax
#

its been changed

#

!d discord.abc.Messageable.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
twin nest
#

Hi, how can i get channel from ID?

#

tried py self.client.fetch_channel and self.client.get_channel but none of those worked

#

yep i should have

#

on the developportal all of the three

pliant gulch
twin nest
#

yep 😄

pliant gulch
#

Yep to what?

#

I'm asking which are you doing

twin nest
#

infochannel = self.client.get_channel(id) and infochannel = await self.client.fetch_channel(id)

#

i tried both of them (not at the same time)

#

And still got ```AttributeError: 'NoneType' object has no attribute 'send'

pliant gulch
#

Ok, the "123" is wrong, you only use 123 as IDs are integers

#

And in what cases are you getting the channel from?

twin nest
#

i know that

pliant gulch
#

Is it in a command, etc?

twin nest
#

in task loop

pliant gulch
#

Ok, there is your issue then

#

A tasks.loop starts before the cache is populated

#

You would need to use wait_until_ready in your task

#

!d discord.ext.commands.Bot.wait_until_ready

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.

Warning

Calling this inside [`setup_hook()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.setup_hook "discord.ext.commands.Bot.setup_hook") can lead to a deadlock.
twin nest
#

I have that

pliant gulch
#

Call & await this, afterwards grab from cache

pliant gulch
slate swan
#

Does anybody know how to fix this ? ```@client.command()
async def clear(ctx, nombre : int):
messages = await ctx.channel.history(limit = nombre + 1).flatten()
for message in messages:
await message.delete()

twin nest
#
    def __init__(self, client):
        self.client = client
        self.send_shop_all.start()

    @tasks.loop(seconds=50)
    async def send_shop_all(self):
        check_time = datetime.datetime.now()
        channel = 945075687000272926
        infochannel = await self.client.fetch_channel(945075687000272926)
        if check_time.hour == 18 and check_time.minute == 37:
            some code here....


    @send_shop_all.before_loop
    async def before_shop_all(self):
        await self.client.wait_until_ready()
twin nest
pliant gulch
#

This should be working fine, perhaps try getting rid of the before_loop hook, and calling & awaiting self.client.wait_until_ready directly in send_shop_all

twin nest
#

Fuuuuuu me xD

pliant gulch
#

lmao

spring flax
#

What?

#

Oh okay

#

!d discord.TextChannel.set_permissions

unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

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

There are some examples in the docs above

twin nest
spring flax
#

Can you give examples of what you mean?

#

What do you mean different classes?

#

But you want to reset permissions only when close right?

#

So you can put it under the class CloseTicket class

#

Can you give your current code for the CloseTicket class? @slate swan

slate swan
#

how do i get my bot to send a message to a user when given the user's id

spring flax
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

no

spring flax
#

Then?

slate swan
# spring flax Then?

well it is reading a chat history and sending a dm to all users who said a certain keyword

slate swan
#

wdym by command

spring flax
#

Are you doing DMing users within a command?

slate swan
#

command as in !dm etc?

#

it does it as soon as i run the bot

#

so there is no commands

spring flax
#

@bot.command()

slate swan
spring flax
slate swan
#

yes

spring flax
#

But you're deleting the channel so do you need to change channel permissions?

#

if you say so

#

I would personally suggest not changing it, because the channel is going to be deleted but it would be like this

#

await ctx.channel.set_permissions(ctx.guild.default_role, read_messages=False)

#

ctx.guild.default_role is the @everyone role

#

!d discord.Guild.default_role

unkempt canyonBOT
spring flax
#

it will set the View Channel permission for the @everyone role to False

#

it doesn't delete any overides, it just changes it

#

you can delete overwrites too if you want though

#

are you an admin?

#

that permission is for you

#

not the @everyone role

buoyant zodiac
#

how can i make it so it says like 5th or 2nd or 3rd

spring flax
#

what do you mean nothing

#

show the code

smoky anvil
#

Someone who can help me with discord bot requirements? tag me when anser. Thanks

buoyant zodiac
unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

spring flax
#

that is an inefficient way to do this.
Consider using this.


@nextcord.ui.button(label="Yes", style=nextcord.ButtonStyle.green)
async def accept(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):


    seconds = 10
    msg = await ctx.send(embed=disnake.Embed(description=f'The channel will close in `{seconds}` seconds'))
    while seconds > 0:
            print(t)
            seconds -= 1
            await asyncio.sleep(1)
            await msg.edit(embed=disnake.Embed(description=f'The channel will close in `{seconds}` seconds'))

    await interaction.channel.delete()
    self.stop()
slate swan
#

is there anyway to change ip of replit?

final iron
#

Nope

echo wasp
#

Ummm I was working on a new help command that uses the class but it sends 4 times why?

slate swan
slate swan
#

everytime you get a new terminal afaik it changes the ip so you probably got a different ip

spring flax
slate swan
slate swan
# slate swan everytime you get a new terminal afaik it changes the ip so you probably got a d...

right right
whatever it was, its fixed now
and
i think i know why ive got that 429error

def retrive():
   global channel_id
   req = requests.get(url + '?limit=1',headers = header)
   for value in json.loads(req.text):
     #print(value['author']['id'])
     if value['author']['id'] == '701802881962999918':     
       if value['content'] == "$hourly":
         hourly()
       if value['content'] == "$giveaway":
         others(cmd='comfirmed!', iurl= url)
         giveaway()
       if value['content'] == "$online":
         others(cmd= 'bot is online', iurl= url)
       if value['content'] == "$uptime":
         others(cmd= time.process_time() - start,iurl = url)
       if value['content'] == "$bcc":
         bcc()
       if value['content'] == "$rob":
         rob()
       if value['content'] == "$cnlid":        
         others(cmd= f'act channel is {channel_id}',iurl= url)
       if value['content'][0:7] == "$setcnl":
         channel_id = value['content'][8:]
         requests.post(url, data={"content":'confirmed!'}, headers = header)
         genurl()
     
         
 #hourly()  
 #schedules
 #schedule.every(5).seconds.do(others, cmd='ridan')  
 #schedule.every(70).seconds.do(others,cmd='!afzaiesh')
 #schedule.every(2).seconds.do(retrive)
 schedule.every(11).minutes.do(rob)
 schedule.every(61).minutes.do(hourly)
 schedule.every(61).minutes.do(giveaway)
 schedule.every(13).hours.do(others, cmd='!kheirie', iurl=url)  
 #------------others-----------------#
 schedule.every(10).minutes.do(bcc)
 
 #inf-loop
 while True:
     schedule.run_pending()
     time.sleep(1)#second counter
except Exception as e:
 print(e,'error occured')
 others(cmd=e,iurl=url)
 raise

it was the only way that i could think about

#

and the reason i got rate limited
how i can send data to server?
in a cleaner wayhemlock

echo wasp
#

Ummm I was working on a new help command that uses the class but it sends 4 times why? And it is the one from the pin

echo wasp
#

It sends the help 4 times

#

Using that directly

pure sparrow
#

hi guys Im searching for a program to add a role when a user has a certain custom statut, there are a lot of tutos on js but not on python... thank you

maiden fable
#

!d discord.Member.activity

unkempt canyonBOT
#

property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
maiden fable
#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

x == y Checks if two activities are equal.

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

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
maiden fable
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
pure sparrow
#

oh thank you so much appreciate it

maiden fable
#

All cool

echo wasp
cloud dawn
#

I just made a bot that sends random monkey images every minute.

maiden fable
#

@echo wasp code

echo wasp
slate swan
#

ahhh

#

wrong rply

maiden fable
#

4 times......?

cloud dawn
maiden fable
#

Oh wow what a coincidence

maiden fable
echo wasp
maiden fable
#

I meant of the help command

#

Weird, u have an on_message with an event deco?

slate swan
maiden fable
#

I, uhhhh

daring olive
maiden fable
#

Lmao

#

mina, u didn't get it. The bot scrapes NFT websites and sends those after processing and seeing if they are monkey NFTs

maiden fable
#

smh I will just go away finalizing sound effects

slate swan
#

good good

modern fiber
#

I know it's not ctx, but what is it then?

#

Still says wrong when I do guild.member_count

thin kelp
#

try doing member.guild.member_count

slate swan
modern fiber
final iron
unkempt canyonBOT
final iron
#

I would test it yourself first

slate swan
#

xd

fleet charm
#

t!profile

dull terrace
#

visual effects on different guilds are donee 🥳

slim ibex
#

fire

pure sparrow
dull terrace
cloud dawn
daring olive
#

ikr :(

#

what framework are you on panda

cloud dawn
#

A friend of mine requested monke

cloud dawn
daring olive
#

i started on disnake and tried to move to dpy today
i've not figured out the slash commands and stuff

cloud dawn
pliant gulch
#

I still firmly believe that slash commands was a mistake

daring olive
#

lolol, how come?

pliant gulch
#

discord says it's made to be easier for the regular user, but that is barely true. At least with all the rules it has

#

And my main point would be the power that regular "commands" have

daring olive
#

idk if it's in my head but every bot i've used with slash commands there's like the slighest of delays/lag

pliant gulch
#

Slash commands just aren't ready yet

cloud dawn
daring olive
pliant gulch
#

Disnake could've used Annotated instead of Param tbh

#

!d typing.Annotated

unkempt canyonBOT
cloud dawn
daring olive
#

can i do that in dpy?

sick birch
#

It's more like a list than anything

cloud dawn
# daring olive can i do that in dpy?

Not sure, i haven't really looked at dpy slash command implementation since it's fairly new and no one has asked. Dpy is just a bit behind Disnake atm.

sick birch
#

I've done a slash commands with d.py, none with the forks so I can't really tell if it's behind :p

daring olive
sick birch
daring olive
#

yeah.. saw those gists lol

sick birch
#

2.0 docs does have the classes, attributes, functions, etc but no real examples or explanations as to why and how one should use it

proud rain
#

why is my buttons not being send?

@Client.command()
async def button(ctx):
    await ctx.send(
        "",
        components = [
            Button(style=ButtonStyle.red, label = 'test!') 
        ]
    )
    interaction = await Client.wait_for("button_click", check=lambda i: i.component.label.startswith(""))
    await interaction.respond(content="test")```
pliant gulch
#

source dive

sick birch
# pliant gulch source dive

Yeah that was one of my strategies on working up some examples, but I don't think many people would want to source dive just to figure out how something works

slate swan
# daring olive i started on disnake and tried to move to dpy today i've not figured out the sla...

tbh i wouldn't change to dpy. danny archived the repo and then criticized forks for there implementation or making dpy "worst" and then saying he didnt like them but it was mainly his fault for leaving the community like that, he said he tried to find a maintaner but never found one i find that very weird in my part and then he came back after 6 months of chaos, while forks will continue development, which in my part i dont trust danny maintaining the lib anymore, why exactly? he sent many gists on how he maybe wouldnt comeback because he didnt had the time etc but then after 6 months he sent a gist going against all his claims before that and i wouldnt doubt the lib being archived again.

pliant gulch
#

Just maintain your own wrapper at this point

#

(joke)

daring olive
#

yeah i'm aware of all the backstory

#

none of my discord bot writing is for any real use

slate swan
daring olive
#

just for fun/learning and no one is gonna use it

pliant gulch
#

The timing for the disnake port was crazy though lmao

daring olive
#

yes lol

pliant gulch
#

but if I start it again, I'll b starting from scratch

#

This time I'll do some websockets with TCP or something

#

(Yea, I know, crazy)

slate swan
slate swan
#

a coroutine*

proud rain
#

which line

pliant gulch
slate swan
proud rain
#
@Client.command()
async def button(ctx):
    await ctx.send(
        "",
        components = [
            Button(style=ButtonStyle.red, label = 'test!') 
        ]
    )
    interaction = await Client.wait_for("button_click", check=lambda i: i.component.label.startswith(""))
    await response.send_message('Hello')```

like this?
slate swan
#

why not use main or a fork and not that trash third party lib

#

i hate how you have to wait for a button click in that trash libworksonmymachine

proud rain
#

i dont know what your meaning, im trying my best!

slim ibex
#

e

slate swan
pliant gulch
#

Just fork rin and finish it

#

I got like 20% finished for you

slate swan
#

mhmwickedcat

#

good idea that would be fun sniff

proud rain
#

still doent send

slate swan
#

for websockets?

pliant gulch
#

No lol that's old asf

slate swan
pliant gulch
#

aiohttp websockets

#

but that isn't what keepalive is for

slate swan
#

alright ill look into it

pliant gulch
#

keepalive is simply for sending heartbeats

slate swan
pliant gulch
#

Making a thread like that is kind of just useless, you can get rid of it and make a task

slate swan
pliant gulch
#

You connect with aiohttp, send your identify payload with your authorisation data

slate swan
#

and connect to the websocket?

pliant gulch
#

Hearbeats just let the gateway know your are still there

pliant gulch
slate swan
#

anyways ima watch the new batman movie see ya thx andyghostwave

pliant gulch
#

mid

slate swan
sick birch
pliant gulch
#

!d aiohttp.ClientSession.ws_connect

unkempt canyonBOT
#
coroutine async-with ws_connect(url, *, method='GET', protocols=(), timeout=10.0, receive_timeout=None, auth=None, autoclose=True, autoping=True, heartbeat=None, origin=None, ...)```
Create a websocket connection. Returns a [`ClientWebSocketResponse`](https://aiohttp.readthedocs.io/en/stable/client_reference.html#aiohttp.ClientWebSocketResponse "aiohttp.ClientWebSocketResponse") object.
slate swan
slate swan
#

why it doesn't work ?

sick birch
sick birch
#

Client has no sense for a "command". If you have a commands.Bot named as client, you should change it

slate swan
#

oh yeha

#

i'm stupid my bad

#

still doesn't work

#

ohhh

#

wait

#

type hint amount to an int

#

so amount: int = 10

#

you mean I should change client.command() to bot.command() @sick birch?

#

he means to rename your bot instance yes

#

but rn thats not the problem its just naming

#

still doesn't work, here's the code

slate swan
#

no

slate swan
sick birch
slate swan
sick birch
#

Ah your on_message

#

You need to:
A) Use a listener as opposed to an event
B) Append bot.process_commands(message) to your on_message

#

Also you shouldn't be changing presence in on_ready

slate swan
#

they should remove event deco tbh

sick birch
#

rather pass it on to your bot instance

sick birch
slate swan
sick birch
#

Ignoring certain users, channels, guilds, etc

#

I know they can be done with a check but having multiple ways is always nice

slate swan
#

nah nah

#

i ment the deco

slate swan
#

listeners are better than events imo

sick birch
#

Ah well for the "features" i mentioned above we need an on_message event

sick birch
slate swan
sick birch
#

Yes, but then you can't really ignore certain commands

slate swan
#

which you can set a name as well

sick birch
#

Using listeners I mean

#
@bot.event
async def on_message(m):
  if m.author.bot: return

  await bot.process_commands(m)

for example

#

That's not really possible with a listener

slate swan
sick birch
slate swan
sick birch
#

Both will work

sick birch
slate swan
#

nah nvm that i didnt quite see the return statement

#

and why have an extra line which is taken by a useless coroutine?

manic wing
sick birch
#

Yeah true, a check works as well

sick birch
slate swan
#

my point tbh is it just causes more confusion and problems for beginners

#

like this?

slate swan
unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
slate swan
#

and remove process commands coro

#

I don't understand why you guys are changing this if its working

#

it will make >clear work )

dull terrace
#

this was a pain in the ass to get working right

manic wing
dull terrace
#

thanks, just gotta get it to save properly now

#

maybe change the text color so it doesn't clash with the gui

slate swan
slate swan
dull terrace
#

i just thought of another thing i need to add, i swear this bot will never be done

cold sonnet
#

that's the good part!

cold sonnet
cold sonnet
#

because of the for loop

#

or sometimes you don't even process commands

#

so that's why okimii told u to use listen() instead

slate swan
#

but idk where to add listen()

cold sonnet
#

above async def on_message(message):, you have @bot.event, right?

#

yeah you do

junior verge
#

How do you make a command like .steal sad, if you do a emoji from a other server that it will 'steal' the emoji and add it

cold sonnet
#

I just didn't look at the picture again

#

replace @bot.event with @bot.listen()

#

smth like this

slate swan
#

like this

#

?

cold sonnet
#

like that

slate swan
#

it will make my clear command work ?

cold sonnet
#

yes

#

because it doesn't override the default on_message now

#

the default on_message in the src code which calls your commands stays and does its work

#

😀

slate swan
#

BRO

#

YOU'RE A MASTER !!!!!!!!!!!!!!

cold sonnet
#

no I'm meh

slate swan
#

I'VE BEEN STUCK FOR HOURS ON THIS

cold sonnet
#

feels great to finally solve it innit

dull terrace
#
int(guild_rank[player.guild][2].split(f",{buid}")[-2].split(f"/{buid}")[1])```
you ever just look at some pieces of dumb code and
cold sonnet
#

you split by a whole var

#

is buid a sentence

#

it would be really cool if buid was like a damn whole sentence

#

I can again

dull terrace
#

buid is 4 unique characters 😓

#

the whole thing gets one number as a result that's either 0,1,2

#

it works though so im never touching it again

slate swan
slate swan
cold sonnet
#

skill gap

pure sparrow
#

bruh I forgot a ","

hoary cargo
pure sparrow
cold sonnet
#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

pure sparrow
hoary cargo
#

🗿 bro i don't like french

pure sparrow
#

idc

hoary cargo
#

ban

pure sparrow
#

ok

pure sparrow
unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

slate swan
#

can you guys stop?

pure sparrow
#

sure

hoary cargo
# pure sparrow !rule 4

how rule 4 applies on my message 🗿 man shut up pls before i start saying something bad about french people

hoary cargo
hybrid mural
#

hey @slate swan considering this code what would be the best way to figure out what button was pressed? ```py
for i in range(3):
for j in range(3):
v.add_item(item=buttons[i][j])
await ctx.send(view=v)

maiden fable
#

button.callback

#

!d discord.ui.Button.callback

unkempt canyonBOT
#

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

The callback associated with this UI item.

This can be overridden by subclasses.
slate swan
hybrid mural
#

and when does an interaction happen? Do i have to wait for some kind of interaction?

sick birch
sick birch
slate swan
#

im getting error: Command raised an exception: TypeError: string indices must be integers

hybrid mural
#

with some function or something

slate swan
#
data = req.json()
    manz = '\n'.join([result['checks'] for result in data['limits']])
    await ctx.send(int(manz))```
#

im getting error: Command raised an exception: TypeError: string indices must be integers

slim ibex
#

what is result and data

slate swan
#

],
"limits":{
"checks":999997,
"keyword":999999
}
}

hybrid mural
#

result["limits"]["checks"] isnt it?

slim ibex
#

doesn't seem like your obj structure matches what you are trying to do

slate swan
#

wdym

slim ibex
#

i'm guessing that that whole dict or whatever structure it is is named data

slate swan
#

yes

slim ibex
#

lemme test somethng rq

#

!e

a = {
  "foo": {
    "bar": "baz",
    "other": "other2"
  }
}

print([v["bar"] for v in a["foo"]])
unkempt canyonBOT
#

@slim ibex :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 8, in <module>
003 |   File "<string>", line 8, in <listcomp>
004 | TypeError: string indices must be integers
slim ibex
#

ok so

slate swan
#

yes

#

thats same error i get

sick birch
slim ibex
#

so the issue is with result["checks"]

#

!e

a = {
  "foo": {
    "bar": "baz",
    "other": "other2"
  }
}

print([k for k in a["foo"]])
unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

['bar', 'other']
hybrid mural
slim ibex
#

the value of it?

slate swan
#

lets just say baz is 85843

slim ibex
#

ok

slate swan
#

the 85843 is what i need

unkempt canyonBOT
#

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

['baz', 'other2']
slim ibex
#

was about to do that

#

forgor the function

slate swan
slim ibex
#

?

slate swan
#

nvm

slim ibex
#

you were trying to slice the expression in the list comp

slate swan
#

!e
py "limits": { "checks":999997, "keyword":999999 } } print([v for v in limits["checks"].values()])

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     "limits":  { 
003 |     ^^^^^^^^
004 | SyntaxError: illegal target for annotation
slim ibex
#

^

#

a doesn't even exist here

slate swan
#

o mb

#

!e

"limits": {
"checks":999997,
"keyword":999999
}
}
print([v for v in limits["checks"].values()])

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     "limits": { 
003 |     ^^^^^^^^
004 | SyntaxError: illegal target for annotation
cold sonnet
#

what was the point of doing it twice

slate swan