#discord-bots

1 messages Β· Page 157 of 1

keen dust
#

you see, you've specified the variable as commands not bot

#

use await commands.tree.sync() and it should work

mighty pilot
#

whelp. always the simple stuff

keen dust
#

lol, we all make mistakes

mighty pilot
#

discord.ext.commands has no attribute 'tree'

keen dust
#

alright

#

instead of using commands try changing the variable to bot or anything else you'd like

mighty pilot
#

i have bot set to commands.Bot

slate swan
#

the function doesnt look like that its in a class, is it?

#
class Foo:
    def in_a_class(self):
        ...
def not_in_a_class(self):
     ...
mighty pilot
#

can i have hybrid commands and slash commands in the same bot? hadnt considered that might be an issue

#

i dont have anything in classes right now

keen dust
slate swan
mighty pilot
#

that was a result of me throwing stuff in trying to get something different to happen

#

@bot.event
async def on_ready():
    await bot.tree.sync()
    print('ready')

channel_id = 960040150765817907
number = [1]

@commands.hybrid_command()
async def question(ctx):
    print('n')

bot.run(TOKEN)```
#

thats everything not commented out of the file right now except the token and imports

#

getting this error still

slate swan
#

@bot.hybrid_command

keen dust
#

pog

#

jinx

slate swan
#

i wrote it only to ping someone named @bot

#

bot didnt work this time sadly πŸ˜”

keen dust
#

rip

mighty pilot
#

so why is that one bot but regular commands are still @commands and slash commands still @app_commands

#

works now though. thanks

keen dust
#

np

slate swan
mighty pilot
#

gets confusing sometimes

slate swan
#

what's confusing about it

mighty pilot
#

i guess i just havent looked at that part of the docs enough for the structure to make sense to me

slate swan
#

mb

keen dust
#

wait I just realized bots can't dm users who don't allow dms from users on a server unless they're friends...

slate swan
#

yea

#

and bots cant be friends

keen dust
#

thats...annoying

#

Users can literally block them if they'd like

slate swan
#

that's the intention

keen dust
#

to make it annoying?

slate swan
#

some bots mass dm users for promotion malicious links

keen dust
#

ye...

#

thats true

slate swan
#

its just to prevent that

#
  • dms from bots get annoying unless asked for
#

i join some servers and boom, 10 dms from bots in the same server

#

leaves instantly

keen dust
#

alr ye thats true

naive briar
#

Say what's the problem is or send with an exception

#

Anyways

#

The init in your lass isn't a magic method

#

So change it

mighty pilot
#

says im missing the command, but im able to get the command object

slate swan
#

you need to use an instance of commands.Context not the class itself

mighty pilot
#

hmmm ok

slate swan
#

what you trying to do with IPs, sus

maiden fable
#

@slate swan if my bot error handler was yr name then i don't think it will ever wake up from 0 second naps

slate swan
#

thats' the future of tech

severe mural
#

uhh no solution here is ```
@show_manager_channel.error # <- name of the command + .error
async def show_manager_channel_error(error, interaction):
if isinstance(error, commands.MissingRole):
await interaction.response.send_message(f"{ctx.author.mention} Sorry, create role << Channels Manager - Giveaways Manager >> has been can permission commands :rotating_light:",ephemeral=True)
# message = await interaction.original_response()

else:
raise error```

naive briar
#

What's the problem

severe mural
#

there ⬆️

naive briar
#

Can you send the actual error from the terminal or console or whatever

severe mural
#

is empty.

severe mural
naive briar
#

Then you simply didn't respond to the interaction

maiden fable
severe mural
severe mural
maiden fable
#

?

severe mural
#

maybe?

maiden fable
#

Indent

severe mural
#

but confuse

maiden fable
#

!indent

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

severe mural
#

Ah

maiden fable
#

Mhm

severe mural
#

Correct?

#

ok

maiden fable
#

There u go

severe mural
#

ah yes but example no have rol and response error "Sorry create role..."

naive briar
#

!traceback

unkempt canyonBOT
#

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.

severe mural
#

is confuse.

severe mural
#

no have rol think

maiden fable
severe mural
#

hmm ok

maiden fable
#

And then, paste the error

#

!paste use this please

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

severe mural
#

error print: <discord.interactions.Interaction object at 0x7fd5abfd6a90>

maiden fable
#

Thought so

severe mural
maiden fable
#

Your error and interaction params are interchanged

#

interaction should be the followed by error not the vice versa

severe mural
#

i see but have there interaction

#

hmmmm weird.

maiden fable
#

async def show_manager_channel(interaction, error)

severe mural
#

ahh

maiden fable
#

Instead of the other way around

severe mural
#

error, interaction change is l(interaction, error)

maiden fable
#

Yes

severe mural
#

i see.

#

my bad...

maiden fable
#

You were trying to check if the Interaction is the error lol

severe mural
#

yeah

#

same lol. // moment again print error.

maiden fable
#

Show the latest code

severe mural
#

yeah..

#

but... missing messag error.

#

no is "error red" but only message error

#

hmm

#

@maiden fable yeah but my think.. other before "ctx" is okay work message error (not need red)

#

and differents response no is error message

#

example message error bot: Role 'Channels Manager' is required to run this command.

naive briar
#

You're printing the error, not raising it

severe mural
#

yeah..

#

hmmm think.

#

there is old yes. work.

#

but interaction no work why red message lol.

#

hmm

#

Okay

#

no problem idea thanks old better.

#

@naive briar oh i see but think no is "commands.MissingRole"?

#

maybe there interaction?

#

ahh

#

my stupid sigh!

#

solution maybe done ok

visual canyon
#

does anyone have an example implementation of a command that opens a modal?

leaden solar
#

how do you add users to a private discord thread?

visual canyon
#

There should be a menu at the top right which lets you invite them. I think mentioning them works too

shrewd apex
#

just interaction.response.send_modal will do

visual canyon
#

Thanks i did find an example, but I was specifically looking for how a slash command could open a modal. I think i have it now though

leaden solar
#

how do you invite users to a private thread?

full marten
#

i don't get errors in the terminal, it just pop up "This interaction failed"

shrewd fjord
#

if doing such a thing before defering interaction it will always result in a fail

#

!e
print("checking")

#

oh bot alive

full marten
shrewd fjord
full marten
shrewd fjord
#

!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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

any help or fixes please?

shrewd fjord
unkempt canyonBOT
#

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.

shrewd fjord
#

show us full traceback

slate swan
#

what is full traceback

#

im trynna fix the thing that it does not unban

full marten
shrewd fjord
#

we need see from which line u r getting this error

slate swan
#

everything works perfectly just not the unban command

shrewd fjord
#

there is more error on upwards

slate swan
shrewd fjord
#

πŸ™‚

slate swan
shrewd fjord
#

i said error

#

not code

#

need full error from terminal

full marten
shrewd fjord
#

error starts with
Traceback (most recent call last):

full marten
shrewd fjord
#

checking

slate swan
#

there is no code error its just that the command dont work @shrewd fjord

full marten
#

if do you want the main.py too, just say me

slate swan
#

and idk how to make it do

shrewd fjord
slate swan
#

u got a fix?

shrewd fjord
slate swan
#

i did a debug and everything is running fine and the bot is online but the only command not working is unban

full marten
#

the interaction failed

shrewd fjord
full marten
#

is what it says

shrewd fjord
#

then
await interaction.response.edit_message(view=self)

shrewd fjord
full marten
#

i doesn't want to send message

shrewd fjord
#

!d discord.Guild.bans

unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.11)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

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

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
shrewd fjord
#

just do what i said

slate swan
#

but than u can steal token spooky

shrewd fjord
#

wait

#

1 min

shrewd fjord
slate swan
#

the bot token

full marten
#

wait

shrewd fjord
#

as far as i see

shrewd fjord
#

not the code bro

full marten
#
 @discord.ui.button(emoji='βž–',  style=discord.ButtonStyle.grey, row=1) 
    async def my_button1(self, interaction:discord.Interaction, button:discord.ui.Button):
        self.button.emoji = 'βœ–οΈ'
slate swan
shrewd fjord
#

button.emoji

full marten
#

or

 @discord.ui.button(emoji='βž–',  style=discord.ButtonStyle.grey, row=1) 
    async def my_button1(self, interaction:discord.Interaction, button:discord.ui.Button):
        button.emoji = 'βœ–οΈ'
shrewd fjord
slate swan
shrewd fjord
slate swan
shrewd fjord
full marten
shrewd fjord
full marten
#

hmm

shrewd fjord
#

wait 1 min bbq

#

checking code

full marten
#
 @discord.ui.button(emoji='βž–',  style=discord.ButtonStyle.grey, row=1) 
    async def my_button1(self, interaction:discord.Interaction, button:discord.ui.Button):
        button.emoji = 'βœ–οΈ'
        await interaction.response.edit_message(view=self)

like this?

full marten
#

I think edit_message does not exists

shrewd fjord
#

async for banned_users in ctx.guild.bans()
then do other stuffs here

shrewd fjord
full marten
#

would it be like that?

shrewd fjord
#

!d discord.InteractionResponse.edit_message

unkempt canyonBOT
#

await edit_message(*, content=..., embed=..., embeds=..., attachments=..., view=..., allowed_mentions=...)```
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.
shrewd fjord
#

see?

full marten
#

await interaction.response.edit_original_response()

shrewd fjord
slate swan
shrewd fjord
#

so no

#

need to use edit_message

#

@shrewd fjord u r getting any error?

#

@shrewd fjord

full marten
shrewd fjord
#

wth

#

@full marten

#

finally lol

full marten
shrewd fjord
#

my ping was not working xddd

full marten
#

i'm testing now

full marten
shrewd fjord
#

try to understand by urself

slate swan
#

how do i send my code

full marten
#

Ohhhhh yeahhhhh it workedddd

shrewd fjord
#

async for ....................:
#then other codes will be send right here

shrewd fjord
full marten
#

thanks a lootttt

shrewd fjord
full marten
shrewd fjord
#

cool

rare echo
full marten
slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

shrewd fjord
full marten
#

this is my first time using discordbots

shrewd fjord
slate swan
#

!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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

rare echo
#

haha

shrewd fjord
#

it's ``` not '''

#

🀷

shrewd fjord
#

jk xd

rare echo
#

i love seeing people choose between code and paste

full marten
shrewd fjord
#

haha

slate swan
rare echo
full marten
#

i don't speak english very well, so if i say something wrong, could you please correct me?

slate swan
slate swan
#

its not that the lines are bad its just that it does not do the command and idk why

shrewd fjord
#

check what i edited

leaden solar
#

is it possible to detect messages from threads that is under a specific channel?

shrewd fjord
#

!d discord.Guild.bans

unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.11)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

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

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.

Examples

Usage...
shrewd fjord
#

Reference ^

slate swan
alpine cove
shrewd fjord
#

/bab

alpine cove
#

its a discord inbuilt feature lol

shrewd fjord
#

πŸ’€

alpine cove
#

no need for another ban cmd

shrewd fjord
#

isn't it ban?

#

u typed bab πŸ’€

full marten
slate swan
rare echo
slate swan
#

@shrewd fjord still not working

alpine cove
#

*ban

#

wtf

slate swan
#

yeah but im trying to do it through a bot

shrewd fjord
#

remove self from function

#

on_command_error(ctx,error):

shrewd fjord
leaden solar
#

is it possible to log messages that are sent from a thread under a specific channel?

full marten
#

self should only be used inside classes

shrewd fjord
#

ye xd

slate swan
shrewd fjord
#

and use get messages

shrewd fjord
slate swan
leaden solar
#

is it like a on event?

shrewd fjord
#

u can use on_message event

#

pass their thread channel id

#

or u can use

#

channel. history

#

!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.11)") 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 "discord.Permissions.read_message_history") to do this.

Examples

Usage...
shrewd fjord
#

it will return a list

full marten
shrewd fjord
leaden solar
visual canyon
#

what is the best way to (de)serialize a modal TextStyle.long to/from a db blob datatype?

leaden solar
#

in the specific thread?

shrewd fjord
full marten
shrewd fjord
alpine cove
full marten
#

ok

shrewd fjord
#

!d discord.ui.Button.disabled

unkempt canyonBOT
leaden solar
#

because i have a variable with with create_thread() in it, should i just do like thread.read_message_history?

alpine cove
#

why not have a on_message event and check for the thread

full marten
#

thank you again, spooky :D

leaden solar
#

i mean i could not figure out how i could read messages from a specific thread from on message

shrewd fjord
alpine cove
#

if isinstance(channel, discord.Thread) and channel.id == your_id

shrewd fjord
#

if he uses history he can just wrap it with a command

shrewd fjord
#

here we can get the channel's history

leaden solar
#

through on message

shrewd fjord
#

but for on_message event we always have to change the id

#

if we want some for diff threads too

shrewd fjord
#

on_command_error doesnt takes arg

alpine cove
#

he's tryna log threads of a channel

alpine cove
#

nvm then

shrewd fjord
#

hmmmmmmmmmmm

slate swan
#

any1 help?

shrewd fjord
#

wait

slate swan
shrewd fjord
#

named thread_delete

alpine cove
#

!d discord.TextChannel.threads

unkempt canyonBOT
slate swan
shrewd fjord
#

just use
await ctx.send(error)

alpine cove
leaden solar
#

yeah its a system that is for users to sell stuff in, and everything gets logged in it

shrewd fjord
#

on_thread_delete
u can then check the history of channel and get the message and log it

#

kinda ez

leaden solar
slate swan
#

where is the async function

alpine cove
#

!d discord.on_thread_create

unkempt canyonBOT
#

discord.on_thread_create(thread)```
Called whenever a thread is created.

Note that you can get the guild from [`Thread.guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Thread.guild "discord.Thread.guild").

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

New in version 2.0.
shrewd fjord
leaden solar
#

oh that seems much easier to use lol

shrewd fjord
#

but he want's the messages

#

ig

leaden solar
#

yeah exactly

shrewd fjord
#

!d discord.on_thread_delete

unkempt canyonBOT
#

discord.on_thread_delete(thread)```
Called whenever a thread is deleted. If the thread could not be found in the internal cache this event will not be called. Threads will not be in the cache if they are archived.

If you need this information use [`on_raw_thread_delete()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_thread_delete "discord.on_raw_thread_delete") instead.

Note that you can get the guild from [`Thread.guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Thread.guild "discord.Thread.guild").

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

New in version 2.0.
shrewd fjord
#

better

leaden solar
#

oh so like on delete

#

read_message_history

#

and send

shrewd fjord
slate swan
#

ok

leaden solar
#

hmm okay thank you for the help, ill try to use this and see how it goes lmao

slate swan
#

@slate swan im now trynna run the command

#

still not working

shrewd fjord
#

!d discord.Thread.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.11)") 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 "discord.Permissions.read_message_history") to do this.

Examples

Usage...
slate swan
shrewd fjord
#

not discord.member

slate swan
#

ok a sec

shrewd fjord
#

xd

slate swan
#

vd

#

tho it says discord.Member meaning the guy needs to be in the server right?

shrewd fjord
#

u can use discord.User

slate swan
#

its an unban command not an ban...

shrewd fjord
#

if the user is not in the server

shrewd fjord
leaden solar
#

oh wait btw, for the on thread create function, how can i detect if the thread are created under specific channel?

#

a*

shrewd fjord
#

in this argument u gotta use either user's id or name or somehow mention him

shrewd fjord
#

!d discord.Thread

unkempt canyonBOT
#

class discord.Thread```
Represents a Discord thread.

x == y Checks if two threads are equal.

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

hash(x) Returns the thread’s hash.

str(x) Returns the thread’s name.

New in version 2.0.
shrewd fjord
#

list of attributes u can get here

leaden solar
#

oh okay

slate swan
#

still not working

leaden solar
#

so it should be like like an id of some sort to check?

slate swan
#

and im trynna unban him with a command

leaden solar
#

like the category id

shrewd fjord
#

can u try to pass his id?

slate swan
#

a sec

shrewd fjord
#

u can get thread in on_thread_create event

leaden solar
slate swan
#

still not working @slate swan

shrewd fjord
#

i gave up already xdddd

slate swan
leaden solar
shrewd fjord
shrewd fjord
slate swan
#

!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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
ember nest
#

I have question how to make something like
/setwelcomechannel for a welcome channel to make bot do the welcome on it (to be able to use the bot in more than 1 server)

shrewd fjord
#

@bot.command()
async def unban(ctx, user: discord.User):
await ctx.guild.unabn(user)
await ctx.send("your message")

#

@slate swan

slate swan
#

unabn\

shrewd fjord
#

if u want to avoid it add cahnnel id manually

ember nest
shrewd fjord
ember nest
shrewd fjord
#

but ig use sqlite3

shrewd fjord
shrewd fjord
ember nest
shrewd fjord
#

nothing else

slate swan
ember nest
#

How to do the set command then

shrewd fjord
shrewd fjord
ember nest
#

Yes

slate swan
shrewd fjord
#

like how did u make ur poll command slash

ember nest
#

Yeah

shrewd fjord
#

ahhh

#

code will help me πŸ’€

#

gimme code let me check

slate swan
#

i guess u dont know how to fix my problem @slate swan

#

still ok

shrewd fjord
#

bot.event
async def on_command_error(ctx, error,):
if isinstance(error, commands.CommandNotFound):
CommandError=discord.Embed(title="🚫 ERROR !",description=f"{error}")
CommandError.set_footer(text="Deleting in 4 seconds...")
await ctx.reply(embed=CommandError)
time.sleep(3)

#

only part of this code enough btw

slate swan
#

the things he told me to do did not fix it

shrewd fjord
#

if u want global command handlers

#

for specific u can use the same

ember nest
#

I can't find any video or anything to show me how to /setchannel so what would I do @shrewd fjord

shrewd fjord
#

if isinsctance(error, commands.CommandNotFound):
#your error msg

#

kindda like dat

shrewd fjord
#

and use ur database skills?

ember nest
#

I don't have database skills actually lol

#

Just learned a little bit for the warn

#

And probably forgot

shrewd fjord
#

try this kind of easy

shrewd fjord
#

idk database professionally either

#

i can just give idea how to implement it

ember nest
#

Alright no problem lemme see

ember nest
shrewd fjord
#

like?

shrewd fjord
# ember nest Sure

u can create a table named channel there will be 2 columns 1 for guild id one for channel id

#

then insert channel id value with guild id

#

ye so?

#

u can replace ur code by mine

#

if u want global slash handler

#

......what's ur new code?

#

show me or πŸ”«

ember nest
#

Hmm

shrewd fjord
#

no need to do

ember nest
#

Lemme try

shrewd fjord
#

@slate swan it will handleeeeeee allll sort of error

full marten
#

what's the diference about discord.ui.Button and discord.ui.button?

shrewd fjord
#

and 1st one is for getting button object

full marten
#

thanks

shrewd fjord
#

;]

slate swan
#

how do i make so only administrators or specific roles can use the commands and members no?

shrewd fjord
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

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

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

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

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

but also for like specific commands

shrewd fjord
#

put that beneath @bot.command()

slate swan
#

no but like the script u gave me looks like it enables and disables bot commands for specific roles and im trynna do it so members can use bot commands but not all of them on the bot

#

and so as staff

shrewd fjord
#

so that if the staff has that role

#

he can use it

slate swan
#

lets say member

shrewd fjord
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
shrewd fjord
#

who have member role, that member can use this command

slate swan
#

which command?

#

there are many...

shrewd fjord
slate swan
#

ok and how do i do the opposite

shrewd fjord
#

?

clever scaffold
#

wth

slate swan
#

like to make them not be able to use the command

clever scaffold
#

ummm

#

can you give example?

shrewd fjord
#

ez as that

slate swan
#

did not understand

slate swan
shrewd fjord
#

@commands.has_permissions(ban_members=True)

naive briar
#

!d discord.ext.commands.check

unkempt canyonBOT
#

@discord.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command.checks "discord.ext.commands.Command.checks").

These checks should be predicates that take in a single parameter taking a [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event.

If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error").
shrewd fjord
naive briar
#

You can check if the member has the role or not, if yes, just return false

#

There's example in that url

shrewd fjord
#

catgal don't talk or πŸ”«

clever scaffold
shrewd fjord
#

jk

clever scaffold
#

here is example

shrewd fjord
#

xd

slate swan
shrewd fjord
slate swan
#

and to put instead of true to false?

shrewd fjord
#

OH MY GOD KILL MEEEEEEE AAAAAAAAAAAAAAAAAAAAA

clever scaffold
shrewd fjord
clever scaffold
#
@client.command()
@commands.has_permissions(ban_members=True)
async def ban():
  ...
#

like that

shrewd fjord
shrewd fjord
#

oh u edited, flash guy

clever scaffold
#

hehe

shrewd fjord
#

gimme ur power or my water gun here to get u πŸ”«

shrewd fjord
shrewd fjord
#

cool

clever scaffold
slate swan
clever scaffold
slate swan
#

no like how do i do it but for another command?

shrewd fjord
#

🀷

clever scaffold
slate swan
#

oh

clever scaffold
#

do you have that permission?

slate swan
#

wdym

clever scaffold
#

@slate swan can you show your code?

slate swan
#

@clever scaffold members cannot unban but the second i put this code: @commands.has_role("owner")

shrewd fjord
slate swan
#

all of the commands were open

#

if i would have used this command on staff staff would have access to use all of the commands

shrewd fjord
#

use it

slate swan
#

i put that

slate swan
#

meaning that when i put the role in the command @commands.has_role("")

#

that same role

#

can use all the commands of the bot

clever scaffold
#
ownerID = [...]

@client.command()
async def ban(ctx):
  if ctx.author.id in ownerID:
    ...

  return
#

I have new idea

shrewd fjord
#

it's outside of if statement πŸ’€

clever scaffold
#

it's like if else

shrewd fjord
#

ikr

#

if ..................:
return

shrewd fjord
slate swan
#

ima need to leave this codes out for now lemme check on yt or sum

ember nest
#

Can you check dms @shrewd fjord

shrewd fjord
shrewd fjord
#

dm this id

ember nest
#

Alright

#

Done @shrewd fjord

honest shoal
unkempt canyonBOT
#

class discord.Team```
Represents an application team for a bot provided by Discord.
upbeat otter
unkempt canyonBOT
#

@check```
A decorator that adds a global check to the bot.

A global check is similar to a [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is applied on a per command basis except it is run before any command checks have been verified and applies to every command the bot has.

Note

This function can either be a regular function or a coroutine.

Similar to a command [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check"), this takes a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") and can only raise exceptions inherited from [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").

Example...
slate swan
#

how to make custom command that when u write it it pings staff roles and it also pings the one who sent the command

#

@shrewd fjord

upbeat otter
slate swan
#

hmmmm ok

#

and how do i then write under those mentions a message?

#

@upbeat otter

upbeat otter
slate swan
#

yeah but i want the message to be under

rare echo
#

i mean you can just {mentions} \n message

#

or send 2 messages

slate swan
#

how to make a command that gives a role? @upbeat otter

#

and how to make one that removes a role

sick birch
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

sick birch
#

L bot

slate swan
#

rip

#

robin hood

sick birch
#

!d discord.Guild.create_role

unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

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

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.

New in version 2.0: The `display_icon` keyword-only parameter was added...
sick birch
#

Epic fail

slate swan
#

not create tho

#

Member.add_roles

rare echo
#

!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/latest/api.html#discord.Role "discord.Role")s.

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

how do i make it give 1 role?

#

and what is atomic

#

pass only a single role object.

rare echo
#

u only add 1 role

slate swan
#

what is the async btw?

#

@rare echo

rare echo
#

?

slate swan
#

I think (?) atomically means that they're added one-at-a-time as opposed to all at once. But I'm not certain.

rare echo
#

are you asking what async is or?

slate swan
#

async def mute()

#

whats gonna be inside the apprentasise

rare echo
#

inside the what

slate swan
#

()

steep estuary
#

solution for this error ?

rare echo
#

so probably the user and role?

slate swan
steep estuary
slate swan
# slate swan

Async means asynchronous. In the context of programming, it means your bot can carry out a longer task and still be able to do other things at the same time. Also, add_roles is a method of discord.Member so you need to put await member.add_roles(...).

#

where do i put that tho

#

im trynna put into the () in the desync line

slate swan
#

what do i write inside of the mouth or sum

rare echo
#

bro the mouth? pikaOMG

steep estuary
#

can i continue a task after a break of 1 hour ?

slate swan
#

it looks like a mouth with eyes fr

#

well so what do i write inside

#

ima go eat write in my dms pls

rare echo
slate swan
rare echo
#

null

cold sonnet
#

can a bot edit an ephemeral message

naive briar
#

!d discord.Interaction.edit_original_response

unkempt canyonBOT
#

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

Edits the original interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.
rare echo
#

just @ works, no?

slate swan
#

its correct, if you are in an embed, you are using a wrong area

rare echo
#

< @ 1039974694033563658 >

slate swan
#

what part of embed, only descriptions and field values work

#

I don't think you can mention users in the title and stuff of an embed

rare echo
#

field value though?

slate swan
#

yes.

rare echo
#

if you want to mention them yeah

#

yeah

slate swan
#

indeed it is

#

the ! is not needed there btw

slate swan
#

i know very little python and discord.py is complicated for me

cold sonnet
#

I've tried it already

slate swan
cold sonnet
#

Interaction.message.edit raises unkown Message

slate swan
#

Was the ephemeral message sent by your own bot or another bot?

cold sonnet
#

own bot

slate swan
#

Send the code then

cold sonnet
#

class LeaveButtonView(discord.ui.View):
    def __init__(self, msg):
        super().__init__()
        self.value = None
        self.msg = msg

    @discord.ui.button(label="Leave Giveaway", style=discord.ButtonStyle.danger)
    async def leave_buttony(self, interaction: discord.Interaction, button: discord.ui.Button):
        if self.msg.id in bot.messages:
            if interaction.user.id in bot.messages[self.msg.id]["embed"][3]:
                bot.messages[self.msg.id]["embed"][3].remove(interaction.user.id)
                await interaction.message.edit(content="response 2")
        else:
            await interaction.response.send_message("response 1", ephemeral=True)

#

sent here

await interaction.followup.send("You have already entered this giveaway!", view=LeaveButtonView(msg), ephemeral=True)
#

does defering it help

#

nah

slate swan
cold sonnet
#

let me try

#

it's getting uglier

#

oh I got it in another way

#
            view = LeaveButtonView(msg)
            last_msg = await interaction.followup.send("You have already entered this giveaway!", view=view, ephemeral=True)
            view.last_msg = last_msg
```editing self.last_msg
#

assuming self.last_msg is assigned before discord gets the message, the user gets the message from discord, the user clicks the button, which discord then tells the bot

craggy cloak
#

Someone know where I can find a sports API key?

PS: ping me if you know please!

slate swan
#

!share

#

!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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
sick birch
#

parenthesis?

slate swan
#

Sorry I'm not one to remember names of python characters

frail tapir
#

how to make my bot list all its slash commands?

fading marlin
#

!d discord.app_commands.CommandTree.get_commands

unkempt canyonBOT
drifting arrow
#

How do I keep my bots slash commands to only being used in a discord server and not in dms?

fading marlin
#

!d discord.app_commands.guild_only

unkempt canyonBOT
#

@discord.app_commands.guild_only(func=None)```
A decorator that indicates this command can only be used in a guild context.

This is **not** implemented as a [`check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check "discord.app_commands.check"), and is instead verified by Discord server side. Therefore, there is no error handler called when a command is used within a private message.

This decorator can be called with or without parentheses.

Due to a Discord limitation, this decorator does nothing in subcommands and is ignored.

Examples...
golden anvil
#

How can you send a private message NOT DM

fading marlin
#

what's a private message then?

drifting arrow
golden anvil
#

Oh is that what it's called

golden anvil
golden anvil
golden anvil
#

I've not heard of that lmao

#

oh yeah this may work, i'll have a look on how it works

proud apex
#
  async def custom_cooldown(ctx):
    time = await self.db.fetchval("SELECT time FROM users WHERE user_id = $1", ctx.author.id)
    if time == 0:
      print("one")
      return commands.Cooldown(1, 200)
    elif time == 1:
      print("two")
      return commands.Cooldown(1, 120)

  @commands.command()
  @commands.dynamic_cooldown(custom_cooldown, commands.BucketType.user)
  async def test(self, ctx):
    await ctx.send("ok")

the bot is not responding, there are no errors, what could be the problem?

fading marlin
#

does it print?

#

shouldn't ctx.author.id be inside a tuple?

proud apex
ember nest
#

Guys I need help I am planning to make a really good bot (already started on) and I am going to spend a lot of time working on it

#

But I want to know what I should really use discord.py or nextcord

#

Can someone suggest to me what to use?

slate swan
#

But it's entirely your decision

ember nest
#

Can someone tell me what is the difference between both of them?

slate swan
#

discord.py provides you more control on application command
nextcord provides you easier way of making application commands

thats basically it, other than that there's a bit of change in cogs extension loading etc

ember nest
#

I don't mind easier or harder but I want it more professional and have the ability to do more features so which one is better for mr?

slate swan
#

you get same features in both, in contrast nextcord has more features.

ember nest
#

So if I got really professional at dpy and same as nextcord, if I am using nextcord it will give me more features to do?

slate swan
#

features like voice recieve and some plugins yeah

visual canyon
#

what's the best way to save/load the text of a long-text modal field? edit: in a database nvm. you just use the .value of the textbox object which is a string that has the formatting.

ember nest
#

So I have level system but idk how would I set the xp because it's kinda confusing so for now I have it to level up

#

5 = 63 messages
10 = 500 messages
15 = 1687 messages
20 = 4000 messages
25 = 7812 messages
30 = 13500 messages
35 = 21437 messages
40 = 32000 messages

slate swan
#

I'd just store each user's XP in a database then add a certain amount to that XP when they send a message. Then come up with some formula to convert between XP and level.

alpine cove
#

that would be a lot of queries

#

you shoulf do some optimizing

silent ermine
#

So this is going to sound weird but basically I need to delete some channels but I dont want to loose the data, so can I use a discord bot to transfer all the data from day one to another channel in a different server?

slate swan
alpine cove
#

*messages

silent ermine
alpine cove
#

a while loop but yes

silent ermine
slate swan
#

root@vmd104222:~/hi# python bruh.py
  File "bruh.py", line 9
    async def sync(ctx):
        ^
SyntaxError: invalid syntax
#

erm

alpine cove
#

there is .attachmentd

alpine cove
#

*attachments

#

at least I think so

alpine cove
silent ermine
slate swan
alpine cove
#

well there u go

slate swan
#

i installed 3.11

#

lol ok thanks

alpine cove
#

np

foggy pond
#

what library should i use to make a discord bot. I heard that discord.py was discontinued but i may be wrong

alpine cove
#

try using python3

alpine cove
#

but they brought it back

foggy pond
#

oh rad

#

thanks!

slate swan
#

root@vmd104222:~/hi# sudo apt-get install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.9.2-3).
python3 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
root@vmd104222:~/hi# python --version
Python 2.7.18
root@vmd104222:~/hi# 0
#

bruh

alpine cove
#

just type "python3"

slate swan
#
async def on_raw_reaction_add(payload):
    if payload.channel_id == 1053432855847522434:
        if payload.emoji.name == "πŸ“©":
            guild = bot.get_guild(payload.guild_id)
            overwrites = {
                guild.me: discord.PermissionOverwrite(view_channel=True),
                payload.member: discord.PermissionOverwrite(view_channel=True),
                guild.default_role: discord.PermissionOverwrite(view_channel=False)
            }
            for role in guild.roles[1:4]:
                overwrites[role] = discord.PermissionOverwrite(view_channel=True)
            channel = await guild.create_text_channel(f"Ticket-{payload.member.display_name}", overwrites=overwrites)
            sendticket = discord.Embed(title=f"Tickets on Pirates Developments", description=f"Thanks for contacting support, {ctx.author.name} here at **Pirates Developments**. Our amazing staff members will be with you shortly and hope to slove your issuses. If you have any information leave it below.")
            sendticket.set_footer(text="Β© 2022 Pirates Developments.  All rights reserved")
            await channel.send(embed=sendticket)```
#

any who can help me

#

without errors bot dont work

ember nest
#

Is it easy to make a music bot on nextcord?

#

Cuz it's been a really long time since I started trying to make a music bot on discord.dpy and still can't

eternal delta
#

Someone can send me the command to install Discord library?

sick birch
#

Can you show us your error handler?

#

The error handler?

#

You're 100% sure?

#

What's it say in the console then?

#

In that case make sure the function itself is being called

torn sail
#

Well you aren’t sending a string

#

But it would cause an error because it would call format on a set so if there’s no error then make sure that the command itself is being called like robin said

#

Try adding a print statement at the top of the command and see if it prints

sick birch
#

yeah that's why i wanted you to be 100% sure there's no error handler

#

we don't do that here

#

they're not supposed to be doing that

#

if you want code to be written for you there are platforms like fiverr where you can pay people to do that

#

then listen to us and fix it for free Β―_(ツ)_/Β―

plain notch
#

Hi, I was wondering if I can please get some help with this simple program game of rock paper scissor. Thank you

sick birch
#

Paste your code & traceback and we'll take a look!

plain notch
#

Thank you so much, and sorry how can I properly paste my code?

#

Okay, thank you

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

plain notch
#

'''
import random
def start_game():
rock_paper_scissors = ['R','P','S']
#'R' = Rock
#'P' = Paper
#'S' = Scissors
print("""-------HOW TO PLAY--------
Type 'R' for Rock
Type 'P' for Paper
Type 'S' for Sissors
---------------------------""")
user = input("Rock Paper or Scissors?: ").upper()

while user != 'Q':
    #if user input is not 
    if user not in rock_paper_scissors:
        return 'Invaild Input!'

    #opponent randomly selects a from list
    opponent = random.choice(rock_paper_scissors)

    #if the user and the opponent choose the same, then it is a tie.
    if tie(user, opponent):
        return 'It is a tie! Type "Q" to Quit'

    #if the opponent chooses incorrectly, then the player wins the game.
    elif player_wins(user, opponent):
        return 'You win! Type "Q" to Quit'

    #if the player choose correctly, then the oppoenent wins the game.
    elif opp_wins(user,opponent):
        return 'You Lose! Type "Q" to Quit'

#scissors > paper, rock > scissors, paper > rock
#Paper defeats Rock
#Rock Defeats Scissors
#Scissors Defeats Rock

def player_wins(player, your_opponent):
if (player == 'S' and your_opponent == 'P') or (player == 'R' and your_opponent == 'S') or (player == 'P' and your_opponent == 'R'):
return True

def opp_wins(player, your_opponent):
if (your_opponent == 'S' and player == 'P') or (your_opponent == 'R' and player == 'S') or (your_opponent == 'P' and player == 'R'):
return True

#When the player and the opponenet chose the same.
def tie(player, your_opponent):
if (player == your_opponent):
return True

start_game()'''

#

sorry!

#

There we go, Thanks

#

So, I am trying to allow the player (user) continue playing unless 'Q' is inputted. However, this seems to not work

sick birch
plain notch
#

Okay!

plain notch
#

Would I put this line of code into start_game()?

slate swan
#

Its without errors but idk why it didnt work

plain notch
#

Okay, I will give this a try

silent ermine
#

how do i get a users name and avatar url from channel.history?

plain notch
#

I'm getting a syntax error with the key. But I think I can make it work

slate swan
#

TypeError: BotBase.init() missing 1 required keyword-only argument: 'intents'

#

someone help ^^

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.

slate swan
#

2 many letters

#

ye

#

like this?

slate swan
silent ermine
slate swan
unkempt canyonBOT
silent ermine
rare echo
#

you can probably just add .url

#

you are getting the attachment object

#

so you gotta specify what you want from it

silent ermine
rare echo
#

try .url

silent ermine
rare echo
#

show code

silent ermine
# rare echo show code
messages = await channel.history(limit=100000000000).flatten()
try:
  image = str(message.attachments.url)
  await webhook.send(image, username=message.author.nick, avatar_url=message.author.avatar)
except Exception as e:
  print(e)```
#

There morre but has webhook and channel id

rare echo
#

oh- pretty sure because you are getting a bunch of images not just 1

silent ermine
torn sail
silent ermine
#

it also has %27%3E after .jpg or .png

rare echo
#

oh?, try and just [0] it

silent ermine
rare echo
#

how did you add the [0]?

silent ermine
rare echo
#

message.attachments[0]?

silent ermine
#

It works tysm

silent ermine
slate swan
#

get the channel and send the message

#

create a webhook

#

with the bot

#

webhooks are creating from channels

#

so whatever u send through a webhook will always be in that channel

silent ermine
#

actually yk screw it it doesnt matter

slate swan
#

docs

#

get the channel then create webhook with channel object

rare echo
#

any particular reason you are doing it through a webhook?

silent ermine
crimson hazel
#

Hello. I moved my bot from another hoster to another hoster but i have some issues

Task exception was never retrieved
future: <Task finished name='Task-58' coro=<ticket_response.on_component() done, defined at C:\Users\--\Desktop\Mirage DC Bot\ext\ticket_response.py:240> exception=FileNotFoundError(2, 'No such file or directory')>
Traceback (most recent call last):
  File "C:\Users\--\Desktop\Mirage DC Bot\ext\ticket_response.py", line 243, in on_component
    await self.close_ticket(ctx, reason = None)
  File "C:\Users\--\Desktop\Mirage DC Bot\ext\ticket_response.py", line 288, in close_ticket
    file = interactions.File(filename=f'./transcripts/{channel.name}.html')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\--\AppData\Local\Programs\Python\Python311\Lib\site-packages\interactions\api\models\misc.py", line 324, in __init__
    self._fp = open(filename, "rb") if not fp or fp is MISSING else fp
               ^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: './transcripts/ticket-97.html'
#

cant close my tickets

rare echo
#

directory on new host is probably different

#

if you dont have console access you can probably run a python file to get the cwd

crimson hazel
#

i cant find the part to change the directory

rare echo
#

wdym? youll just have to navigate to /transcripts/ assuming the folder and that file exists / are created

crimson hazel
rare echo
#

so then my next guess is its trying to open that html file it looks like, but cant find it

crimson hazel
#

but i habe 5 different types of tickets and they get renamed randomly my firstnames

rare echo
crimson hazel
rare echo
#

why dont you just name it as the name of the user who made the ticket?

#

same with the file

crimson hazel
#

back then it worked but today i change it to another hoster

#

since then it dont worked

rare echo
#

the host shouldnt effect the code though

#

i could see some directories being changed at the least

crimson hazel
#
 File "C:\Users\--\Desktop\Mirage DC Bot\ext\ticket_response.py", line 288, in close_ticket
    file = interactions.File(filename=f'./transcripts/{channel.name}.html')
rare echo
#

but you can change the contents of the file after its made without editing the file name, for example -
create channel with name ( i.e duckv9-ticket ) and a transcript file ( i.e duckv9-transcript(-datemaybe))
do whatever in ticket
when ticket is closed, transcript everything into the file and delete the channel or rename the channel to duckv9-ticket-closed

#

then you can close the file and upload it to the ticket (prior to closing it)

crimson hazel
# rare echo but you can change the contents of the file after its made without editing the f...

thats the code

                log_channel = await interactions.get(self.client, interactions.Channel, object_id=1024695080080113764)
                embed = interactions.Embed(fields=fields, author=author, thumbnail=thumbnail, color=color)
                await ctx.send('Dieses Ticket wird in 10 Sekunden geschlossen')
                os.system(f'dotnet DiscordChatExporter.CLI/DiscordChatExporter.Cli.dll export -t "BOT--TOKEN" -b -c "{channel.id}" "-o" "transcripts/{channel.name}.html"')
                file = interactions.File(filename=f'./transcripts/{channel.name}.html')
                await member.send(embeds=embed, files=file)
                await log_channel.send(embeds=embed)
                await asyncio.sleep(10)
                await channel.delete()
                collection.delete_one({'_id' : f'{channel.id}'})
                with open('./utils/ticket_ids.json', 'r+') as f:
                    data = json.load(f)
                    list = data['ticket_channels']
                    list.remove(str(channel.id))
                    print(list)
                    data['ticket_channels'] = list
                    f.seek(0)
                    json.dump(data, f)
                    f.truncate()
slate swan
#

lost here

#

cant find the issue

fading marlin
#

parameters should go the other way around

#

interaction first, then button

slate swan
#

ok let me try it out

#

thanks it worked

slate swan
#

ok I want my first button to send a second button when clicked but I'm stuck

torpid hare
fading marlin
#

interaction.response returns InteractionResponse, you don't call that. You have to use one of the various response methods that InteractionResponse offers

torpid hare
rare echo
fading marlin
slate swan
torpid hare
fading marlin
#

either send_message or edit_message

rare echo
#

or set to a debug guild

torpid hare
#

I do not know what that means

fading marlin
#

it is synced, otherwise they wouldn't be able to use it

rare echo
#

slash commands take time to sync by default, so unless you sync it manually or give it a debug guild it might not work right away

torpid hare
#

It's been doing this for days

rare echo
#

Β―_(ツ)_/Β―

fading marlin
torpid hare
#

I'll send it in dms

fading marlin
#

why...

#

just remove any sensitive information

torpid hare
#

dont wanna clog up the channel

rare echo
#

!paste

torpid hare
#

oh

fading marlin
#

defer before you send an HTTP request

#

if you ever defer, it's probably always best to do it at the start of the callback

torpid hare
#

oh

#

i thought it was because of the images not loading fast enough in the embed

fading marlin
#

also don't use requests

#

you were good using aiohttp - there's no point in spontaneously switching to requests

torpid hare
#

testing purposes basically

fading marlin
#

is there any reason why you're purposefully sleeping for 5 seconds after each defer?

torpid hare
#

thats what everywhere online said to do

rare echo
torpid hare
#

internet is always right

rare echo
#

hahahaha

fading marlin
#

no - sleeping serves no use

rare echo
lament depotBOT
rare echo
#

fav quote

torpid hare
#

now sometimes when i do the command it doesnt stop thinking

fading marlin
#

because you're not sending a followup

torpid hare
#

i did though

fading marlin
#

check your if status == 'available_later'

torpid hare
#

it wouldnt be under that one though

#

the response would have been in taken

fading marlin
#

probably because you're using requests then?

torpid hare
#

i removed it

fading marlin
#

any errors?

torpid hare
#

no errors its just thinking forever

fading marlin
#

hmmm, any error handlers that might be eating up yer errors?

torpid hare
#

one second

#

ok yea my log file is telling me something about the capes

#

ok so i called it again and it works perfectly the second time though

#

i didnt save it or anything

#

ok i put the capes one into its own seperate json file and that seemed to fix it

shrewd fjord
#

oh u fixed it xd

torpid hare
shrewd fjord
#

nahhhhh, fixing something urself, is just great

drifting arrow
#

is there a decorator to limit a slash command to admins only?

drifting arrow
#

oo neato

#

Thank you!

flat pier
#

Yw

loud junco
#

im trying to challenge god
will this work

drifting arrow
#

What's with the $?

loud junco
#

its call placeholder

#

like variable but in sql

drifting arrow
#

lol

#

There's a better way to do databases

loud junco
#

tell me the better way

#

πŸ₯Ή

flat pier
drifting arrow
loud junco
#

so confused rn