#discord-bots

1 messages Β· Page 187 of 1

hushed galleon
#

to make it very easy to recognize in your command error handler

#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, NoAccountCreatedError):
        await ctx.send(embed=...)
    # other elif statements for other errors...
    else:
        # unknown error occurred, print it to terminal
        raise error```
tired notch
#

oh i forgot () in class definitions is inheritance πŸ€¦β€β™‚οΈ

hushed galleon
#

for example: ```py
async def retrieve_account(user_id: int) -> AccountInfo:
info = <query user info>
if info is None:
raise NoAccountCreatedError
return info

@bot.command()
async def my_command(ctx):
info = await retrieve_account(ctx.author.id)
# if the function didn't fail, we can continue normally```

#

thinking about it i actually would prefer this over the check approach, still removes most of the boilerplate while being flexible and taking advantage of type inference, biggest drawback is now your error handler has to do slightly more work to match that exception

tired notch
#

thank you bro you are a wizard πŸ™

slate swan
#

What's the best way to set variables for each string after a comma? i.e
,hello john, james, jeff

I'd like those names to be they're own variable

#

use actual command decorator

#

and not on_message

#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
slate swan
#

I assume you just use .split(",")

#

why not just use cmd deco and set a param for a list of names?

slate swan
#

something like that yea

#

I don't think that's the best way?

upbeat gust
slate swan
#

first one would be ur best bet theb

slate swan
#

oh, it returns a list im dumb

pulsar kettle
#

Working on delete message log, but how can I make it so it also detects file attachments such as images, videos, etc.?

@bot.event
async def on_message_delete(message):
    if message.author.bot:
        return
    embed = discord.Embed(description = f"**A message sent by {message.author.mention} has been deleted in <#{message.channel.id}>**\n{message.content}", color = 0xf6ff00, timestamp = discord.utils.utcnow())
    embed.set_author(name = f"{message.author.name}#{message.author.discriminator}", icon_url = message.author.avatar)
    embed.set_footer(text = f"User ID: {message.author.id} β€’ Message ID: {message.id}")
    channel = bot.get_channel(1067413418597953637)
    await channel.send(embed = embed)```
wild oxide
#

ModuleNotFoundError: No module named 'discord.ext.menus.views'

slate swan
#

anyone know any good open source discored bots I can fork for an all purpous server?

unkempt canyonBOT
vocal snow
wild oxide
vocal snow
#

which discord.ext.menus package are you using?

wild oxide
vocal snow
#

I don't see a ViewMenuPages there

wild oxide
vocal snow
#

who told you to use ViewMenuPages?

#

they should also know which package they were talking about

pulsar kettle
#
@bot.event
async def on_message_delete(message):
    if message.author.bot:
        return
    embed = discord.Embed(description = f"**A message sent by {message.author.mention} has been deleted in <#{message.channel.id}>**\n{message.content}", color = 0xf6ff00, timestamp = discord.utils.utcnow())
    if message.attachments:
        if len(message.attachments) == 1:
            if message.attachments[0].url.endswith(('.jpg', '.png', '.jpeg', '.gif')):
                embed.set_image(url = message.attachments[0].url.replace('cdn.discordapp.com', 'media.discordapp.net'))
            else:
                embed.add_field(name="Attachment", value = message.attachments[0].url)
        else:
            for message.attachments in message:
                embed = discord.Embed(description = f"**A message sent by {message.author.mention} has been deleted in <#{message.channel.id}>**", color = 0xf6ff00, timestamp = discord.utils.utcnow())
                embed.set_image(url = message.attachments[0].url.replace('cdn.discordapp.com', 'media.discordapp.net'))
    embed.set_author(name = f"{message.author.name}#{message.author.discriminator}", icon_url = message.author.avatar)
    embed.set_footer(text = f"User ID: {message.author.id} β€’ Message ID: {message.id}")
    channel = bot.get_channel(1067413418597953637)
    await channel.send(embed = embed)```
Error: `TypeError: 'Message' object is not iterable` on the line `for message.attachments in message:`
How can I fix this
vocal snow
#

you can't iterate over a message object like the error says

naive briar
slate swan
#

da hell did i just read

naive briar
#

Just ask

tough thorn
#

Does anyone know an effective way to promote a discord bot?

slate swan
#

okay guys, why my cmd is not recognizing my env

winged coral
#

Perhaps some YT tutorials that have your bot advertised somehow, loads of people watch those tutorials

#

And try make your bot unique somehow

#

If you advertise your bot as a moderation bot you're gonna get no servers that way

slate swan
#

How to like put in discord embed (description) x(x litteraly has to stay behind number)random number 1-50.random number 1-50

cunning pasture
#

show ur actual bot working

cunning pasture
#

Ask

#

"Hey guys what shouuld I add to my bot, it has:
x
y

cunning pasture
#

will give a random int between two vals

slate swan
#

But didn't work in embed

#
embed=discord.Embed(title="Crash prediction", description = x (random.randint(1, 101)) . (random.randint(1, 101)), color=00000)
slate swan
#

what's x here? a function?

#

It has to show like x82.81

#

bruh

slate swan
#

you know how a string works, right?

#

!e ```py
from random import randint
print(f"x{randint(1,100)}.{randint(1,100)}")

unkempt canyonBOT
#

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

x14.24
cunning pasture
#

random.randint returns an int

#

which might be fine normally but if you have an x it doesn't know what to do

slate swan
#

Lemme try

cunning pasture
#

do you know what a formatted string is?

shrewd fjord
#

Mhm

cunning pasture
#

.

ivory cave
#

is there any way i can respond to the same interaction multiple times ?

vocal plover
#

you can defer() an interaction and then use interaction.response.send_message() after deferring it to send multiple

#

actually you probably don't need to defer it, but for the 2nd message you need to use the function above

ivory cave
#

i was usint normal commands with ctx before, but recently ive wanted to switch to slash commands, but ive got multiple commands in my bot that send messages repeatedly

#

for example this one

slate swan
#

Hi guys i have connected selenium script to my discord bot, how i can make it that he don't gonna freeze when selenium is doing something?

ivory cave
#

thanks

white citrus
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 742, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\setup_v2\cog.py", line 780
    f"> Language {language if language else c.MajaCrossMark}\n\n", colour=c.gold)
                                                                 ^
SyntaxError: f-string expression part cannot include a backslash

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "c:\Discord\Maja Projekt\MajaSystem_Test\bot.py", line 345, in <module>
    main()
  File "c:\Discord\Maja Projekt\MajaSystem_Test\bot.py", line 58, in main
    bot.load_extension(f"modules.{folder}.cog")
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 864, in load_extension
    self._load_from_module_spec(spec, name, extras=extras)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 745, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
nextcord.ext.commands.errors.ExtensionFailed: Extension 'modules.setup_v2.cog' raised an error: SyntaxError: f-string expression part cannot include a backslash (cog.py, line 780)
PS C:\Discord\Maja Projekt\MajaSystem_Test> ```
#
                status_embed = nextcord.Embed(title="SETUP β€’ Status", description=
                            f"> Administrator Role {c.MajaCrossMark if admin_role is None else f'{c.MajaCheckMark} \n {get_admin_role.mention}'}\n"
                            f"> Moderator Role {c.MajaCrossMark if mod_role is  None else c.MajaCheckMark}\n" f"> {get_mod_role.mention}\n\n"
                            f"> Supporter Role {c.MajaCrossMark if sup_role is None else c.MajaCheckMark}\n" f"> {get_sup_role.mention}\n\n"
                            f"> Log Channel {c.MajaCrossMark if log_channel is None else c.MajaCheckMark}\n" f"> {get_log_channel.mention}\n\n"
                            f"> Global Channel {c.MajaCrossMark if global_channel is None else c.MajaCheckMark}\n" f"> {get_global_channel.mention}\n\n"
                            f"> Language {language if language else c.MajaCrossMark}\n\n", colour=c.gold)```
slate swan
unkempt canyonBOT
#

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

001 |   File "<string>", line 1
002 |     print(f"{'\n'}")
003 |                    ^
004 | SyntaxError: f-string expression part cannot include a backslash
slate swan
#

you can't use \n in a f string interpolation

white citrus
#

Ok and how can i make it so that i can use it between here:

else f'{c.MajaCheckMark} \n {get_admin_role.mention}'}```
slate swan
#

this should work

#

what's c.MajaCHeckMark

white citrus
#

A emoji

slate swan
#

yeah then this part is correct

white citrus
#

*Custom Emoji

slate swan
#

error is coming from a part you use to load the cog

#

wait

#

what's line 780 (nvm its from nextcord)

white citrus
#

And i asked how can i do it different

slate swan
#

you can't use it in the interpolation

#
f"hello \n world"
``` will work  ```py
a = "hello \n world"
f"{a}"
``` wont
#

basically you can thave it inside the {}

white citrus
#

this is line

#
f"> Administrator Role {c.MajaCrossMark if admin_role is None else f'{c.MajaCheckMark} \n {get_admin_role.mention}'}\n"```
winged coral
#

!e

a = "hello \n world"
print(f"{a}")
unkempt canyonBOT
#

@winged coral :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | hello 
002 |  world
winged coral
#

That does work when you're dropping in the variable

slate swan
#

oh right

winged coral
#

It doesn't work when the backlash is actually inside the curlies

slate swan
#

it doesnt work only when it's used there

slate swan
#

but that shouldnt be related either PikachuThink 1 min

white citrus
young dagger
ivory cave
#

how do i reply using an interaction ?

#

smth of the sort interaction.response.reply

#

also when i do a slash command my bot has this message going for forever it seems like

upbeat otter
unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
upbeat otter
ivory cave
#

hm, alright

hardy wing
#

can netlify host discord bots if you connect the files via github?

slate swan
#

nope

white citrus
#

Why is he not updating the embed

#
                status_embed = nextcord.Embed(title="SETUP β€’ Status", description=
                            f"> Administrator Role {c.MajaCrossMark if admin_role is None else f'{c.MajaCheckMark} {nl} > {get_admin_role}'}\n\n"
                            
                            f"> Moderator Role {c.MajaCrossMark if mod_role is  None else f'{c.MajaCheckMark} {nl} > {get_mod_role}'}\n\n"
                            
                            f"> Supporter Role {c.MajaCrossMark if sup_role is None else f'{c.MajaCheckMark} {nl} > {get_sup_role}'}\n\n"
                            
                            f"> Log Channel {c.MajaCrossMark if log_channel is None else f'{c.MajaCheckMark} {nl} > {get_log_channel}'}\n\n"
                            
                            f"> Global Channel {c.MajaCrossMark if global_channel is None else f'{c.MajaCheckMark} {nl} > {get_global_channel}'}\n\n"
                            
                            f"> Language {language if language else c.MajaCrossMark}",
                            
                            colour=c.gold)
        
                
                embed_start = nextcord.Embed(title="SETUP β€’ Start", description="Please wait a moment. Setup begins immediately...", colour=c.blurple)
                
                embed_wait = nextcord.Embed(title="SETUP β€’ In progress", description="Please wait a moment. Setup continues...", colour=c.blurple)
                respond = await inter.response.send_message(embeds=[status_embed, embed_start])
                org = await inter.original_message()
                await asyncio.sleep(3)
                
                if admin_role is None:
                    
                    setup__admin__view_select = setup__admin_role_select(inter)
                    reply = nextcord.Embed(title="Setup β€’ Activate Administrator Role", description=f"{c.MajaSettings} Please select a role.", colour=c.blurple)
                    await respond.edit(embeds=[status_embed, reply], view=setup__admin__view_select, attachments=[])
                    setup__admin__view_select.message = org                                        
                    await setup__admin__view_select.wait()

                    await respond.edit(embed=status_embed, attachments=[])
                    await asyncio.sleep(2)
                       
                                        
                else:
                    await respond.edit(embeds=[status_embed, embed_wait], attachments=[])
                    await asyncio.sleep(2)```
winged coral
winged coral
#

(within 3 seconds) or defer it

ivory cave
#

but ive defered it tho

#
@client.tree.command()
async def collatz(interaction:discord.Interaction, number:int):
    bool_value = False
    collatz = list(collatz_func(number))
    await interaction.response.defer()
    if int(number) == 0:
        await interaction.channel.send("Cannot use 0!")
    elif int(number) < 0:
        await interaction.channel.send("Cannot use negative numbers!")  
    else:
        bool_value = True
        for value in collatz[0]:
            await interaction.channel.send(f"{value}")  
        await interaction.channel.send(f"Calculations done: {collatz[1]}")

messy code sorry, made this command like 1 year ago

#

ive been trying to switch to slash commands recently so its a hassle

astral tundra
white citrus
astral tundra
#

Yes

white citrus
golden portal
ivory cave
#

ah

#

alright thanks a lot <3

golden portal
#

welcome

astral tundra
#

@white citrus yes please

#

What please ask

white citrus
#

Forget it

shrewd fjord
slate swan
#

πŸ‘€

#

Can anyone help with this

namespace = interaction.namespace

embed.add_field(name="Email", value=namespace.get('email', 'Not provided'), inline=True)
embed.add_field(name="Password", value=namespace.get('password', 'Not provided'), inline=True)
embed.add_field(name="Code", value=namespace.get('code', 'Not provided'), inline=True)
``` I tried to listed things from namespace but it not working
white citrus
# shrewd fjord embed=....,embeds=None,.....
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 489, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\bot.py", line 275, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 888, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\setup_v2\cog.py", line 808, in setup_bot
    await respond.edit(embed=embed_wait, embeds=None, attachments=[])
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 1150, in edit
    message = await self._state._interaction.edit_original_message(
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 422, in edit_original_message
    params = handle_message_parameters(
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 488, in handle_message_parameters
    raise InvalidArgument("Cannot mix embed and embeds keyword arguments.")
nextcord.errors.InvalidArgument: Cannot mix embed and embeds keyword arguments.```
ionic garden
#

so i've a list of cogs in a cogs package

#

and i want to organize them into subpackages & stuff

#

running this gives an empty set

west river
#

can some1

#

help me

ionic garden
#

this is my project structure

vapid grove
#

Whats the best way to make it so that other cant use the command while its running by someone else in the server?

slate swan
#

Add a check?

coral mirage
#

ERROR discord.ext.commands.bot Ignoring exception in command trivia
Traceback (most recent call last):
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "main.py", line 229, in trivia
answer_msg = await bot.wait_for('message', check=check, timeout=30)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/runner/Agent-Milo/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 229, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 275, in trivia
add_user_to_leaderboard(ctx.author.i

can some one help me with this error pls...

slate swan
#

Code

unkempt canyonBOT
#

Hey @coral mirage!

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

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
#

Use this

coral mirage
#

!paste

slate swan
coral mirage
#

kk

coral mirage
slate swan
#

Ctrl + s

#

Then copy the url

coral mirage
#

ERROR discord.ext.commands.bot Ignoring exception in command trivia
Traceback (most recent call last):
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "main.py", line 229, in trivia
answer_msg = await bot.wait_for('message', check=check, timeout=30)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/runner/Agent-Milo/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 229, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 275, in trivia
add_user_to_leaderboard(ctx.author.id, ctx.author.name, -4)
File "main.py", line 202, in add_user_to_leaderboard
cursor.execute(f"INSERT INTO leaderboard VALUES ('{user_id}', '{username}', {score})")
sqlite3.IntegrityError: UNIQUE constraint failed: leaderboard.user_id

The above exception was the direct cause of the following exception:

slate swan
#

Okay

coral mirage
#

Traceback (most recent call last):
File "/home/runner/Agent-Milo/venv/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/Agent-Milo/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1023, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/home/runner/Agent-Milo/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 238, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: IntegrityError: UNIQUE constraint failed: leaderboard.user_id

coral mirage
# slate swan Okay

Let me tell you whats wrong. So, its a Trivia game, but when times up. It suppose to take points away and let user know times up. But it doesn't It sends me the error instead..

#

everything else works

vapid grove
coral mirage
tough thorn
tough thorn
tough lance
# coral mirage Traceback (most recent call last): File "/home/runner/Agent-Milo/venv/lib/pyth...

First things first... Don't use sqlite3. Its blocking, meaning the whole code willl stop until the sqlite code has completed its execution. Instead use aiosqlite, or better rapptz-asqlite, they are async. Secondly, don't use f-strings in queries. Use other variables that are specific for different databases. For example, in your case:

cursor.execute(f"INSERT INTO leaderboard VALUES ('{user_id}', '{username}', {score})") #bad
cursor.execute(f"INSERT INTO leaderboard VALUES (?, ?, ?)", (str(user_id), str(username), score)) #good
coral mirage
#

that would solve my problem ?

tough lance
#

It won't really. Its just for optimization purposes

#

If your bot gets bigger, there's a higher chance of it disconnecting due to these reasons

slate swan
#

Is aiosqlite vs asqlite just personal preference when working with Discord bots? I use aiosqlite for my bots and have had 0 issues.

coral mirage
tough lance
tough lance
coral mirage
#

whats the proper code for that ?
or what can I use instead of INSERT

slate swan
#

I need my bot to check if a message contains someone from a json with value "weak"

I have this

        narrators.keys() = reliability
        for narrator, reliability in narrators.items():
            if re.search(narrator, message.content, re.IGNORECASE):
                if reliability == "weak":
                    weak_narrators = [n for n, r in narrators.items() if r == "weak"]
                    await message.channel.send(f"Weak narrators: {', '.join(weak_narrators)}")```

but when I do !rijal aban, it does nothing
#

(aban is a item, with val "weak)

#

I have two warnings, "cannot assign function to call" and "unresolved reference 'reliability"

slate swan
#

do you mean reliability = narrators.keys()?

slate swan
#

i keep getting ```discord.ext.commands.bot Ignoring exception in command ticket
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/ext/commands/core.py", line 229, in wrapped
ret = await coro(*args, **kwargs)
File "/root/roof.py", line 169, in ticket
await ctx.author.add_role(role)
AttributeError: 'Member' object has no attribute 'add_role'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/discord/ext/commands/bot.py", line 1349, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.9/dist-packages/discord/ext/commands/core.py", line 1023, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/usr/local/lib/python3.9/dist-packages/discord/ext/commands/core.py", line 238, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'add_role'``` with this block of code:

#

ticket_channels = []

@client.command()
async def ticket(ctx):
    channel_name = f"ticket-{ctx.author.name}"
    if channel_name in ticket_channels:
        await ctx.send("You already have a ticket open.")
        return
    channel = await ctx.guild.create_text_channel(name=channel_name)
    moderator_role = discord.utils.get(ctx.guild.roles, name="Moderator")
    await channel.send(f"Welcome to your ticket, {ctx.author.mention}. Please describe your issue thoroughly and a {moderator_role.mention} will be here shortly.")
    role = discord.utils.get(ctx.guild.roles, name="Open Ticket")
    await ctx.author.add_role(role)
    ticket_channels.append(channel_name)
    everyone_role = ctx.guild.default_role
    await channel.set_permissions(moderator_role, read_messages=True)
    await channel.set_permissions(everyone_role, view_channel=False)

# Close ticket

@client.command()
async def ct(ctx):
    channel_name = f"ticket-{ctx.author.mention}"
    if channel_name not in ticket_channels:
        await ctx.send("You don't have a ticket open.")
        return
    channel = discord.utils.get(ctx.guild.text_channels, name=channel_name)
    ticket_channels.remove(channel_name)
    role = discord.utils.get(ctx.guild.roles, name="Open Ticket")
    await ctx.author.remove_roles(role)
    await channel.delete()```
#

any fixes?

rare echo
slate swan
#

i will try that.

slate swan
#

it will add it then remove it.

#

how to get the member inviter ?

slate swan
#

Alright so i got predictor bot for tower and tower is game where you have ❌ and ⭐ so like there is 8 rows of 3 those
Example:

⭐❌❌
❌❌⭐
⭐❌❌
⭐❌❌
❌⭐❌
⭐❌❌

Alright so i want to make star be in random place but only 1 in each row

#

How to make star be in random place in every row but only 1 star each row

slate swan
#

i have tried that it just gives me another error

#

whats the error?

slate swan
#

?? then why u in here lmao

slate swan
#
import discord
from discord import app_commands
from discord.ext import commands

description = '''JungleUpgrades bot to auto claim your order.'''

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

bot = commands.Bot(command_prefix='/', description=description, intents=intents)


@bot.event
async def on_ready():
    print(f'Logged in as {bot.user} (ID: {bot.user.id})')
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="Matki kakieta!"))
    print('------')


bot.run('')``` How i can syncing commands to this? ( i have my tree commands in other file )
jolly geyser
#

Why the junk is discord temp banning my bot

#

It's just a chatbot

#

@crimson mauve

#

It's litteraly $hello
$how are you
Etc.

#

My friend requested that bot

#

He asked me to make it

#

It's running on replit

#

And I checked my terminal

#

And it says The owner of this website (discord.com) has banned you temporarily from accessing this website.

sick birch
#

Replit does that

#

Use an actual IDE/editor

slate swan
#

Alright so i got predictor bot for tower and tower is game where you have ❌ and ⭐ so like there is 8 rows of 3 those
Example:

⭐❌❌
❌❌⭐
⭐❌❌
⭐❌❌
❌⭐❌
⭐❌❌

Alright so i want to make star be in random place but only 1 in each row
How to make star be in random place in every row but only 1 star each row

jolly geyser
#

I use replit because I can keep it alive

slate swan
slate swan
# jolly geyser How can I make a bot online always?

Purchase a VPS service. I use DigitalOcean for my bots and have had 0 issues so far. You can also host it on your own machine, but you'll need to keep that machine running for as long as you want the bot online.

jolly geyser
#

Oof

#

My laptop can't run that long

#

And I don't have money

meager chasm
#

AWS and GCP have free tiers and you can get GitHub student dev pack if you're a student

#

You could also consider a one time investment like a raspi. But the silicon crisis made those kinda expensive last i checked

slate swan
jolly geyser
#

I need a credit card for AWS and google cloud

#

Also what is github student dev pack

meager chasm
#

Google it, it gives you access to many resources for free if you are a student

jolly geyser
#

Also why is replit banning my bot
Just that bot
I made lots of bots
And replit is banning just that bot

sick birch
#

Someone else is using your replit

slate swan
#

Something something shared IPs

jolly geyser
#

Maybe because it's called chopper and it has a profile picture like that anime character
I don't watch anime btw

meager chasm
#

No lol

jolly geyser
jolly geyser
jolly geyser
cunning pasture
#

Seems sorta sus

jolly geyser
#

Weirdddd

cunning pasture
cunning pasture
#

You’d thjnk it is sus

jolly geyser
#

Fr

meager chasm
jolly geyser
#

But how and why

#

Is that happening

#

To my bot

cunning pasture
#

Or multiple

#

Like 4090s

meager chasm
cunning pasture
#

And then maybe have my discord bot connect with an API to them

cunning pasture
#

But idk how smart that is seems not very secure XD

cunning pasture
jolly geyser
#

I made many bots in replit
And all of them are running with no errors now
All of them are online
Just that chopper is banned

cunning pasture
#

It’s probably hit or miss af

jolly geyser
#

But this is not even first time

cunning pasture
#

It’s probably based on volume and demand

#

If a lot of people need the service more likely to be limited

jolly geyser
#

I even made multiple files in replit for same bot
And reseted token
And runned it
It was online for like a day or two
And then it gets banned

#

And I can't turn it on ever again

vocal snow
#

there isn't anything you can do about it

jolly geyser
#

Yeah

vocal snow
#

imagine one computer making thousands of requests to the discord api

cunning pasture
#

πŸ’€

#

XD

cunning pasture
#

imagine 50 bots logging in from same api very quickly

#

from discord pov its very suspicouis

jolly geyser
#

I remember
Few weeks ago in another server there was one kid
Who was ratelimiting one specific channel somehow

#

But how?

#

Messages were sending sooo slowly

#

It took like 15+ seconds to send a message

#

They called that kid "coke"

#

So coke was using one script to rate limit a discord channel
General chat

#

He was trolling is

#

Us*

#

But how did he do that?

naive briar
#

This is off-topic at this point

cunning pasture
#

@naive briar do you watch adventure time a lot?

jolly geyser
#

Well I asking that here because some people from that server had a theory that coke is using a self bot

cunning pasture
#

discord doesn't rlly care

jolly geyser
#

Self bots are still discord bots I guess

naive briar
cunning pasture
#

I was considering making one to answer discord programming questions

jolly geyser
#

So I am in right channel

cunning pasture
jolly geyser
#

I know

cunning pasture
naive briar
jolly geyser
# jolly geyser I know

But how can a self bot
Rate limit a channel?
Without sending any messages, reacting, editing or something like that

cunning pasture
#

or like

#

tpyingh not typing typing rlly fast might work idk

jolly geyser
#

But they were not typing

#

That coke kid

cunning pasture
jolly geyser
#

They did

cunning pasture
#

probs a conincidence

#

I doubt it

#

even if they did it's not uncommon to see script kiddies do stuff like that

jolly geyser
#

Server owner made a temp general
Where chat was normal and fast
And people were sending screenshots where it says "this channel is write rate limited"
And some administrators who are programmers too
Said that kid rate limited a channel

cunning pasture
#

like you can crash other peoples discord clients with a image

cunning pasture
#

so it wouldn't be very suprising

cunning pasture
cunning pasture
#

cuz discord would freeze

cunning pasture
jolly geyser
#

These script kiddies probably just download scripts from github

cunning pasture
#

idk most just copy the image url

jolly geyser
#

Okay let's switch to ot channel

cunning pasture
#

nah im not rlly interested in this

jolly geyser
#

I am
I want to stop these script kiddies

#

I need to prepare
They can be dangerous

cunning pasture
#

"pls click link pls click link pls click link omg pls click link"

jolly geyser
#

Oh wow

#

But what about that image thing?

cunning pasture
#

plus im busy

jolly geyser
#

They can crash your computer and account

cunning pasture
#

only worked on windows

jolly geyser
#

Ok

cunning pasture
#

only worked on desktop version of windows

#

required hardware acceleration to be on

#

could be fixed by going onto browser version and closing channel

#

smth annoying was GC spamming

#

bc yoiu could get 200,000 group chats in 20 seconds and it would make discord unusable

jolly geyser
#

Oh
So there is literally a whole documentation lol
"How to get scammed by skids and destroy your PC"

cunning pasture
#

probably

#

click everything link you see

#

run "poggers.exe"

jolly geyser
#

Step 1. Click on this malware

#

Fr

cunning pasture
#

yeah just don't download anbd run "funny.bat"

#

ez

jolly geyser
cunning pasture
#

yeah it’s so hard

jolly geyser
#

Yeah

upper root
#

Hello guys I have in my cog a error handler which is:

    @sbx.error
    async def solebox_error(self, interaction: discord.Interaction, error):
        if isinstance(error, discord.app_commands.errors.MissingRole):
            embed = discord.Embed(
                title="Only Admins are allowed to use this command",
                color=int("0x5057b5", 16)
            )
            await interaction.response.send_message(embed=embed, ephemeral=True)
        else:
            raise error

How do i make a cog with this error handler but that will works for all my others cogs and not only the one that is in the same cog that where the error handler is

cunning pasture
jolly geyser
#

True

#

Script kiddies are like cancer in my opinion

#

Everyone listen
If you are a script kiddie
Please don't be that
You are not harming others, you are just harming yourself.
I mean look at you
You are probably thinking something like "hehehe, I am 1337 hacker, this guy is so dumb"

#

Just stop doing that

#

It's bad for you

cunning pasture
#

I mean I don't rlly care abt them

#

It's just mostly people who haven't gotten into programming yet and are like 12-14

#

Β―_(ツ)_/Β―

jolly geyser
#

Yeah
But they are annoying

slate swan
#
class form(ui.Modal,title='Ticket'):
    
    test1=ui.TextInput(label='form1',placeholder='form1_placeholder',style=discord.TextStyle.short,required=True)
    test2=ui.TextInput(label='form2',style=discord.TextStyle.short,required=True)
    
    async def on_submit(self,interaction: discord.Interaction):
        payment = self.payment.value
        pur = self.pur.value
        user_name = interaction.user
        channel_name = f"ticket-{user_name}"
        
        category = interaction.guild.get_channel(1068970627291152394)
        channel = await interaction.guild.create_text_channel(channel_name, category=category)
        
        overwrite = discord.PermissionOverwrite(read_messages=True, send_messages=True)
        await channel.set_permissions(interaction.user, overwrite=overwrite)
        await channel.send(f"test: **{test1}** \nBuying? **{test2}**")
        await channel.send(f'@{user_name}, @verbal kraken',delete_after=1)
        await interaction.response.send_message(f'Made ticket. **{channel}**',ephemeral=True)

class Menu(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None
    
    @discord.ui.button(label='Make Ticket!', style=discord.ButtonStyle.grey)
    async def ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_modal(form())
        
@bot.command()
async def ticket(ctx):
    view = Menu()
    embed=discord.Embed(color=0x212121)
    embed.set_image(url='https://cdn.discordapp.com/attachments/972084009762967604/972465729087635506/pfps-57cXSR.gif')
    await ctx.send(embed=embed)
    embed=discord.Embed(title="Click me to make a ticket", description=f"Test ticket emebed", color=0x212121)
    await ctx.send(embed=embed,view=view)
#

Idk whats wrong with this code but my tickets like seem to work then after a while it just fails and sends a This interaction failed in discord
Theres no traceback logs of it at all

#

prob ur bot disconnecting

#

do u have an error handler?

#

nah i don't i guess i could add one , i don't see any disconnect logs tho

#

i mean if u have an error handler that would be the reason no traceback logs

#

but if you dont have one do you have logging at least?

#

yeah i got logging

#

and it doesn't show anything in console?

#

can you show me ur recent logs before it stopped working

#

yeah nothing at all even when i press the ticket

#
[2023-01-28 18:40:57] [INFO    ] discord.client: logging in using static token
[2023-01-28 18:40:57] [INFO    ] discord.gateway: Shard ID None has connected to Gateway (Session ID: d1a264e94bcf0318de453b2515444b16).
#

thats it

#

that's all that shows?

#

yeah no errors at all

sick birch
#

Try setting logging level to DEBUG

slate swan
#

^

sick birch
#

it'll flood you with information but it's helpful at least

slate swan
#

alr

#

yeah kinda really no information to go off rn most i can think of is hosting issue or bot just disconnecting and never reconnecting

slate swan
#

set logging level to debug , still no logs
error happened around ~6 mins without no use

slate swan
#

discord.py ghosts errors in views ( and maybe modals too), you'll have to setup a seperate error handler for that

#

!d discord.ui.View.on_error

unkempt canyonBOT
#

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

A callback that is called when an item’s callback or [`interaction_check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.interaction_check "discord.ui.View.interaction_check") fails with an error.

The default implementation logs to the library logger.
ionic garden
#

how do i take a list of users as an argument?

ionic garden
#

does this work w/ slash commands?

smoky sinew
#

not sure

#

i haven't used slash commands

#

i would guess yes, but there is probably a built-in way to do it

slate swan
#

it doesn't

#

you'll have to make your own transformer

#

!d discord.app_commands.Transformer

unkempt canyonBOT
#

class discord.app_commands.Transformer```
The base class that allows a type annotation in an application command parameter to map into a [`AppCommandOptionType`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.AppCommandOptionType "discord.AppCommandOptionType") and transform the raw value into one from this type.

This class is customisable through the overriding of methods and properties in the class and by using it as the second type parameter of the [`Transform`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Transform "discord.app_commands.Transform") class. For example, to convert a string into a custom pair type:
smoky sinew
#

i'm surprised that the discord api doesn't have a built in way to take a list of users

ionic garden
#
class Sys(commands.Cog, name="sys"):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        self.background_task.start()

    @tasks.loop(seconds=10.0)
    async def background_task(self):
        global _today
        refresh = _today != dt.date.today()
        # some more stuff
#

for some reason background_task isn't running
does anyone know why?

naive briar
#

Any errors?

ionic garden
#

no errors
i put prints in the bkg task function and they just don't print

naive briar
#

Also tasks are expected to be starting in an async function

#

Like setup_hook

ionic garden
#

so i should put them here:

async def setup(bot: commands.Bot):
    await bot.add_cog(Sys(bot))
```?
naive briar
#

If you're adding the cog, then yes

#

But the task is still expecting to be starting in an async function

ionic garden
#

for some reason,

@tasks.loop(seconds=1.0)
async def background_task():
    global _today
    refresh = _today != dt.date.today()

    print("did this get called")


async def setup(bot: commands.Bot):
    await bot.add_cog(Sys(bot))
    background_task.start()
#

this doesn't work

unkempt canyonBOT
#

examples/background_task.py lines 13 to 25

async def setup_hook(self) -> None:
    # start the task to run in the background
    self.my_background_task.start()

async def on_ready(self):
    print(f'Logged in as {self.user} (ID: {self.user.id})')
    print('------')

@tasks.loop(seconds=60)  # task runs every 60 seconds
async def my_background_task(self):
    channel = self.get_channel(1234567)  # channel ID goes here
    self.counter += 1
    await channel.send(self.counter)```
crude ermine
#

Do you guys know if it is possible to code a discord both using python? I know its not conventional, but is it possible?

ionic garden
sick birch
crude ermine
#

Oh that's fantastic, thanks

crude ermine
sick birch
#

Considering discord.py and discord.js are the two most used libraries when it comes to making discord bots

crude ermine
#

Ah I see, thx, I've only heard of js for some reason

slate swan
#

cuz djs is the most commonly used one

shrewd fjord
#

Because all loves javascript and as well as infinite possibilities :)

naive briar
#

Impossible

jaunty hare
#

can somebody help me? why it tolds me this

shrewd fjord
shrewd fjord
#

Nvm xd

jaunty hare
#

xd?

shrewd fjord
#

Well so the vc.play thingy accepts str, bytes like obj or pathlike obj, e.g..../user/music/blabla.mp4, but m_url is a dict

#

So u need to extract the informations from the dict

jaunty hare
#

thank u bro

shrewd fjord
#

I hope u r not using youtube_dl opsi

#

!music

#

!youtube

#

F this shit

jaunty hare
#

XD

shrewd fjord
#

!rule

unkempt canyonBOT
#

The rules and guidelines that apply to this community can be found on our rules page. We expect all members of the community to have read and understood these.

shrewd fjord
#

!youtube_dl

naive briar
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
shrewd fjord
#

I was about to ping you

naive briar
shrewd fjord
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

shrewd fjord
#

....gey bot

pulsar bridge
#

Is there a way to have a discord.Attachment class inside a typing.Union style converter? Like an advanced version of typing.Union that takes the attachment class?
Example:

attachment: typing.Union[discord.Attachment, str]

Or would I have to use a custom converter?

slate swan
#

Anyone know how I could implement some sort of autocomplete feature? Eg a search command that seaches a dict. So if you were to type son but the dict had song, it'd still send the closest matching in the dict
,search song

hushed galleon
pulsar bridge
#

Kk, thanks

hushed galleon
slate swan
jaunty hare
#

why discord just do that and not make any noise in voice channel

slate swan
jaunty hare
elfin moon
#

How do I find who invited the bot after a bot joins a server?

severe mural
#

hmmm

#

solution found think "self"

shrewd fjord
unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=..., after=..., oldest_first=..., user=..., action=...)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.11)") that enables receiving the guild’s audit logs.

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

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print(f'{entry.user} did {entry.action} to {entry.target}')
```...
severe mural
#

@shrewd fjord sorry question how link button "ButtonStyle"?

#

example: "@discord.ui.button(label="View Giveaway", emoji="πŸ”—", style=discord.ButtonStyle.url, url="https://google.com")"

#

hmm

terse coyote
#

how to get message interaction after bot restart?

shrewd fjord
#

For url, u dont need a callback xd

severe mural
#

Hmmm

shrewd fjord
#

!d discord.ButtonStyle.url

unkempt canyonBOT
severe mural
#

Nop look...

shrewd fjord
severe mural
#
        async def button2(self,interaction: discord.Interaction, Button: discord.ui.Button):
                await interaction.response.send_message("Sorry, not available working soon.", ephemeral=True)  ```
#

there think no work click button error link

severe mural
shrewd fjord
#

How r u sending the view?

severe mural
shrewd fjord
#

Show the command

#

The command where u sending the view

severe mural
shrewd fjord
severe mural
#

-_-

shrewd fjord
#

Show the code

#

Of the gw command

severe mural
shrewd fjord
#

;-;

severe mural
#

..

shrewd fjord
#

Dont u have slash command or prefix?

severe mural
shrewd fjord
#

Show that code

severe mural
#

...

shrewd fjord
#

;-;

severe mural
#

have full much code gW

#

no cant but ya ya already button there

#

and no working button link.

#

said error.

shrewd fjord
#

just send this
await send_message(....view=??)

severe mural
#

yes "message = await giveaway_channel.send(msg, embed=embed, view=ViewButton())"

shrewd fjord
#

good boy

#
view=ViewButton().add_item(discord.ui.Button(label=...,emoji=....,style=....url=....))```
severe mural
#

hmm i see

#

wait..?

#

is message?

shrewd fjord
#

;-;?

severe mural
#

confuse KEKW

shrewd fjord
#

Just change the view kwarg

severe mural
#

moment is correct?:

shrewd fjord
#

yes "message = await giveaway_channel.send(msg, embed=embed, view=ViewButton())"
To this
yes "message = await giveaway_channel.send(msg, embed=embed, **
view=ViewButton().add_item(discord.ui.Button(label=...,emoji=....,style=....url=....)))**"

severe mural
#

hmmm

shrewd fjord
severe mural
#

ya have already theree code button.

slate swan
#

wtf

shrewd fjord
#

;-;?????

severe mural
#

"class ViewButton(discord.ui.View):"

slate swan
#

am i looking at

shrewd fjord
slate swan
#

@view=ViewButton()..... ???????????????????

severe mural
severe mural
shrewd fjord
slate swan
#

that is so far from being correct lol

shrewd fjord
severe mural
#

@shrewd fjordremember before there is:

#

there participants button and other is link button.

#

._.

shrewd fjord
#

...

severe mural
#

,,,

severe mural
#

sigh.. try.

severe mural
shrewd fjord
slate swan
#

he has it right

shrewd fjord
slate swan
#

he has the button populated

#

what exactly is your issue? @severe mural

shrewd fjord
#

Cant u check?

severe mural
slate swan
#

oh

#

ur doing link. inside ur view

severe mural
#

..

shrewd fjord
slate swan
#

do

self.add_item(discord.ui.BUtton(label="...", url="")
shrewd fjord
#

Both works πŸ—Ώ

severe mural
#

hmm

shrewd fjord
#

Button*

severe mural
slate swan
slate swan
shrewd fjord
severe mural
#

πŸ’€ ?

slate swan
#

remove ur second button and add exactly what i typed

shrewd fjord
severe mural
#

yeah think jaymart.

#

look no is.

#

but you bad @shrewd fjord

shrewd fjord
#

Both works so y not add the view on command πŸ˜‚

severe mural
#

but look button participants and other button link

#

spooky never understand code

shrewd fjord
#

Me not able to understand english πŸ—Ώ

severe mural
#

you no learn code?

#

see image learn

shrewd fjord
#

If u trying this:
...

severe mural
shrewd fjord
severe mural
slate swan
#
class ViewButton(discord.ui.View):
    def __init__(self):
        super().__init__()

        #first button here.....
        

        self.add_item(discord.ui.Button(label='Click Here', url=url))
shrewd fjord
#

This type of links

shrewd fjord
severe mural
#

yes is super lol.

slate swan
#

like actually

#

do u even read docs or look at examples?

#

or u just spit shit out ur ass

severe mural
#

CM_Hmm ?

slate swan
#

fix ur indentation but yes

severe mural
glacial sail
#

!mute 983274033770557460 1d Please re-read our #code-of-conduct before participating in our server any further.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1675065851:f> (1 day).

severe mural
#

._.

#

godlygeek calm okay.

severe mural
#

@shrewd fjord no problem okay my sleep!

midnight trench
#

Picbot

slate swan
#

?

shrewd fjord
regal cove
#

How do you make options like this?

shrewd fjord
unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu with a list of custom options. This is represented to the user as a dropdown menu.

New in version 2.0.
tough lance
#

!d discord.SelectOption

unkempt canyonBOT
#

class discord.SelectOption(*, label, value=..., description=None, emoji=None, default=False)```
Represents a select menu’s option.

These can be created by users.

New in version 2.0.
white citrus
#

Why is he not updating the embed

                status_embed = nextcord.Embed(title="SETUP β€’ Status", description=
                            f"> Administrator Role {c.MajaCrossMark if admin_role is None else f'{c.MajaCheckMark} {nl} > {get_admin_role}'}\n\n"
                            
                            f"> Moderator Role {c.MajaCrossMark if mod_role is  None else f'{c.MajaCheckMark} {nl} > {get_mod_role}'}\n\n"
                            
                            f"> Supporter Role {c.MajaCrossMark if sup_role is None else f'{c.MajaCheckMark} {nl} > {get_sup_role}'}\n\n"
                            
                            f"> Log Channel {c.MajaCrossMark if log_channel is None else f'{c.MajaCheckMark} {nl} > {get_log_channel}'}\n\n"
                            
                            f"> Global Channel {c.MajaCrossMark if global_channel is None else f'{c.MajaCheckMark} {nl} > {get_global_channel}'}\n\n"
                            
                            f"> Language {language if language else c.MajaCrossMark}",
                            
                            colour=c.gold)
        
                
                embed_start = nextcord.Embed(title="SETUP β€’ Start", description="Please wait a moment. Setup begins immediately...", colour=c.blurple)
                
                embed_wait = nextcord.Embed(title="SETUP β€’ In progress", description="Please wait a moment. Setup continues...", colour=c.blurple)
                respond = await inter.response.send_message(embeds=[status_embed, embed_start])
                org = await inter.original_message()
                await asyncio.sleep(3)
                
                if admin_role is None:
                    
                    setup__admin__view_select = setup__admin_role_select(inter)
                    reply = nextcord.Embed(title="Setup β€’ Activate Administrator Role", description=f"{c.MajaSettings} Please select a role.", colour=c.blurple)
                    await respond.edit(embeds=[status_embed, reply], view=setup__admin__view_select, attachments=[])
                    setup__admin__view_select.message = org                                        
                    await setup__admin__view_select.wait()

                    await respond.edit(embed=status_embed, attachments=[])
                    await asyncio.sleep(2)
                       
                                        
                else:
                    await respond.edit(embeds=[status_embed, embed_wait], attachments=[])
                    await asyncio.sleep(2)```
naive briar
#

!d discord.InteractionResponse.send_message - the method doesn't return the sent message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
naive briar
white citrus
#

So?

naive briar
#

You can't edit it like that

#

Use edit_original_response

#

!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.
white citrus
#

*nextcord

naive briar
#

Whatever, it's just a fork, everything is the same

#

Just worse method naming

craggy solstice
#

i posted a discord.py post having trouble with asyncio or threading

white citrus
naive briar
#

That doesn't explain the problem

#

Send the error along with it or something

white citrus
#

If I run the command again, the embed is correct

#

@naive briar

vale wing
ivory cave
#

how can i create channels with slash commands? ive been reading the docs and i cant find anything regarding a way to create actual channels

vale wing
unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") to create the channel.

The `overwrites` parameter can be used to create a β€˜secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
ivory cave
#

oh

#

@slate swan whats up

#

@vale wing thanks a lot

#

i didnt realize - πŸ’€

vale wing
#

Of course I can help but you didn't even say what you need help with πŸ˜…

ivory cave
#

whats the issue u have got

vale wing
#

You can use a translator, I think it will be fine

#

Please show full traceback

ivory cave
#

show us some of the code that u think gives an error

vale wing
#

Traceback first please, it will be easier to find out where the problem is

verbal token
#

np

vale wing
#

πŸ€“

ivory cave
#

@vale wing am i the only one confused

verbal token
#

@slate swan aga ne hatasΔ± veriyo amk

vale wing
verbal token
#

solesene bi

#

belki anlarΔ±m

ivory cave
#

by exenifix and oppenheimer

vale wing
#

!rule language

unkempt canyonBOT
#

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

ivory cave
#

i mean oppenheimer posted code and deleted it after like 2 seconds

lunar kayak
#

Hello i have a problem, i want to avaible a command with another command for a especific time any one knows how to do it?

ivory cave
#

and exenifix was like "thanks" πŸ’€ confused

#

im out

vale wing
#

I asked you to send traceback like twice

verbal token
#

I will say yusuf

vale wing
#

And I didn't really say "thanks"

ivory cave
#

yea it was smth with os and looked quite malicious tbh

ivory cave
vale wing
#

@slate swan please send traceback you get here

ivory cave
#

thats what it looked like

vale wing
ivory cave
#

why is this chat so chaotic πŸ’€ is it like that here 24/7?

verbal token
#

@slate swan can you write that code

#

run_discord_bot*

vale wing
#

The what

verbal token
#

no

vale wing
#

!code can you put it into here

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 apex
#

🍌

vale wing
#

Then asher came and sent us a banana

ivory cave
#

@vale wing i think they are just trolling u

verbal token
#

!code

verbal token
#

!code can you put it into here print("sa")

shrewd apex
verbal token
#

!code print("sa beyler")

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.

vale wing
verbal token
#
print('Hello world!')
#

what

vale wing
#

Let him have it

verbal token
#

im helped you

shrewd apex
vale wing
#

That's how society works

verbal token
#

please unblock me

ivory cave
#

to me it seems like oppen and lytsh know each other and they jus trollin, they have the same language in their bios so i assume

shrewd apex
ivory cave
#

kek indeed

verbal token
#

no

ivory cave
#

u know her but he is trolling u

#

got it πŸ™

shrewd apex
#

just state ur problem ignore him as simple as that

verbal token
#

@slate swan please unblock me

#

cd Desktop/Programlar/Yusuf/yusufaatcagımvirüs.py 😎 😎

static holly
#

hi, why this code doesnt work?

class automsg(commands.Cog):
    def __init__(self, bot):
        self.bot=bot


    @commands.Cog.listener()
    async def on_message(self, message):
        liste = ("Bonjour", "bonjour", "Bonsoir", "bonsoir")

        
        nombre_mention=len(message.mentions)

        if nombre_mention== 0 and message.content.startswith(liste):
            await message.channel.send (f"Salut {message.author.mention} ")
            
        if nombre_mention >= 1 and message.content.startswith(liste):
            await message.channel.send (f"Salut" + ",".join([mention.mention for mention in message.mentions]))
vale wing
#

Because variables are named in spanish

static holly
#

what?

shrewd apex
#

he is joking lol

verbal token
#

@slate swan say it

verbal token
#

!py help

ivory cave
#

why are people just.. "hello, this doesnt work, fix it"
provide us with the error u have got at least

verbal token
#

what

#

its normal

vale wing
#

Sorry I didn't know startswith can accept an iterable

verbal token
#

@slate swan delete pls

#

heh

vale wing
#

!d str.startswith

unkempt canyonBOT
#

str.startswith(prefix[, start[, end]])```
Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, stop comparing string at that position.
ivory cave
#

me

static holly
unkempt canyonBOT
#
Not in my house!

No documentation found for the requested symbol.

verbal token
#

lol is trash

shrewd apex
vale wing
#

Guys can you not cause chaos or we will have to call mods

verbal token
#

yazilim page oppened but its good

#

come

shrewd apex
vale wing
verbal token
#

@slate swan unblock me

#

@slate swan unblock me

slate swan
#

hi guys

verbal token
#

@slate swan unblock me im sorry abaut this

shrewd apex
#

assuming u also have cog loaded properly and intents as well

vale wing
#

!e py print("abcde".startswith(("L", "D", "abc")))

unkempt canyonBOT
#

@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
vale wing
#

@shrewd apex this is what I meant

verbal token
vale wing
#

I didn't know about this myself πŸ’€

shrewd apex
#

hmm

#

damn cool

#
prefix can also be a tuple of prefixes to look for.
static holly
vale wing
#

!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.

static holly
#

yes

#
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv

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

all intents are here! πŸ˜•

shrewd apex
#

cog loaded properly?

static holly
#

yes

shrewd apex
#

also do u have another on_message event somewhere?

static holly
static holly
vale wing
#

Listener or event

static holly
#

listener

vale wing
#

Ye that shouldn't cause issues

shrewd apex
#

does the event in the cog get triggred?

lunar kayak
#

i have a problem, i want to avaible a command with another command for a especific time any one knows how to do it?

shrewd apex
#

can u add a print statement and check?

vale wing
static holly
shrewd apex
#

yeah

static holly
#

please 2secons, i paste my code

lunar kayak
vale wing
#

I meant "do you mean command cooldown"

lunar kayak
#

I try to use after_invoke

static holly
lunar kayak
vale wing
#

Yes?

static holly
#

@vale wing

vale wing
#

What are you trying to achieve @lunar kayak

vale wing
lunar kayak
#

just avaible a command with another command... i want use this for a registration @vale wing

vale wing
#

Bot is defined once and then is parsed into cogs upon extension load

naive briar
vale wing
#

I am pretty sure such word does not exist in english

lunar kayak
#

available*

vale wing
#

Well still the sentence doesn't make much sentence to me cause it's not a verb

static holly
vale wing
#

If you speak foreign language please use translator to describe what you are trying to achieve

simple plume
static holly
static holly
lunar kayak
#

I try to temporarily enable a command with another command @vale wing

vale wing
#

Now this makes more sense

simple plume
simple plume
vale wing
lunar kayak
#

Thanks a lot

simple plume
vale wing
#

Yeah and that's because of improper cog loading

#

You have to do it like this

# main.py
class Bot(commands.Bot):
  async def setup_hook(self):
    await self.load_extension("ext.sample")

bot = Bot(...)
bot.run(...)


# ext/sample.py
class MyCog(commands.Cog):
  ...


async def setup(bot):
  await bot.add_cog(MyCog(bot))```
static holly
#

my main.ppy is this:

import discord
from discord.ext import commands
from cogcmd.cog_info import cog_info
from cogcmd.cog_cmd import liste_commandes
from cogcmd.monde import monde
from cogcmd.automsg import automsg
import os
from dotenv import load_dotenv


intents = discord.Intents.all()
bot = commands.Bot (command_prefix="!", help_command=None, intents=intents)

load_dotenv()
TOKEN = os.getenv("TOKEN")

@bot.event
async def on_ready():
        print("Le bot est connectΓ©")

        await bot.load_extension("cogcmd.cog_info")
        await bot.load_extension("cogcmd.monde")
        await bot.load_extension("cogcmd.cog_cmd")
        await bot.load_extension("cogcmd.automsg")

        
bot.run(TOKEN)
vale wing
unkempt canyonBOT
#

utils/bot.py lines 62 to 72

def auto_setup(self, module_name: str) -> None:
    module = importlib.import_module(module_name, None)
    sys.modules[module_name] = module
    members = inspect.getmembers(
        module,
        lambda x: inspect.isclass(x) and issubclass(x, commands.Cog) and x.__name__ != "Cog",
    )
    for member in members:
        self.add_cog(member[1](self))

    self.log.ok("%s loaded", module_name)```
simple plume
#

lambda xD

vale wing
#

Lambda is just a function

simple plume
#

yha I know

#

@vale wing He does not understand the error

vale wing
#

What is the error to start with

simple plume
vale wing
static holly
#

@vale wing the second part of my code it works fine, look :

#

the cogs work fine...

#

its very strange...

vale wing
#

Is it the same cog

static holly
#

yes

#

and in the same file

vale wing
#

Ah I got it

#

You have 2 functions named the same

#

on_message

static holly
#

on_message_2?

vale wing
#

Edit one so it looks like this

@commands.Cog.listener("on_message")
async def whatever_cool_name(...)```
shrewd fjord
#

Yo

vale wing
#

Hello spooky

shrewd fjord
#

Hewo exen Peepo_UwU

simple plume
#

Guys, I wanted to make that when a specific word or emoji is in a message, to be stored by my bot, and when I request a specific command to give me the storaged messages.
Anyone knows how can I start?

static holly
#

@commands.Cog.listener("on_message")

on_message is not defined

vale wing
#

🧐

shrewd fjord
#

If there store the line in a file

vale wing
#

You sure you put quotes around

vale wing
simple plume
vale wing
#

Use database

simple plume
vale wing
#

Yes it's fine for your case

vale wing
simple plume
shrewd fjord
#

Bro i legit made birthday command with using txt file πŸ˜‚

shrewd fjord
#

My format was
birthdate
member_id
birthdate
member_id

simple plume
#

you fckng god

#

respect ❀️

shrewd fjord
#

Xd, the i check it with enumerate and match up those lines

vale wing
shrewd fjord
vale wing
#

And then was like "why tf is my data corrupt"

simple plume
shrewd fjord
vale wing
#

It's good in terms of objects serialisation

simple plume
shrewd fjord
#

πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚πŸ˜‚

simple plume
shrewd fjord
#

Exenifix: G_CryLeave

vale wing
#

Weird context

simple plume
shrewd fjord
#

Pretty weird

simple plume
shrewd fjord
#

Not me opsi

simple plume
shrewd fjord
#

:-:

vagrant hill
#

help plss

neat basin
#

I want to get optional variables using slash commands in my discord bot, how do I do it? I am using the discord.py library

thin raft
simple plume
#

So you put your token there, and use the prefix TOKEN in the actual code

vale wing
#

And yeah don't name functions in russian

#

If you want it to be named like that just do

@bot.command(name="Π»ΠΎΠ°Π΄")
async def load(...)```
slate swan
#

where can i set required False or True for options

#

because ik with pycord u can do ,required=True or False

gentle nova
#

def setup(bot):
bot.add_cog(test(bot))

#

only like that

#

Someone know how to connect discord bot to mongodb ?

abstract owl
#

i j shifted to cogs is there any thing as command.Cog.user?

maiden fable
abstract owl
#

nevermind figured it out ty

tired notch
#

is there a way to override a global error handler with a local one?

#

is the best way just to check in the global error handler if the name is the command i want to override, and to not do it if it is?

torn sail
#

!pypi motor

unkempt canyonBOT
slate swan
#
async for log in channel.guild.audit_logs(limit=1):
    if log.action == discord.AuditLogAction.webhook_create:
        await log.target.delete()

'Object' object has no attribute 'delete'```
full lily
#

what is an "Object" object?

slate swan
#
@bot.listen()
async def on_webhooks_update(channel):
    async for log in channel.guild.audit_logs(limit=1):
        guild = channel.guild
        if log.action == discord.AuditLogAction.webhook_create:
            euser = await audit_user(guild, discord.AuditLogAction.webhook_create)
            if not euser.id == 1064491535086931998:
                try:
                    await euser.user.ban(reason="PM-Beta: (Анти ΠΊΡ€Π°Ρˆ)Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π²Π΅Π±Ρ…ΡƒΠΊΠΎΠ²")
                except:
                    pass
                try:
                    await log.target.delete(reason="PM-Beta: (Анти ΠΊΡ€Π°Ρˆ)Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π²Π΅Π±Ρ…ΡƒΠΊΠΎΠ²")
                except Exception as e:
                    print(e)```
jaunty hare
#

Can somebody help me with this? my bot doesnt make any noise in the voice channel, just this, there is my code

gentle nova
#

@torn sailyea but its not working at all , i got all links in code , but still not connecting

abstract owl
#

i wanna use commands.Bot inside mybot

#

would be great if you could tell me a solution

shrewd apex
shrewd apex
jaunty hare
#

yeh i got installed PyNaCl

#

i need to import it?

slate swan
#

hey everyone !

#

i have something to ask

#

im using pillow to add text to an image but the text is not in the right place

#

I made a small drawing to explain where I want the text ^^

winged coral
#

pls send code thx

slate swan
#

@bot.command()
async def say(ctx, *, text: str):

    background = Image.open("sayempty.png")
    draw = ImageDraw.Draw(background)
    font = ImageFont.truetype("supercell-magic.ttf", 48)
    text_width, text_height = draw.textsize(text, font)
    while text_width > 500 or text_height > 200:
        font = ImageFont.truetype("supercell-magic.ttf", font.size - 1)
        text_width, text_height = draw.textsize(text, font)
    draw.text((int((700 - text_width) / 2), int((250 + text_height) / 2)), text, (0, 0, 0), font=font)
    buffer = io.BytesIO()
    background.save(buffer, format="PNG")
    buffer.seek(0)
    file = discord.File(fp=buffer, filename=f"{text}.png")
    await ctx.send(file=file)```
#

so?

tough mirage
#

whats this error mean

hushed galleon
tough mirage
#

10-4

#

thanks

slate swan
hushed galleon
#

not sure whats causing it though, might be related to your service provider

sick birch
white citrus
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 489, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\bot.py", line 275, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 888, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\setup_v2\cog.py", line 858, in setup_bot
    await org.edit(embeds=[status_embed, reply], view=setup__language__view_select, attachments=[])
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 1150, in edit
    message = await self._state._interaction.edit_original_message(
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 422, in edit_original_message
    params = handle_message_parameters(
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 515, in handle_message_parameters
    payload["components"] = view.to_components()
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 204, in to_components
    children = [item.to_component_dict() for item in group]
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 204, in <listcomp>
    children = [item.to_component_dict() for item in group]
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\select\base.py", line 194, in to_component_dict
    return self._underlying.to_dict()
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\components.py", line 295, in to_dict
    "options": [op.to_dict() for op in self.options],
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\components.py", line 295, in <listcomp>
    "options": [op.to_dict() for op in self.options],
AttributeError: 'str' object has no attribute 'to_dict'```
#

where does the error come from?

hushed galleon
#

looks like one of your select options was a string and not a SelectOption instance

white citrus
#

I see

white citrus
#

πŸ‡ΊπŸ‡Έ and πŸ‡©πŸ‡ͺ

white citrus
#
flag_us = ":flag_us:"
flag_de = ":flag_de:"```
hushed galleon
#

standard emojis need to be written in code with their unicode equivalents because discord's API doesnt actually recognize the text :flag_us:, thats something unique to their desktop application

#

!charinfo πŸ‡ΊπŸ‡ΈπŸ‡©πŸ‡ͺ

unkempt canyonBOT
ionic delta
#

Hello I am creating a bot to receive notifications from discord when a vinted article is published. I hosted it on a hosting site and the problem is that my bot uses the authentication cookie from a vinted computer. The question I ask myself is how can I open a link from a bot so that the cookie is created on my machine. I don't know if I was very clear thanks in advance

white citrus
hushed galleon
# unkempt canyon

you'd therefore either write flag_us = "\U0001f1fa\U0001f1f8" and flag_de = "\U0001f1e9\U0001f1ea" respectively

white citrus
#

How shoul it looks like?

#

Oh okay thanks

#

@hushed galleon can you help me with another problem

jaunty hare
#

help me please, my discord bot just do this and doesnt play sound

winged coral
#

FFMPEG is closing just 1 second after connecting

#

Are you sure you're sending it the stream?

versed anvil
#

Good evening,
It's been a long time since I programmed discord bot.
And when I am trying to see what's in the message send by a user with the function : if message.content.lower() == something
the bool object is never true even thaugh something is egal to the message send

#

@bot.event
async def on_message(message):
print("Message")

if message.content.lower() == "/Helpy":
    usage = """
    devine -> dΓ©marre le jeu
    stop -> arrΓͺte le jeu
    """
    await message.channel.send(usage)
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.

sick birch
#

without the message content intent message.content will always be "" (an empty string)

versed anvil
#

Oh

#

thank you πŸ₯³πŸ₯Ή

exotic maple
#

It pops up and gives them their options when they click on the argument in the slash cmd

tawny junco
#

Wym

pliant gulch
sick birch
#

Right

tawny junco
#

It sounds like you can just parse 1 argument for their choice

exotic maple
exotic maple
# sick birch Right

Hey can you maybe help,
why does it raise an error when i try and edit the variable msg

#

it says msg is nonetype

sick birch
#

Can we see the traceback?

hushed galleon
#

send_message() doesnt return a message, so you'd have to use original_message() afterwards

jaunty hare
#

I have a question, the discord.FFmpegPCM must have the executable parameter?

hushed galleon
#

gah i keep forgetting its original_response

ionic garden
#

i have a bunch of background task functions that i wanna load
however, from playing around, it seems that only loading them in setup_hook works
where should i store the bkg functions? if i put them in a cog, it won't have a setup functions & i'll see an error each time i start the bot

hushed galleon
#

oh right, if its just to edit the message then you can use edit_original_response()

#

!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.
hushed galleon
#

e.g. py await interaction.response.send_message("Hello...") await interaction.edit_original_response(content="world!")

exotic maple
#

thank you very much

normal cliff
#

Where do I go to ask about a normal Python question

#

Like what channel

jaunty hare
#

xd

normal cliff
jaunty hare
#

!d discord.FFmpegPCMAudio

unkempt canyonBOT
#

class discord.FFmpegPCMAudio(source, *, executable='ffmpeg', pipe=False, stderr=None, before_options=None, options=None)```
An audio source from FFmpeg (or AVConv).

This launches a sub-process to a specific input file given.

Warning

You must have the ffmpeg or avconv executable in your path environment variable in order for this to work.
hushed galleon
ionic garden
#

if i put them inside setup() they don't seem to run
lemme try again

#
@tasks.loop(seconds=1)
async def asdf():
    print("was this called")


async def setup(bot: commands.Bot):
    await bot.add_cog(Sys(bot))
    asdf.start()
```yeah, this doesn't work
hushed galleon
ionic garden
#

something's wrong

#

wait was this in a cog & called w/ bot.load_extension?

hushed galleon
#

of course

#

what error were you getting?

ionic garden
#

no error

#

it's just that nothing prints

hushed galleon
#

oh i thought you said you had an error on startup

#

event loop could be blocked, or extension wasnt actually loaded?

ionic garden
#
Loaded extension 'cogs.management.sys'
```the extension was definitely loaded
i put a print inside `setup()` as well and that one printed
potent spear
potent spear
#

all of it

#

every single line

ionic garden
#

tell me if you need anything else

potent spear
#

first thing I can note

#

on_message seems redundant

#

you shouldn't sync in on_ready

#

but that's besides your current issue

ionic garden
#

only does that if i tell it too (rn it's set to false)

potent spear
#

still, that's not where you want it to be

potent spear
#

you can just start it inside the init

#

optionally, you can add a before_loop in that task which waits for the bot to be ready before running

#
    @your_sexy_task.before_loop
    async def your_sexy_task_before(self):
        await self.bot.wait_until_ready()```
ionic garden
potent spear
# ionic garden https://paste.pythondiscord.com/ikohakusor no dice
class Sys(commands.Cog, name="sys"):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot
        self.counter = 0
        self.asdf.start()
    
    @commands.command()
    async def count_command(self, ctx):
      await ctx.send(f"Here's your count {self.counter}")

    # same function stuff here

    @tasks.loop(seconds=5)
    async def asdf(self):
        self.counter += 1


async def setup(bot: commands.Bot):
    await bot.add_cog(Sys(bot))```
#

can you try this?

#

just use the count_command and check if it changes after like 10 seconds to something else but 0

ionic garden
potent spear
#

damn

potent spear
#
async def setup_hook(self):
        await self.load_extension("cog_ext")```
use this to load your extensions, so add that in your subclassed bot and remove the asyncio.run(....) you're doing above bot.run(...)
naive briar