#discord-bots

1 messages · Page 318 of 1

final iron
#

Send to the channel?

latent jay
final iron
#

!d discord.Interaction.channel

unkempt canyonBOT
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. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, 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

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

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

potent arrow
#

Is it possible to do context menu commands in a separate file then call them in main?

potent arrow
#

I want to try and clean up my code as to not have it all in one file

latent jay
#
command_list = [(command.name, command.help) for command in client.commands]

displaying only one command although I have multiple?

glad cradle
#

are they application commands?

#

why everyone call a Bot instance "client"

shrewd fjord
latent jay
shrewd fjord
#

Also instead its preferred to use command.qualified_name instead of name

young dagger
#

Is there any way to delete the message without having to await?

dm_message = client.get_partial_messageable(channel_id).get_partial_message(message_id) 
await dm_message.delete()```
vale wing
young dagger
vale wing
#

Wdyem "remove dm"

#

Delete message?

young dagger
#

Then await delete to actually delete the DM

vale wing
#

Yeah that is a message

#

You need to do it without await or what

young dagger
#

Is this the way you would do it?

vale wing
#

create_task yeah

young dagger
#

Also why do we need a channel id to remove a DM? Why is it not enough with just the message id?

vale wing
#

I assume it's either message ids are not globally unique or global lookup is way too expensive

slate swan
#

can i pay someone to make me a discord bot

vale wing
unkempt canyonBOT
#

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

slate swan
#

Why can’t i

young dagger
#

Because now we must save both channel id and message id

vale wing
#

I think url already contains channel id and message id

young dagger
#

Right

#

So why not just use the url to remove the DM

vale wing
#

So you ain't saving space, quite the opposite

shrewd fjord
#

But you have to fetch the message anyway

shrewd fjord
#

Nothing

young dagger
shrewd fjord
#

It doesn't fetch any message

#

Thats what partial does, it does not require make http request to get anu resource, it builds a partial class of actual class

#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
shrewd fjord
#

!d discord.PartialMessage

unkempt canyonBOT
#

class discord.PartialMessage(*, channel, id)```
Represents a partial message to aid with working messages when only a message and channel ID are present.

There are two ways to construct this class. The first one is through the constructor itself, and the second is via the following...
slate swan
#

!d

shrewd fjord
#

One can be constructed by requesting to discord api only, and other one you can construct it

slate swan
#

!d

unkempt canyonBOT
shrewd fjord
#

#bot-commands

#

Please keep this channel clean

slate swan
#

why can’t i pay someone to make me a bot here

shrewd fjord
#

Its against discord TOS but people are doing it anyway like me kek

young dagger
glad cradle
#

!d discord.app_commands.CommandTree.walk_commands

unkempt canyonBOT
glad cradle
#

and you get the tree using

#

!d discord.ext.commands.Bot.tree

unkempt canyonBOT
#

property tree```
The command tree responsible for handling the application commands in this bot.

New in version 2.0.
glad cradle
#

at least that's what i found, never tried it directly

idle lantern
slate swan
#

I Have this ticket system, but the close button like after 10 mins expires

slate swan
#

`node index.js
node:internal/errors:464
ErrorCaptureStackTrace(err);
^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:371:5)
at defaultResolve (node:internal/modules/esm/resolve:1016:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/esm/translators:111:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at file:///C:register-commands.js:13:19
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME`

how to fix this error plz help

#

@shrewd fjord

slate swan
slate swan
young dagger
next heath
#

Yo can someone help me whit on_member_joind it dosent send or react to the event what can the problem be?
Code:

@client.event
async def on_memmber_joind(member):
    await print("1")
    #role = client.get_guild(676446095739453450).get_roles(1146014701575221268)
    channel = client.get_guild(676446095739453450).get_channel(1146014701575221268)
    
    embed=discord.Embed(title=f"Welcome to Rash", description=f"Welcome {member.mention} Make sure to read [#719174215961542697](/guild/267624335836053506/channel/719174215961542697/) and [#719174187188748299](/guild/267624335836053506/channel/719174187188748299/)", url=f"{member.avatar_url}", color=0x000000)
    embed.set_author(name=f"{member.name}", icon_url=f"{member.avatar.url}")
    embed.set_footer(text="Joined at")
    embed.timestamp = datetime.datetime.utcnow()
    
    await channel.send(embed=embed)
    #await member.add_roles(role)
    await print("2")```
slate swan
#

Look at the event name function again

#

And double check you have the intent enabled afterwards

next heath
#

Oh... 🤣

slate swan
#

you dont await the print ...

robust fulcrum
next heath
#

Just brain error 🤣

dreamy trench
#

Hi, I need to make a quick script that send a notification on discord when a build has completed. I have achived sending messages to our builds channel with the attached code. Now I need to do this inside a function that can be called from another script?

bot = commands.Bot(command_prefix='\\', intents=discord.Intents.all())

@bot.event
async def on_ready():
    print("Bot is ready!")
    channel = bot.get_channel(BUILDS_CHANNEL_ID)
    await channel.send("Hello World!")

bot.run(token=TOKEN)

def Notify(notification):
  ...?

final iron
dreamy trench
#

Send a notification/ I found another solution using webhooks that works better :)

winter hare
#

so i have this wiithin my modal class


        async def on_submit(self, interaction: discord.Interaction):
            embed = interaction.message.embeds[0]
            if self.ftext:
                embed.set_footer(text=self.ftext.value, icon_url=self.fticon.value)

            if self.time.value.lower() == "yes":
                embed.timestamp = datetime.now()
            else:
                embed.timestamp = None

            await interaction.message.edit(embed=embed)
            await interaction.response.send_message()```

when i removed the last line of code the embed edited but the modal said interaction failed is there a way to edit the embed without having to send a message
final iron
unkempt canyonBOT
#

await edit_message(*, content=..., embed=..., embeds=..., attachments=..., view=..., allowed_mentions=..., delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by editing the original message of a component or modal interaction.
winter hare
runic hemlock
#

does anyone know how to include graphics in discord bots

fading marlin
#

Could you elaborate? Do you mean buttons/drop down menus?

final iron
vocal rivet
#

How can I check when a member's given a timeout and who gave them the timeout?

final iron
unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

final iron
unkempt canyonBOT
#

discord.on_audit_log_entry_create(entry)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild) gets a new audit log entry. You must have [`view_audit_log`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.view_audit_log) to receive this.

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

New in version 2.2.

Warning

Audit log entries received through the gateway are subject to data retrieval from cache rather than REST. This means that some data might not be present when you expect it to be. For example, the [`AuditLogEntry.target`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AuditLogEntry.target) attribute will usually be a [`discord.Object`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Object) and the [`AuditLogEntry.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AuditLogEntry.user) attribute will depend on user and member cache.

To get the user ID of entry, [`AuditLogEntry.user_id`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AuditLogEntry.user_id) can be used instead.
vocal rivet
vocal rivet
#

There's something called "automod_timeout_member" but that's not what I'm looking for

final iron
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) updates their profile.

This is called when one or more of the following things change...
vocal rivet
#

Yeah that's what I was bouta say

final iron
#

You can use that to see when a member is timed out

#

Then you’ll have to query the audit log to see who did it

vocal rivet
#

Can I also see who timed them out?

vocal rivet
#

Why's this so complicated

final iron
#

Discord being discord

slate swan
#

How do I get started making a Discord bot?

final iron
#

And DON'T follow ANY Youtube tutorials

#

I have yet to see 1 that doesn't have issues

latent jay
final iron
#

!paste

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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

latent jay
#
client = commands.Bot(etc..)
tree = client.tree
shrewd fjord
#

Name it bot in the first place dead

latent jay
shrewd fjord
#

!d discord.app_commands.CommandTree.command

unkempt canyonBOT
#

@command(*, name=..., description=..., nsfw=False, guild=..., guilds=..., auto_locale_strings=True, extras=...)```
A decorator that creates an application command from a regular function directly under this tree.
shrewd fjord
#

Huh

shrewd fjord
latent jay
#

pretty sure I tried that and it returned an empty list

shrewd fjord
#

It will be client.tree to get all app commands

shrewd fjord
latent jay
#

tree already is client.tree so I could just do tree.walk_commands() no?

shrewd fjord
#

How many commands do you have anyway and do they show up in the discord? Also use command.qualified_name

latent jay
#

and yes I sync them before

elder locust
#

ok I'm embarrassed. I can't get this command to work and I don't understand why, been a long time since I used discord.py

#
import discord, asyncio
from discord import app_commands
from discord.ext import commands

bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())


@bot.tree.command(name="hello", description="My first application Command")
async def hello(interaction: discord.Interaction):
    await interaction.response.send_message("Hello!")


@bot.command(name="ping")
async def ping(ctx):
    await ctx.send("pong")


@bot.event
async def on_ready():
    for guild in bot.guilds:
        await bot.tree.sync(guild=discord.Object(id=guild.id))


bot.run("*")
#

/ping works fine but when i do /hello I get discord.ext.commands.errors.CommandNotFound: Command "hello" is not found

latent jay
shrewd fjord
elder locust
#

that's whats happening in on_ready() right?

shrewd fjord
latent jay
shrewd fjord
#

Uh weird, i will get to you kater

latent jay
#

yeah Idk why it's doing it either

shrewd fjord
#

!d discord.app_commands.CommandTree.walk_commands

unkempt canyonBOT
shrewd fjord
#

@latent jay walk_commands(guild=ctx.guild)

latent jay
#

you can't use ctx in an interaction?

shrewd fjord
#

then use interaction.guild shrug

latent jay
#

yeah that worked

#

why does guild need to be included I am confused

shrewd fjord
#

Nice

shrewd fjord
latent jay
#

so to sync globally?

shrewd fjord
#

just do not pass guild=... In your command deco and just call sync() where you sync ur cmds

latent jay
#

but that's what I was doing before where it'd only return an empty list?

elder locust
shrewd fjord
#

I said command decorator,
@tree.command(..., guild=...)

elder locust
#

where do I put it other than on_ready though so I dont have to do a command everytime it boots up

latent jay
unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready) event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for) and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready)...
potent light
hallow kernel
#
import discord
bot = discord.Client(intents=discord.Intents())
@bot.event
async def on_ready():
    user = await bot.fetch_user("curome")
    print(user.avatar_url)
    await bot.close()
bot.run("token")

So.. it is one of solutions.
Actually what i need is skript that will print my avatar url to stdout.
Is there any faster + lighter ways.. like single request with curl?

naive briar
#

Me when people call discord.Client "bot" and use a string on fetch_user 🫠

naive briar
#

Probably should've suppress those embeds

naive briar
#

You should be able to adjust the sizes

hallow kernel
naive briar
#

The returned size can be changed by appending a querystring of ?size=desired_size to the URL. Image size can be any power of two between 16 and 4096.

naive briar
hallow kernel
#

Um, default still will work, i mean, default is ok to use as pfp on other platforms?

brazen raft
# potent light If you override it as an event it'll run automatically when the bot goes online:...

Called when the client is done preparing the data received from Discord. Usually after login is successful and the Client.guilds and co. are filled up.
WARNING: This function is not guaranteed to be the first event called. Likewise, this function is not guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.

await setup_hook()

A coroutine to be called to setup the bot, by default this is blank.
...
This is only called once, in login(), and will be called before any events are dispatched, making it a better solution than doing such setup in the on_ready() event.

sacred wolf
#

Simple ticket discord

hollow zinc
#

Probably. Can you switch that to the glob.glob

golden portal
#

well you should try it first, im pretty much eating right now because that was sent before i was eating

final iron
sacred wolf
#

ticket bot discord for example give me 😐

hollow zinc
fiery girder
fiery girder
golden portal
unkempt canyonBOT
#

glob.glob(pathname, *, root_dir=None, dir_fd=None, recursive=False, include_hidden=False)```
Return a possibly empty list of path names that match *pathname*, which must be a string containing a path specification. *pathname* can be either absolute (like `/usr/src/Python-1.5/Makefile`) or relative (like `../../Tools/*/*.gif`), and can contain shell-style wildcards. Broken symlinks are included in the results (as in the shell). Whether or not the results are sorted depends on the file system. If a file that satisfies conditions is removed or added during the call of this function, whether a path name for that file will be included is unspecified.
vale wing
#

!d pathlib.Path.glob also

unkempt canyonBOT
#

Path.glob(pattern, *, case_sensitive=None)```
Glob the given relative *pattern* in the directory represented by this path, yielding all matching files (of any kind):

```py
>>> sorted(Path('.').glob('*.py'))
[PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib.py')]
>>> sorted(Path('.').glob('*/*.py'))
[PosixPath('docs/conf.py')]
```  Patterns are the same as for [`fnmatch`](https://docs.python.org/3/library/fnmatch.html#module-fnmatch), with the addition of “`**`” which means “this directory and all subdirectories, recursively”. In other words, it enables recursive globbing...
hollow zinc
#

Amm how do i use it in my code?

naive briar
#

Like any other code that uses it

fiery girder
#

hey can someone help me with setting up custom prefix for all indivisual servers

naive briar
#

You need to learn to mix things on your own sometimes

#

!e

from glob import glob

print(*glob("../*"), sep="\n")
unkempt canyonBOT
#

@naive briar :white_check_mark: Your 3.12 eval job has completed with return code 0.

001 | ../home
002 | ../dev
003 | ../lang
004 | ../usr
005 | ../snekbox
006 | ../lib64
007 | ../lib
008 | ../etc
fiery girder
#

catlover you know about how to setup custopm prefix?

#

for every server

#

i am using a .db file btw

naive briar
#

!d discord.ext.commands.Bot the command_prefix argument can be set to a coroutine(I believe). You just want to process the things with the coroutine and return a string that will be the prefix

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

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

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

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
fiery girder
naive briar
#

What's the problem?

fiery girder
#

idk my self lol it dont give any error

#

code

#

i also trying () but it gave error cause i didnt put in the message id and this way it worked somehow idk how to fix this thing

tiny ibex
#
c:\Users\ASUS\OneDrive\Desktop\Tindbot\main.py:17: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  bot.load_extension('jishaku')```Can someone tell what's wrong?
fiery girder
#

it was not awaited

#

use await bot.load_extension

#
await bot.load_extension("jishaku")
tiny ibex
fiery girder
#

await before function

tiny ibex
# fiery girder just like this
  File "c:\Users\ASUS\OneDrive\Desktop\Tindbot\main.py", line 20
    await bot.load_extension('jishaku')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'await' outside function

[Done] exited with code=1 in 0.391 seconds```
fiery girder
#

huh

#

did you forget to leave indentation

#

await can only be in async def function

tiny ibex
fiery girder
#

just put it in on_ready

tiny ibex
fiery girder
#

the bot.load_extension

tiny ibex
#

My old bots never required that

fiery girder
#

do

async def on_ready():
      print(f"Logged In As {bot.user}")
      await bot.load_extension()
fiery girder
#

it worked?

tiny ibex
#

But why won't it work without the function

tiny ibex
fiery girder
#

cause you need to await the function

#

coruntine it

tiny ibex
fiery girder
#

prob a new discord bot feature i dont really know i started like a few months ago

tiny ibex
#

I am coding after an year so I don't know much

fiery girder
#

yea it happens i guess

#

ok seeya gotta work on my bot

tiny ibex
#

can anyone pls give me an example of a slah command

fiery girder
#

sure

#
@bot.hybrid_command(name="ping", description="Get the bot's ping.")
@commands.has_permissions(administrator=True)
async def ping(ctx):
    await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")

fiery girder
#

can anyone get this error cause i got get it

#

the code

golden portal
fiery girder
#

so i should use async def get_prefix?

golden portal
#

yes

fiery girder
#

ok lemme try it

golden portal
#

tbf the proper way is to give a callable to command_prefix of Bot rather than directly override get_prefix

#

but it's whatev

fiery girder
golden portal
# fiery girder i tried it but coudnt get it done

something like this should be fine ```py
class Bot(commands.Bot):
def init(self):
super().init(self.get_bot_prefix, ...)

def get_bot_prefix(self, bot, message):
    ...
the argument for the callback takes in bot and a message object
fiery girder
#

a new error

golden portal
#

!e ```py
a = ('a', )
print(a[1])

unkempt canyonBOT
#

@golden portal :x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 2, in <module>
003 |     print(a[1])
004 |           ~^^^
005 | IndexError: tuple index out of range
golden portal
#

that's pretty much the error, you did fetchone and then proceeded to try to get the second element

fiery girder
#

first its not a tuple

#

but fetchone gives a whole list

#

the whole row

#

it should give all of that

#

so guild id should be 0

golden portal
#

!d sqlite3.Cursor.fetchone

unkempt canyonBOT
#

fetchone()```
If [`row_factory`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.row_factory) is `None`, return the next row query result set as a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple). Else, pass it to the row factory and return its result. Return `None` if no more data is available.
fiery girder
#

@golden portal and its also SELECT all

#
    db.execute("SELECT * FROM guild WHERE guild_id = ?", (message.guild.id,))
golden portal
#

error says otherwise

#

im not denying, i'm simply telling you the error

fiery girder
#

it was working like 5 mins ago

#

just when i put it the main_db.commit() it stopped working

golden portal
#

seriously, just please print your prefix so you can debug it

fiery girder
#

good idea

#

wanna know a life hack? @golden portal

golden portal
#

sure?

fiery girder
#

if you want to think about anything any problem just go to the freaking bathroom and take a Sh*t you will find the solution

golden portal
#

eh i usually take a shower if im stuck at programming, it does help with thinking

fiery girder
#

just go to the bathroom and do anything lol

#

it works

golden portal
#

understandable, anyways that's kinda off topic

fiery girder
#

tbh yea but i got the prefix problem fixed i think but i cant get the setup freaking working

#

@golden portal aperantly the on_message is not working

golden portal
#

just send the code here with the problem desc someone will help\

fiery girder
#

i set it that on_message it just prints the message and its not printing anything

#

ah fk

#

i am stupid as fk

#

i didnt do @bot.listen

slate swan
#

Any Bot Dev Dm Ineed 1 Bot Paid

#

+×+

slate swan
unkempt canyonBOT
#

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

slate swan
young kernel
#

I have a question. If I have to keep a discord bot alive 24/7 for simple tasks and not that much traffic on a raspberry pi 4. Do I need a ice tower cooling or a case with cooling fan would be okay

hushed galleon
young kernel
hushed galleon
#

(though i found out recently that the 64-bit OS allowed pip to install their precompiled wheels, so that stopped being an annoyance)

brazen geyser
#

hey guys, can someone tell me whats the difference between @discord.ui.Button and @discord.ui.button

slate swan
brazen geyser
slate swan
brazen geyser
slate swan
#
class CustomButton(discord.ui.Button):
    def __init__(self, ...):
        # do startup stuff
    async def callback(self, ...):
        # do stuff

is the same as ```py

@discord.ui.button(...)
async def somename(...):
# do stuff

#

for example with just @button you cant really have dynamic button name and another properties

brazen geyser
#

now i have thiss

slate swan
#

well thats not really how it works

brazen geyser
#

i know, its working on another button

slate swan
brazen geyser
slate swan
#

you have to do self.add_item(Button(..., url="someurl"))

brazen geyser
#

can I send you the whole code?

slate swan
#

sure

brazen geyser
#

!paste

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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

brazen geyser
#

here it is

slate swan
#

yeah so

#

in __init__ method

#

you need to add this self.add_item(Button(label="something", style=..., url="your url to jump to"))

brazen geyser
#

now just Button isnt defined

#

so just add

slate swan
#

import it from discord.ui

brazen geyser
#

Button: discord.Button to __init__

slate swan
#

?

#

no on top add import

#

from discord.ui import Button

brazen geyser
#

ohh have it

#

and now whatt?

slate swan
#

what have you done so far

brazen geyser
#

imported Button, added item

slate swan
#

well jumptosuggestionurl isnt really a url

brazen geyser
#

its this

slate swan
#

you need actual url to message like [#discord-bots message](/guild/267624335836053506/channel/343944376055103488/)

brazen geyser
#

or it cant be like this?

slate swan
#

pass it to the __init__

#

def __init__(self, url) like so

#

then pass url to url in button

brazen geyser
#

like this?

slate swan
#

yeah but now

#

when creating the view you need to pass that url

#

in your case: await suggestlog.send(embed=approval, view = ApprovalSystem()) this line

brazen geyser
#

yeaa

slate swan
#

you are creating view, just add await suggestlog.send(embed=approval, view = ApprovalSystem("some cool url"))

brazen geyser
#

and can it be that suggmsg.jump_url?

slate swan
#

i would say it should be

brazen geyser
#

okay, have it

#

anything else?

slate swan
#

well i suggest you do that for each param instead of doing ApprovalSystem.something = something

brazen geyser
#

and rewrite all buttons to Buttons?

slate swan
#
class X:
    something = None

    def method(self):
        print(self.something)
``` instead do this ```py
class X:
    def __init__(self, something):
        self.something = something

    def method(self):
        print(self.something)
slate swan
brazen geyser
slate swan
#

imagine 2 users run the command at the same time

brazen geyser
slate swan
#

the variable values will override

#

with your idea

brazen geyser
#

ohhh

slate swan
brazen geyser
#

like this?

slate swan
#

!e ```py
class X:
something = None

def method(self):
    print(self.something)

x = X()
X.something = 123

y = X()
X.something = 456

x.method()
y.method()

#

ah cause i edited it for instance

unkempt canyonBOT
#

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

001 | 456
002 | 456
slate swan
#

see its being overriten

brazen geyser
brazen geyser
slate swan
#

!e ```py
class X:
def init(self, something):
self.something = something

def method(self):
    print(self.something)

x = X(123)
y = X(456)

x.method()
y.method()

unkempt canyonBOT
#

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

001 | 123
002 | 456
slate swan
#

with this approach you can even have 100 commands at once and it will still have correct values

brazen geyser
#

ohhhh, i understand noww

#

i have it, what nextt

slate swan
#

try out

brazen geyser
#

and can i delete this?

slate swan
#

yea

brazen geyser
#

omgg its workingg

#

and is there any way to like chance the order of that buttons?

slate swan
#

yea check out row

#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
brazen geyser
#

ohh i understand now

#

and why im adding just this as Button and leaving the rest of buttons like button?

slate swan
#

!D discord.ui.button

unkempt canyonBOT
#

@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction) you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button) being pressed.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button) manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
slate swan
#

read note from this ^

brazen geyser
#

ohh so the rest of it is just button because we dont need to pass url?

slate swan
#

callback is basically what to do when clicked

#

but since url buttons dont have callbacks they cant be created using button

brazen geyser
#

ohhhh, so that interaction.responce.restofthecode...

brazen geyser
# slate swan yea check out `row`

but now it just moves it to another row, i want to have buttons "Accept", "Deny", "Jump to suggestion" and "Delete" in this exact order

final iron
lavish harness
#

I don't know if this should be here but

  File "/home/runner/NOA/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/NOA/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1029, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/NOA/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 244, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'set' object has no attribute 'append'```
Anyone knows how to fix this? It was fine before I deleted a file and even after I replaced it it somehow still doesnt work
#

I can show the code if needed

violet pivot
#

hello does anyone can help me with a project that is using discord.py?

slate swan
slate swan
violet pivot
lavish harness
#

is there any way to like, make it work again without modifying code?

slate swan
violet pivot
slate swan
smoky cedar
#

Has anyone been able to do unit testing on a slash command? If so, how can I trigger a command if I can't manually call the method?

final iron
unkempt canyonBOT
#

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

Fetches an application command from the application.
lavish harness
final iron
#

Now the issue is, not sure how you’re going to pass the interaction arg

sick birch
#

You'll need to mock it

final iron
#

Unlike context, iirc theres no way to manually create an Interaction class

final iron
sick birch
#

The interactions object

#

If they wrote their code in a testable way (as they should) it should be pretty easy to mock and test

final iron
#

Oh, I thought you were talking about the mock package which is used to mock classes lol

sick birch
#

well yeah, you'd use the mock package to mock interactions

smoky cedar
sick birch
#

I mean, the one from unittest

#

or another mock package. doesn't really matter

smoky cedar
sick birch
slate swan
lavish harness
sick birch
#

yes

#

Sets have .add

lavish harness
#

if so, how do i make the text file that the code uses into a list?

#

using add just breaks it more

final iron
#

I wouldn’t really be using a text file for that purpose

lavish harness
final iron
#

Obviously it doesn’t get the job done if you’re having issues now lol

slate swan
#

use list built-in to convert, but yes use sqlite or something instead

lavish harness
slate swan
#

do which

cold oyster
#

@unkempt canyon

stiff flame
#

question about pycharm

#

i used
`import discord
import os

token = os.environ.get("TOKEN1")

intents = discord.Intents.all()
client = discord.Client(intents=intents)

client.run(token)in replit and pycharm. replit works but pycharm sends the following error:
discord.client: logging in using static token
...
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)')]
`

hushed galleon
#

sure, double click it

stiff flame
#

it finally work

#

i got really tired of working in replit lol

#

also i spent about 2 hours yesterday trying to make it work in pycharm

slate swan
slate swan
slate swan
maiden fable
#

The fuck is happening here

shrewd fjord
#

💀💀

#

Pin this maybe?

golden portal
#

it's already pinned

#

there is an older message

slate swan
#

There

slate swan
slate swan
#

My bot have the activity Streaming can someone help me with big image and buttons?

slate swan
#

I show you

merry cliff
#

ok

slate swan
#

Bad example

merry cliff
#

looks like custom rich presence

merry cliff
#

try this I guess

turbid condor
young dagger
#

How do you set a nickname for the bot?

vocal laurel
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

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

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

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

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) instead of `InvalidArgument`.
naive briar
unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., bypass_verification=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
naive briar
#

You can get the bot as discord.Member object from guild.me

unkempt canyonBOT
#

property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.user) except an instance of [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member). This is essentially used to get the member version of yourself.
young dagger
naive briar
vale wing
#

When the OOP

fiery girder
#

F

glad cradle
vale wing
slate swan
#

any coustom bot developer plz dm

cosmic dome
#

nice work

fiery girder
#

how can i make commands specific to a guild like i want a command that i can use to get the main database file but only i can use it on my server

golden portal
#

slash commands or text commands?

fiery girder
#

hybrid

golden portal
#

!d discord.app_commands.guilds

unkempt canyonBOT
#

@discord.app_commands.guilds(*guild_ids)```
Associates the given guilds with the command.

When the command instance is added to a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree), the guilds that are specified by this decorator become the default guilds that it’s added to rather than being a global command.

Note

Due to an implementation quirk and Python limitation, if this is used in conjunction with the [`CommandTree.command()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree.command) or [`CommandTree.context_menu()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree.context_menu) decorator then this must go below that decorator.

Example...
golden portal
#

it would register your slash only to that guild

#

for text you would have to make your own check

fiery girder
#

what about hybrid?

#

i have to do both?

golden portal
#

yes

restive talon
#

Well you can add a check. Like check the guild id of the server the command is coming from and compare it to a list of 'verified' guilds.

fiery girder
#

wait i found on on overflow

restive talon
#

Ah alright!

fiery girder
#
@tree.command(name = "sync", description="Syncs the bot commands", guild=discord.Object(id=TEST_GUILD_ID))

can i use this with hybrid?

golden portal
#

that is only for slash

idle lantern
#

in discord py is there any way to trigger an interaction using message?

golden portal
#

your hybrid deco have the kwarg

restive talon
fiery girder
idle lantern
#

im trying to trigger an event by a message but it has to be ephemeral

fiery girder
#

like what

restive talon
fiery girder
#

if you say hello it says hello back?

#

something like that??

idle lantern
#

yea but in ephemeral with an embed and buttons

restive talon
fiery girder
#

i dont get it but you can use on_message can check if the message is what you want

#

then you can perform the task

idle lantern
#

it doesnt have ephemeral property

fiery girder
#

wdym

restive talon
#

No sorry ping when replying i am not fimiliar with any way to do that. I dont believe you can send views in an emphramal message.

fiery girder
idle lantern
#

but not with a message that is on_message

#

nvm its hard to explain

fiery girder
#

bruh

#

if you want help u need to explain what u are trying to do

idle lantern
#

it is really hard to explain

#

but i think its not possible

#

ty for listening anyways

fiery girder
#

anyone wanna be my test subject?

glad cradle
final iron
idle lantern
#

Is that possible?

slate swan
#

no

final iron
idle lantern
#

Not even if the user message triggers an interactable command somehow?

#

Which is what I originally wanted to know

slate swan
#

only interactions, which are e.g. buttons, slash commands, etc.

idle lantern
#

I see

#

Thanks for that kinda already guessed that it's not possible but still wanted to ask

glad cradle
#

why do you think that adding another bot will speed up things? they're still using the same gpu

hushed galleon
#

this question seems more suited for #async-and-concurrency, but generally asyncio.create_task() is for running asynchronous functions in the background and loop.run_in_executor() (or asyncio.to_thread()) is for running sync functions; if you have to mix blocking and non-blocking code together, i would suggest only threading the parts of the code that are blocking: ```py
async def update_user_data_to_collection(...):
data = await some_network_io()
processed = await asyncio.to_thread(process_gpu_stuff(data))
await upload_to_db(processed)

task = asyncio.create_task(update_user_data_to_collection(...))

Sidenote, the task should be stored to avoid garbage collection

https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task```

shrewd fjord
hushed galleon
#

assuming your async function doesn't have code that blocks the event loop, sure

shrewd fjord
#

Either way you can start multiple same task using gather

#

Ok i just don't know the context and pulled out this 💀💀 dont scold me if its not related

harsh orbit
#

why when I add the view to this message this error happen

    button = discord.ui.Button(
        style=discord.ButtonStyle.link,
        label='🚀',
        url=link,
    )

    view = discord.ui.View(timeout=None)
    view.add_item(item=button)
    await member.send(content=message, view=view)
normal summit
#

can someone help me with a bot? i learned from a tutorial from youtube so idk if i did it correctly it only works in private messages but not on the server i added it to

slate swan
#

if anyone has experience something similar to a bot that gives out roles for reaching points, i need quick assistance #1169316527309340752 message

harsh orbit
#

why None helps here?

wise cradle
#

How to get active developer badge?
Yes i have a working bot

wise cradle
slate swan
wise cradle
#

Thanks

wise cradle
slate swan
#

Use google

slate swan
#

Such a helpful response

#

Someone tell me how to make the bot tag a user that run a specific command?

#

I forgot how

#

Like {?.user}

fading marlin
#

You're looking for the .mention property

slate swan
#

Yeah

#

member.mention?

brazen geyser
#

Hey guyss, Im making suggestion command on my Discord bot and i need help with buttons, i have channel for mods where are send all suggestions and on that message is View with four buttons and i want that if you press one, it will send message and disable all of them. Can someone please help me? I have something made, but its not working.

fading marlin
fading marlin
#

You have to respond to the interaction by editing the message. Embeds don't have an edit_message method

brazen geyser
fading marlin
#

You can either respond to the interaction ephemerally first and then call Interaction.edit_original_response to edit the message with your new view, or respond by editing the message first and sending a non-ephemeral message later on

brazen geyser
#

ohh so when i want to make that ephemeral i should to the first thing

fading marlin
#

Yeah

#

You can still do it that way if you don't want to make it ephemerally though. The order doesn't really matter if you don't care about it being ephemeral

shrewd vapor
#

Heyo

#

You know how to put this and how to continue it working after restarting the bot ?

fading marlin
slate swan
shrewd fjord
#

Technically how many slash commands you can make?

#

1 command can have 25 sub commands which is equals to 1 slash command by discord so we can have 100 max.. then 100*25 = 2500 but what about subcommand's subcommand 💀💀

final iron
shrewd fjord
#

They can? bruh_stare

#

it like
/parent sub1 sub2 [options]

final iron
#

Pretty sure that’s not possible

#

I haven’t seen any implementations, and I don’t really see how nesting the classes would work

#

I don’t really understand the point of the issue you sent either. It’s about a different topic

shrewd fjord
final iron
#

It is possible

#

There’s a parent kwarg in app_commands.Group that allows you to set the parent group

#

Mb

shrewd fjord
#

Yeah

dull fern
#

hello im making my first discord bot
i have a question, what do "async" and "@client.event" mean?

naive briar
#

And the @client.event is a decorator that marks the following function as an event of the bot

#

!d discord.Client.event

unkempt canyonBOT
#

@event```
A decorator that registers an event to listen to.

You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events).

The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) is raised.

Example

```py
@client.event
async def on_ready():
    print('Ready!')
```...
wise cradle
#

I want to know how can i add prefix to my bot
like for now it reads the messages which starts with .hi or messages like .roll
so there is no prefix for the bot rn

naive briar
#

What library are you using?

wise cradle
naive briar
wise cradle
#

yeah i saw but it didnt seem to work

naive briar
#

What about it didnt seem to work?

wise cradle
#

@client.command() async def test(ctx): await ctx.send("hello!")
This part

naive briar
#

And what's wrong with it?

wise cradle
#

the bot dosent respond to .test

viral remnant
#

yesterday my discord bot was working. but after i update my python to version10, its giving error:AttributeError: TypeError: Client.init() missing 1 required keyword-only argument: 'intents'

naive briar
unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, 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

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

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

naive briar
#

Why are you defining client but registering the command on bot?

wise cradle
#

I just said i used client 😭

naive briar
#

You shouldn't have multiple bot instances, by the way

naive briar
wise cradle
#

my bad sorry edited it

#

so is it outdated or am i doing something wrong

naive briar
#

!paste can you send the full code?

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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

wise cradle
#

yeah sure give me few mins

viral remnant
# naive briar !intents

thanks! it probably changed and i didnt update the version until yesterday, probably thats why it didnt work.

wise cradle
#

like where can i add the command thing in that

naive briar
wise cradle
#

okai thank you so much

#

so i can basically replace @client.event with @client.listen('on_message')?

#

second one

naive briar
#

The page already explained it

#

But yes

wise cradle
#

thx

cosmic dome
#

metamask

vale wing
#

This is not the full error

#

!traceback

unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

!e ```py
print(code)

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(code)
004 |           ^^^^
005 | NameError: name 'code' is not defined. Did you forget to import 'code'?
slate swan
#

you cant use a varriable that is not defined

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval [python_version] <code, ...>
Can also use: e

Run Python code and get the results.

This command supports multiple lines of code, including formatted code blocks. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

The starting working directory /home, is a writeable temporary file system. Files created, excluding names with leading underscores, will be uploaded in the response.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside them.

Currently only 3.12 version is supported.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!

#

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

001 |   File "/home/main.py", line 11
002 |     get_defCoins(uid):
003 |                      ^
004 | SyntaxError: invalid syntax
#

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

001 |   File "/home/main.py", line 3
002 |     try:
003 | IndentationError: unexpected indent
#
Missing required argument

code

lyric sigil
#

I have this error :

2023-11-02 11:46:27 ERROR    discord.client Ignoring exception in on_member_join
Traceback (most recent call last):
  File "C:\Users\canai\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 441, in _run_event      
    await coro(*args, **kwargs)
  File "c:\Users\canai\Desktop\discord_bots\Gym_advice\main_GA.py", line 31, in f3
    await channel.send(embed=embed)
          ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'

For this code part :

@client.listen('on_member_join')
async def f3(member):
    channel = client.get_channel(THEID)
    embed=discord.Embed(title="Welcome!",description=f"{member.mention}just arrived!" , color=discord.Colour.green())
    await channel.send(embed=embed)
fiery girder
lyric sigil
#

Okay thanks for the help !

fiery girder
#

and if the id is correct try

channel = client.get_guild(member.guild.id).get_channel(THEID)
slate swan
fiery girder
#

oh yea @slate swan

#

i am dumb

#

how can imake that after a command execute after a time period it replies a message like in 5 min

#

i just want a response like a few minutes after maybe even an hour after

slate swan
fiery girder
#

i dont want to wait

#

i want to make a poll command but after like 1 hour it will give the poll results back to the user

slate swan
#

still the easiest solution is to wait

#
@command()
async def ...(...):
    ...
    await asyncio.sleep(3600) # 1h
    # send results
fiery girder
#

will this like put other commands to wait aswell like it will not work with othercommands or it just this command?

slate swan
#

no its all async

#

(not blocking)

fiery girder
#

ok

#

so if its waiting for 1 hour in the poll command can someone else use the poll command?

slate swan
#

yea

fiery girder
#

ok thats great

slate swan
#

but keep in mind that if the bot restarts while the 1h waiting is still pending it wont be still waiting after reload

fiery girder
#

oh ok

slate swan
#

hence this is not the best solution but the easiest one for sure

final iron
fiery girder
slate swan
#

i would say that easier would be if you insert to the database date that you want it to end and then check if this date already passed or not

final iron
#

It’s your choice wether you want to store the datetime object or the unix time. I prefer unix time as it’s easier to compare, but storing the object itself would be more readable

young dagger
#

@final iron Do you use this logic for temp bans/mutes as well?

rough shuttle
slate swan
vale wing
slate swan
stark nexus
#

Im having a cog question
Here's main.py
https://paste.pythondiscord.com/CLUA
Help.py
https://paste.pythondiscord.com/HATA
Here's the few reasons i think the bot have problem:
1.Online status
First pic is this bot in the console
It didnt have the blue and purple text's that checked it online and the synced how many commands
Left one is other normal bot looks like
2.when i enter / in server, the command list didnt refresh, new commands i added not showing, old command i deleted still there
Anyone please tell me is this normal

stark nexus
sage otter
#

so i’m fairly sure that when you modify as well as add any new slash commands you need to resync them so that discord is updated with your new command

#

also from what it looks like between the two pictures. that you could be running two different versions of the code. one that has logging(the colored text you were talking about) setup and one that doesn’t.

stark nexus
stark nexus
#

How suppose i do?

valid yew
#

ok so im making a python script where you can use these commands !play Artist - Song name and queue but when i use these commands it doesnt do anything and it doesnt show anything on python cmd

shrewd pagoda
#

Hey

#

I want help

fiery girder
#

i mean it doesnt work for like mnore then 1 min or so

#

i tried for 3 min and waited but it never worked

final iron
#

Literally 0 reason to use bots for that

young dagger
naive briar
#

Why would you ban someone temporarily anyway? pithink

shrewd fjord
naive briar
#

I wouldn't want some obvious trolls to be back in my server, if I have one anyway

shrewd fjord
#

Then ig just for removing messages ;-;

cyan eagle
#

Hello can anyone take my post?

slate swan
#

anyone have self bot ?

slate swan
unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

barren tiger
#

Why does my bot not reply to messages? also how can i access the debug logger?? I've tried various things but I can't seem to figure out what im doing wrong

here's my paste:

https://paste.pythondiscord.com/5QZA

slate swan
barren tiger
slate swan
#

How to make a bot with / commands

#

A normal simple bot will do

#

So i get the idea

snow coral
#

!paste

final iron
patent lark
patent lark
#

@final iron Hey brother i gotta question. So i have created a configuration command in my bot, this function configures things like Automod and Embed colors. Heres my issue: I want to be able to re run a configuration question if an invalid response is detected. For example, if the configuration funtion asks the user "How long would you like Spam mutes to be?" And the user responds with "Pig", this is an invalid response and at this point, i want to ask that question again. Do i need to use a while loop? Or is there something that will handle this better for me?

fading marlin
#

What are you using to configure your bot? Do you have a list of questions you send and wait for a message response from the user?

patent lark
#

And this is all being written to a database

fading marlin
#

Is there any reason why you don't have subcommands for specific configurations instead?

proper python
#

this is the initial setup. There will be subcommands for specific configurations in the future

patent lark
#

^

patent lark
#

It would make the process longer at hand

proper python
#

would be a hell of a lot easier to make tho lmao

rotund flame
#

my lord that small nickname got me some reading problems

fading marlin
proper python
#

again, we'll probably implement the subcommands afterwards. We just need an initial streamlined setup

fading marlin
#

If you want to do it the way you currently are, a while loop is probably your best bet. Though I'd strongly recommend joining that up into a group with subcommands for those features

proper python
#

one more thing: bot.wait_for("interaction") is a thing, right?

fading marlin
#

Yeah

#

!d discord.on_interaction

unkempt canyonBOT
#

discord.on_interaction(interaction)```
Called when an interaction happened.

This currently happens due to slash command invocations or components being used.

Warning

This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View) instead as it provides a nicer user experience.

New in version 2.0.
devout drum
#

anyone know how I can make it to where instead of me having to use cd all the time it is just always there

proper python
#

I'm using a Select Menu and don't want other people interacting with it

proper python
#

when other users click on it, it runs the rest of the code. So I'm tryna stop that from happening but still allow the user that ran the command to interact

final iron
final iron
#

on_interaction should be rarely, if ever used

#

Callbacks were implemented specifically for this purpose

glossy birch
#

Hey

#

anyone help mejust little guide me and help me very small thing

#

dm me if you can help me 🙏

shrewd fjord
#

Wtf?

void mauve
#

lmfao

shrewd fjord
#

Bro stop 💀💀💀

#

Dont make me reverse search this images on google 💀

void mauve
#

bro i think he dead serious hes not even sarcastic

shrewd fjord
#

You exactly know reverse what lol, <@&831776746206265384> please handle

#

Ok python server really getting raided

#

Where r the mods bruv

copper quartz
#

whats going on here?

shrewd fjord
#

Please handle, ;-;

void mauve
shrewd fjord
#

From here..

copper quartz
#

@craggy meadow and @slate swan stop this nonsense.

thin raft
#

hey

#

what do you need help with

#

will you save the data?

#

what have you tried

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

shrewd fjord
#

Lmaoooo

grave rock
#

lets not

copper quartz
#

that is agains discords Terms of Use and your account will be reported

#

!pban 1168338903145664575 self bot spamming

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @distant forum permanently.

timid vector
#

he was probably trolling

#

dumb bith

copper quartz
timid vector
copper quartz
slate swan
turbid condor
#

seems like the channel was pretty lively earlier

cyan eagle
#

Whats the code to dm a mentioned member

Soemthing like this 👇

!dm @cyan eagle hello

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/latest/api.html#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) of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#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/latest/api.html#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) of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed) objects. **Specifying both parameters will lead to an exception**.
cyan eagle
#

I am not able to copy code :/

final iron
#

What

#

Why do you need to copy it. Just type it yourself…

cyan eagle
#

I am not able to copy code

#

Hmm

cyan eagle
final iron
#

That’s how you do it…

cyan eagle
#

Hmm me new so dont know much

#

Ty

cyan eagle
#

@final iron i need a help


import os

intents =

discord. Intents.default()

intents. typing = False

intents.presences = False

client =

discord.Client(intents-intent s)

@client.event

async def on ready():

print("Logged in as (8.user).formatent))

client.run(os.getenv('TOKEN') )

@client.event

async def

on_message(message):

if message.author ==

client.user:

return

message.content.startswith("! dm'):

mentioned_members = message.mentions

nonmention message = message.content.replace('Idm ').strip()

for member in

mentioned members:

dm_channel await member.create_dm()

await

dm_channel.send(nonmention_me ssage)``` 

Can you tell me whats wrong here bot is not responding to command
unkempt canyonBOT
#
Resources

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

final iron
#

It’s very clear you’ve just copied code online and pasted it in

final iron
slate swan
cyan eagle
#

Spending 10 to 15 days is not worth for 1 command soo thats why j joined this server and used raplit ai

slate swan
wise cradle
#

is using BeautifulSoup for searching websites illegal?

#

or against the ToS of discord

slate swan
#

its about website tos

wise cradle
#

i mean i am just using the bot to get the website link nothing else in that

slate swan
#

website link from another website?

wise cradle
#

from here yes

slate swan
#

its an api

wise cradle
#

yeah

slate swan
#

so you obviously can use the results

wise cradle
#

oh?

#

alright thanks

slate swan
#

are you using beautiful soup to access api?

wise cradle
#

nope

slate swan
#

so what are you doing with bs?

wise cradle
#

apprantly i thought beautiful soup was included there

#

but its not used

#

i never said i was using beautiful soup anyways 😭

slate swan
wise cradle
#

welp i just asked if its legal or not i didnt say i "used" it

slate swan
#

then why you ask about something that you dont use 😵‍💫 ?

wise cradle
#

good question

#

for general knolege

#

i just dont remember why did i import this i am not even using it

#

so i thought i might be using it before and forgot so asked just to be safe

left dew
#

how can i get rid of these types of errors:
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

final iron
left dew
# final iron Respond to interactions within 3 seconds

do u know why nothing will append to this empty file ive sent in dbchannel?

@bot.command()
@commands.cooldown(1, 2, commands.BucketType.guild)
async def loa(ctx, userID=None, amt_time=None):
  support = ctx.guild.get_role(SUPPORT_ID)
  if (support in ctx.author.roles):
    if userID == None or amt_time==None:
      await ctx.reply(f"Invalid usuage.\n*`usuage: {PREFIX} userID time in days`*")
      return
    else:
      # user = guild.get_member(int(userID))
      dbchannel = bot.get_channel(1155888521840693359)
      logsdata_msg = await dbchannel.history(limit=1, oldest_first=True).flatten()
      while len(logsdata_msg) == 0:
        logsdata_msg = await dbchannel.history(limit=1, oldest_first=True).flatten()
      logsdata_msg=logsdata_msg[0]
      file = logsdata_msg.attachments[0]
      cont = await file.read()
      alldata = ast.literal_eval(cont.decode('utf-8'))
      alldata.append({"userID": userID, "time": amt_time})
      await loa_logs(alldata, logsdata_msg, dbchannel)
      await ctx.reply(f"Successfully added <@{str(userID)}> to the database.")```
slate swan
#

.flatten() is not a thing anymore

left dew
#

what do i use instead

final iron
#

!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) that enables receiving the destination’s message history.

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

Examples

Usage...
slate swan
final iron
#

It’s an iterable now

slate swan
#

Flattening into a list:

messages = [message async for message in channel.history(limit=123)]
# messages is now a list of Message...
left dew
#

oh okay

left dew
final iron
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

final iron
#

Share the current code

left dew
#

wait not that

left dew
# final iron Share the current code
@bot.command()
@commands.cooldown(1, 2, commands.BucketType.guild)
async def loa(ctx, userID=None, amt_time=None):
  support = ctx.guild.get_role(SUPPORT_ID)
  if (support in ctx.author.roles):
    if userID == None or amt_time==None:
      await ctx.reply(f"Invalid usuage.\n*`usuage: {PREFIX} userID time in days`*")
      return
    else:
      # user = guild.get_member(int(userID))
      dbchannel = bot.get_channel(1155888521840693359)
      messages = [message async for message in dbchannel.history(limit=1)]
      while len(messages) == 0:
        messages = [message async for message in dbchannel.history(limit=1)]
      messages=messages[0]
      file = messages.attachments[0]
      cont = await file.read()
      alldata = ast.literal_eval(cont.decode('utf-8'))
      alldata.append({"userID": userID, "time": amt_time})
      await loa_logs(alldata, messages, dbchannel)
      await ctx.reply(f"Successfully added <@{str(userID)}> to the database.")```
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

left dew
#

huh

honest falcon
#
import discord
from discord.ext import commands
import chess
import chess.svg
from cairosvg import svg2png

intents = discord.Intents.default()
bot = commands.Bot(command_prefix='.', intents=intents)

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user.name}')

@bot.command()
async def new(ctx):
    chess.Board()
    game = chess.Board()
    await ctx.send("Chess game started!")
    if game.turn:
        await ctx.send("White's turn")
    else:
        await ctx.send("Black's turn")
    await ctx.send(file=discord.File("board1.png"))

@bot.command()
async def move(ctx, move):
    game = chess.Board()
    if game.legal_moves:
        game.push_san(move)
    else:
        await ctx.send("Invalid move. Please try again.")

    with open("board.svg", "w") as f:
       f.write(chess.svg.board(board=game))

    svg2png(url="board.svg", write_to="board.png")

    await ctx.send(file=discord.File("board.png"))
    if game.turn:
        await ctx.send("White's turn")
    else:
        await ctx.send("Black's turn")

    if game.is_checkmate():
        await ctx.send("Checkmate! Game over.")
    elif game.is_check():
        await ctx.send("Check!")
    elif game.is_stalemate():
        await ctx.send("Stalemate! Game over.")


bot.run('token')

Im coding a discord chess game, when i run the game, it went well until it get to black turn (white go first), i tried to move d7 to d6 and it gave me this error:

IllegalMoveError: no matching legal move for d7d6 (d7 -> d6) in rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

Did i do sth wrong here or are there any bug

final iron
left dew
final iron
#

So…

left dew
#

i have the exact same code for another databse and it works fine

#

so im not sure

final iron
#

Okay and?

#

Read the embed…

slate swan
final iron
#

Literally read what it says

#

Follow the very simple instructions

left dew
#

my code isnt too large tho

#

u want my whole code file?

final iron
#

Doesn’t matter

final iron
#

Follow the extremely, extremely simple instructions…

turbid condor
#

Welp even first line of error tells everything in the chess one

final iron
left dew
#

await loa_logs(alldata, messages, dbchannel) does

#
async def loa_logs(data, messages, dbchannel):
  buffer = io.StringIO()
  buffer.name = "loa.py"
  buffer.write(str(data))
  buffer.seek(0)
  await messages.delete()
  await dbchannel.send(file=discord.File(buffer, 'loa.py'))```
final iron
#

Do you know what StringIO does?

left dew
#

not really

#

i did but ive forgot

slate swan
#

!d io.StringIO

final iron
#

Pretty sure you didn’t

unkempt canyonBOT
#

class io.StringIO(initial_value='', newline='\n')```
A text stream using an in-memory text buffer. It inherits [`TextIOBase`](https://docs.python.org/3/library/io.html#io.TextIOBase).

The text buffer is discarded when the [`close()`](https://docs.python.org/3/library/io.html#io.IOBase.close) method is called.

The initial value of the buffer can be set by providing *initial\_value*. If newline translation is enabled, newlines will be encoded as if by [`write()`](https://docs.python.org/3/library/io.html#io.TextIOBase.write). The stream is positioned at the start of the buffer which emulates opening an existing file in a `w+` mode, making it ready for an immediate write from the beginning or for a write that would overwrite the initial value. To emulate opening a file in an `a+` mode ready for appending, use `f.seek(0, io.SEEK_END)` to reposition the stream at the end of the buffer.
final iron
#

This is not used to write to files lmao

left dew
#

what do i use instead

final iron
#

This is why we don’t copy and paste code off the internet

final iron
left dew
#

i havent

#

the file is in a discord channel

#

and why do u have to be so condescending

#

okay i may not know everything unlike you

#

but theres no need to be rude

final iron
#

Not being rude lmao

left dew
#

then you must have a great personaility

final iron
#

Thanks for the compliment

#

!d discord.File.fp

unkempt canyonBOT
#

A file-like object opened in binary mode and read mode or a filename representing a file in the hard drive to open.

Note

If the file-like object passed is opened via open then the modes ‘rb’ should be used.

To pass binary data, consider usage of io.BytesIO.

final iron
#

You can get a file like object with that

#

Then open it in memory of course and do allat

left dew
#

but the code is the exact same as another databse and that works fine. ive sent an empty file name loa.py to the channel, is that why nothing is being appended to it?

final iron
#

Possibly? You’re not using StringIO for its intended use so it’s a given it’s not going to function possibly each time

left dew
#

how would i send thw file to the channel for the intended use

final iron
#

Then you can do everything from there

left dew
#

i just sent the file like this

@bot.command()
async def a(ctx):
  c = bot.get_channel(1155888521840693359)
  buffer = io.StringIO()
  await c.send(file=discord.File(buffer, 'loa.py'))```
final iron
#

Okay?

#

Like I said before, you’re not using StringIO for its intended purpose

#

Sometimes it’ll work, sometimes it won’t

fiery girder
#

how can i get a category from its id?

rotund flame
fiery girder
#

i want category

#

not channel

rotund flame
#

CategoryChannel

#

Is a type of channel

#

As forum channel and voice channel too

fiery girder
#

oh ok

cold oyster
#
class OrderButton(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    @discord.ui.button(label="Claim", style=discord.ButtonStyle.green)
    async def order1(self, button: discord.ui.Button,  interaction: discord.Interaction):
        await interaction.response.send_message("You clicked me!")

@client.hybrid_command()
async def test(ctx):
    view = OrderButton()
    await ctx.send(view=view)```
Why is it giving me an error:

[2023-11-03 12:53:58] [ERROR ] discord.ui.view: Ignoring exception in view <OrderButton timeout=180.0 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Claim' emoji=None row=None>
Traceback (most recent call last):
File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
await item.callback(interaction)
File "c:\Users\HP\OneDrive\Desktop\MetaBotsForge\Server\Bot\main.py", line 310, in order1
await interaction.response.send_message("You clicked me!")
AttributeError: 'Button' object has no attribute 'response'```

hushed galleon
cold oyster
#

woah

#

too much to understand

hushed galleon
#

i havent even given a detailed answer tho

cold oyster
hushed galleon
#

ergh, i mean sure you could write that...

cold oyster
hushed galleon
#

im just saying to flip button and interaction around in your parameters

cold oyster
#
@discord.ui.button(label="Claim", style=discord.ButtonStyle.green)
    async def order1(self, button: discord.ui.Button,  interaction: discord.Button):
        await interaction.send_message("You clicked me!")```

Smth like this 😭 ?
pseudo token
#

Elloh

hushed galleon
#

interaction should be the second parameter of your function, and button should be the third parameter

pseudo token
#

How is everyone

cold oyster
unkempt canyonBOT
pseudo token
# cold oyster !ot

Ye i dunno what that means 🙂 the reason why I joined this server is I need help

#

Can I dm you if u are a python programmer 🙂

#

cannnnnnn I doo thattt? ^~^

hushed galleon
#

#❓|how-to-get-help
you're more likely to get help asking your full question in the server than prodding people to DM you

cold oyster
hushed galleon
#

i think you meant to write discord.Interaction instead of discord.Button

cold oyster
#

nope it dosent

cold oyster
#

OH WAITI

#

Im so dumb sry 💀

#

@hushed galleon

@discord.ui.button(label="Claim", style=discord.ButtonStyle.green)
    async def order1(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.send_message("You clicked me!")```

Error again
hushed galleon
#

interaction.response.send_message was correct the first time too

cold oyster
#

It says interaction failed 😭

hushed galleon
#

most likely because you used interaction.send_message which isn't a valid method

cold oyster
#

interaction.response.send_message()?

cold oyster
#

Nvm nvm it worked thanks

#

Im soooo dumbb ahhhhh im embarrased

hushed galleon
# hushed galleon i havent even given a detailed answer tho

fyi during dpy 2.0's development it used to be (button, interaction), but when danny left and development stopped, various forks came out to finish the remaining work which is why disnake, nextcord, and pycord all still have it ordered as (button, interaction)

when danny came back and resumed development, he thought it would make more sense to have it ordered as (interaction, button), presumably to be consistent with the new slash commands which would have interaction as their first parameter, but of course people had already started posting code using (button, interaction) which has led to many more people copying their code without realizing it's not compatible with discord.py anymore

hushed galleon
unkempt canyonBOT
#

examples/views/confirm.py lines 29 to 31

@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
    await interaction.response.send_message('Confirming', ephemeral=True)```
cold oyster
hushed galleon
# cold oyster Is it possible to send a message to a specific channel using interaction?

you can't do that as a response to the interaction itself, but you can get the TextChannel object you do want to send to and use that afterwards: py @discord.ui.button(label='Confirm', style=discord.ButtonStyle.green) async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button): await interaction.response.send_message('Confirming', ephemeral=True) channel = interaction.client.get_channel(1234) # channel ID await channel.send('Someone just used the confirm button!')

#

!d discord.Client.get_channel

unkempt canyonBOT
#

get_channel(id, /)```
Returns a channel or thread with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
slate swan
#

Can i go to the next iteration of a tasks.loop and keep the interval till the next-next one?
what i want is
print(0) -> dispatch_send -> wait for 1.5s -> next iteration of the task

fading marlin
#

!d discord.ext.tasks.Loop.restart you could call this after dispatching

unkempt canyonBOT
#

restart(*args, **kwargs)```
A convenience method to restart the internal task.

Note

Due to the way this function works, the task is not returned like [`start()`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop.start).
slate swan
#

`(venv_name) C:\Users\abhay\OneDrive\Desktop\mater bot>python main.py
Traceback (most recent call last):
File "C:\Users\abhay\OneDrive\Desktop\mater bot\main.py", line 25, in <module>
client = Client()
^^^^^^^^
File "C:\Users\abhay\OneDrive\Desktop\mater bot\main.py", line 12, in init
super().__init(command_prefix=commands.when_mentioned_or('.'), intents=discord.Intents().all())
^^^^^^^^^^^^^^
AttributeError: 'super' object has no attribute '_Client__init'

(venv_name) C:\Users\abhay\OneDrive\Desktop\mater bot>`

why this error im trying to fix doesnt get fixed plz help

#

main.py code here

`import discord
from discord.ext import commands
from colorama import Fore, Back, Style
import time
import json
import platform
from buttons.blacklist import BlacklistView

class Client(commands.Bot):
def init(self):
# You should call the constructor of the parent class using super() and ensure that it has the correct parameters.
super().__init(command_prefix=commands.when_mentioned_or('.'), intents=discord.Intents().all())

async def setup_hook(self):
    for ext in self.cogslist:
        await self.load_extension(ext)

async def on_ready(self):
    prfx = (Back.BLACK + Fore.GREEN + time.strftime("%H:%M:%S UTC", time.gmtime()) + Back.RESET + Fore.WHITE + Style.BRIGHT)
    print(prfx + " Logged in as " + Fore.YELLOW + self.user.name)
    print(prfx + " Bot ID " + Fore.YELLOW + str(self.user.id))
    print(prfx + " Discord Version " + Fore.YELLOW + discord.__version__)
    print(prfx + " Python Version " + Fore.YELLOW + str(platform.python_version()))

client = Client()

client.run("ig my token") # bot token inside quotes
`

#

@hushed galleon

final iron
#

__init__

slate swan
slate swan
final iron
#

I already gave the answer...

slate swan
final iron
#

When you're calling your super()...

slate swan
# final iron When you're calling your `super()`...

`(venv_name) C:\Users\abhay\OneDrive\Desktop\mater bot>python main.py
[2023-11-04 09:18:52] [INFO ] discord.client: logging in using static token
Traceback (most recent call last):
File "C:\Users\abhay\OneDrive\Desktop\mater bot\main.py", line 27, in <module>
client.run("token fr") # bot token inside quotes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abhay\OneDrive\Desktop\mater bot\venv_name\Lib\site-packages\discord\client.py", line 860, in run
asyncio.run(runner())
File "C:\Users\abhay\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\abhay\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abhay\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\abhay\OneDrive\Desktop\mater bot\venv_name\Lib\site-packages\discord\client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\abhay\OneDrive\Desktop\mater bot\venv_name\Lib\site-packages\discord\client.py", line 777, in start
await self.login(token)
File "C:\Users\abhay\OneDrive\Desktop\mater bot\venv_name\Lib\site-packages\discord\client.py", line 621, in login
await self.setup_hook()
File "C:\Users\abhay\OneDrive\Desktop\mater bot\main.py", line 15, in setup_hook
for ext in self.cogslist:
^^^^^^^^^^^^^
AttributeError: 'Client' object has no attribute 'cogslist'

(venv_name) C:\Users\abhay\OneDrive\Desktop\mater bot>`

final iron
#

And this is why we don't copy code we find online

#

You never defined cogslist

#

You also shouldn't be calling your commands.Bot subclass client

#

discord.Client exists so it's insanely confusing

slate swan
#

how do i fix it?

slate swan
final iron
#

Well you need to define cogslist lol

slate swan
final iron
#

Thousands

final iron
#

Oh nvm

#

It's off stackoverflow

slate swan
# final iron Oh nvm

`(venv_name) C:\Users\abhay\OneDrive\Desktop\mater bot>python main.py
Traceback (most recent call last):
File "C:\Users\abhay\OneDrive\Desktop\mater bot\main.py", line 25, in <module>
client = Client()
^^^^^^^^
File "C:\Users\abhay\OneDrive\Desktop\mater bot\main.py", line 12, in init
super().__init(command_prefix=commands.when_mentioned_or('.'), intents=discord.Intents().all())
^^^^^^^^^^^^^^
AttributeError: 'super' object has no attribute '_Client__init'

(venv_name) C:\Users\abhay\OneDrive\Desktop\mater bot>`

final iron
#

Same error as before...

slate swan
#

new eeror bruh

#

error