#discord-bots

1 messages Β· Page 1104 of 1

heady creek
#

@ before the bot.command()

heady sluice
#

that's not his issue

heady creek
#

you werent calling it right maybe?

heady sluice
heady creek
#

wait what is he trying to do?

heady sluice
#

this, not just embed=discord.Embed

heady sluice
paper sluice
slate swan
#

what in new row?

#
        for guild in bot.guilds:
            for channel in guild.text_channels:
                
                link = await channel.create_invite(max_age=300)
                await ctx.send(link)```
this is a bad way but how can i get the first channel of every guild and make a invite?
heady creek
#

oh i have a snipet for this

heady sluice
slate swan
#

ah ok

sonic flax
paper sluice
slate swan
#

ohk

sonic flax
#

i dont want a title tho

heady sluice
#

try not putting anything in the brackets then

heady creek
#

@sonic flax try this:

embed = Embed(title="title", description="whatever")
heady sluice
#

iirc it will error

sonic flax
#

no my error is

heady sluice
#

dew you just missed ()

sonic flax
#

I get discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_author() missing 1 required positional argument: 'self' when I use this code

@bot.command()
@has_permissions(administrator=True)
async def help(ctx, command=None):
  if command is None:
    embed=discord.Embed("Commands")
    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)```
heady sluice
#

that's why you got the error before

sonic flax
#

i still got it when idid it now

heady creek
heady sluice
#

title="Commands"

slate swan
heady sluice
sonic flax
slate swan
# sonic flax idk what command grouping is
@bot.command(invoke_without_command = True)
async def help(ctx):
  embed=discord.Embed(title = "Commands")
  embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)

  await ctx.send(embed = embed)
#
@bot.command()
async def showguilds(ctx):
      for guild in bot.guilds:
          for channel in guild.text_channels:
              link = await channel.create_invite(max_age=300)
              await ctx.send(link)```
it sends links for the amount of channels in every guild that's the only method i found, what other methods can i use to create 1 link for each guild
heady sluice
slate swan
sonic flax
heady sluice
#

I mean if we really overkill with command grouping, why not do it the right way and subclass HelpCommand

slate swan
#

he want custom help command

heady sluice
sonic flax
#

I get discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_author() missing 1 required positional argument: 'self' when I use this code

@bot.command()
@has_permissions(administrator=True)
async def help(ctx, command=None):
  if command is None:
    embed=discord.Embed("Commands")
    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)```
slate swan
#

did you remove help ?

heady sluice
#
@bot.command()
@has_permissions(administrator=True)
async def help(ctx, command=None):
  if command is None:
    embed=discord.Embed(title="Commands")
    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)β€Š
slate swan
#
await ctx.send(embed = embed)
heady sluice
#

yes

cloud dawn
heady sluice
#

I'm not sure how not putting title= makes the code not make an instance

heady sluice
heady sluice
#

I haven't seen the pep8 officer in a while

sonic flax
#
@bot.command()
@has_permissions(administrator=True)
async def help(ctx, command=None):
  if command is None:
    embed=discord.Embed(title="Commands")
    embed.set_author(name=bot.user.name, icon_url=bot.user.avatar_url)
    await ctx.send(embed=embed)

Now i get discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: init() takes 1 positional argument but 2 were given

slate swan
heady sluice
#

I'm confusion

heady sluice
slate swan
quaint epoch
#

🍿

slate swan
sonic flax
slate swan
#

oh

heady sluice
#

you forgot to restart the bot

slate swan
heady sluice
#

once putting the right code

slate swan
quaint epoch
# sonic flax

embed=discord.Embed(title="Commands") and restart the bot

heady sluice
slate swan
#

I agree with your name, meh

#

πŸ˜”

heady sluice
#

same

slate swan
#

mutual feelings

heady creek
#

poorly thrown together but should work.

heady sluice
#

that's like the same thing that he has

#

in slash

heady creek
#

yeah i just ran it and it works so its an issue with somethin else he has

heady sluice
#

yeah only 4 of us have said it already

slate swan
#
@bot.command()
async def showguilds(ctx):
      for guild in bot.guilds:
          for channel in guild.text_channels:
              link = await channel.create_invite(max_age=300)
              await ctx.send(link)```
it sends links for the amount of channels in every guild that's the only method i found, what other methods can i use to create 1 link for each guild
#

looli your bot's gonna get ratelimited AAAAAAA

slate swan
slate swan
#

if it's under a for loop, thats what ruins it

slate swan
#

though it's better to just send them all at once

#
await ctx.send("\n".join([(await guild.text_channels[0].create_invite(max_age=300)).url for guild in bot.guilds if guild.text_channels])
#

though it's privacy breaching as I've said it multiple times before

#

since people could have your bot in private servers

#

with content to not be seen by other people

#

with your bot being in the server, you could get an invite which will just result in your bot getting reported multiple times leading to further consequences

#

πŸ˜”

slate swan
heady sluice
#

maybe I'm unpythoning

#

!e print(number for number in [1, 2, 3, 4])

unkempt canyonBOT
#

@heady sluice :white_check_mark: Your eval job has completed with return code 0.

<generator object <genexpr> at 0x7f455c7dfca0>
heady sluice
#

hah

slate swan
heady sluice
#

oh you made it a list

#

fawk I really oversaw those brackets

#

stop

slate swan
#
[await ctx.send(
await guild.text_channels[0].create_invite(max_age=300)
)
for guild in bot.guilds 
if guild.text_channels]
``` read it now
heady sluice
#

I hate reading this

slate swan
#

ok

#

!e

''' Don't tell me that am repeating, an uwu example is required forsure '''
[print(uwu) for uwu in ["uwu1", "uwu2", "uwu3"]]
unkempt canyonBOT
#

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

001 | uwu1
002 | uwu2
003 | uwu3
heady sluice
#

ew

#

do you need the brackets here

slate swan
#
     @disnake.ui.button(label="h", style=ButtonStyle.gray)
     async def but1(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
         if interaction.author == self.user or self.challanger:
            if self.chance == 1 and interaction.author == self.user:
             button.emoji = "πŸ‡΄"
             button.style=ButtonStyle.green
             button.disabled = True
             self.chance = 2
             await interaction.response.send_message("Selected",ephemeral=True)
            elif self.chance == 2 and interaction.author == self.challanger:
             button.emoji = "❎"
             button.style=ButtonStyle.red
             button.disabled = True
             self.chance = 1
             await interaction.response.send_message("Selected",ephemeral=True)

πŸ˜” why this doesnt change emoji and disbable the button and change the color

lyric apex
#

How bots Doesn't tag the role like they use @everyone tag yet the role isnt mentioned

heady sluice
slate swan
#

!d discord.AllowedMentions in .send /.reply or your Bot constrctor

unkempt canyonBOT
#

class discord.AllowedMentions(*, everyone=True, users=True, roles=True, replied_user=True)```
A class that represents what mentions are allowed in a message.

This class can be set during [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") initialisation to apply to every message sent. It can also be applied on a per message basis via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for more fine-grained control.
slate swan
heady sluice
#

it's getting worse and worse

slate swan
unkempt canyonBOT
#

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

001 | uwu1
002 | uwu2
003 | uwu3
slate swan
dire wind
#

Hi guys

slate swan
#

hello

dire wind
#

I'm building a discord robot now, does anyone have any theoretical ideas? I mean, what options should I put on the robot?

heady sluice
slate swan
#

uh wait

slate swan
maiden fable
heady sluice
#

wowse and wowse

slate swan
heady sluice
#

I'm deleting discord

sick birch
slate swan
slate swan
# heady sluice do that
 @disnake.ui.button(label="** **", style=ButtonStyle.gray)
     async def but1(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
         if interaction.author == self.user or self.challanger:
            if self.chance == 1 and interaction.author == self.user:
             await interaction.response.edit_message("Selected")
             button.emoji = "πŸ‡΄"
             button.style=ButtonStyle.green
             button.disabled = True
             self.chance = 2
            elif self.chance == 2 and interaction.author == self.challanger:
             await interaction.response.edit_message("Selected")
             button.emoji = "❎"
             button.style=ButtonStyle.red
             button.disabled = True
             self.chance = 1

this doesnt work...

heady sluice
#

which message has the button

#

where do you send jt and how

stiff fern
#
class Main(commands.Bot):
    
    def __init__(self):
        super().__init__(
            command_prefix = ".",
            intents = discord.Intents.all(),
            application_id=986411930954629131) # Client ID

    async def on_ready(self):
        print(f'{self.user} has initialized.')


    async def setup_hook(self):

        self.initial_extensions = [
            'cogs.general',
            'cogs.suggestion',
        ]

        for ext in self.initial_extensions:
            await self.load_extension(ext)

        # Guild ID
        await bot.tree.sync(guild=discord.Object(id=981034070421155850))


    @app_commands.command(name='load', description='Enable a command')
    @app_commands.describe(extension="Command Name")
    async def load(self, interaction: discord.Interaction, extension: str):
        bot.load_extension(f'cogs.{extension}')

    @app_commands.command(name='unload', description='Disable a command')
    @app_commands.describe(extension="Command Name")
    async def unload(self, interaction: discord.Interaction, extension: str):
        bot.unload_extensions(f'cogs.{extension}')

    @app_commands.command(name='reload', description='Reload a command')
    @app_commands.describe(extension="Command Name")
    async def reload(self, interaction: discord.Interaction, extension: str):
        if extension in ['all', '*']:
            for ext in self.initial_extensions:
                bot.unload_extension(ext)
                await self.load_extension(ext)
        else:
            bot.unload_extension(f'cogs.{extension}')
            bot.load_extension(f'cogs.{extension}')

Anyone know why the @app_commands.command lines don't show up? I dont get any errors they just dont load in I guess because I dont have them as cogs

heady sluice
#

jesus

slate swan
regal pulsar
heady sluice
#

wait I just realised

#

is interaction.response this message?

slate swan
#

..?

heady sluice
#

I don't know how you could access this message without saving it to a variable

slate swan
heady sluice
#

!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.
slate swan
#

..

heady sluice
#

seems good

#

lmao

#

awaig interaction.response.edit_message("Selected", view=self)

#

at the end of the code...?

#

cuz you put it at the start

slate swan
heady sluice
#

I'd be happy if that worked

slate swan
heady sluice
#

it worked

slate swan
#

yeah

#

Hello

#

How I can to send two embeds in one message?

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

Sends a message to the destination with the content given.

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

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

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

use the embeds kwarg

#

ok

#

await ctx.send(embeds=embed, embeds=embed2)

slate swan
slate swan
#

I said to use the embeds kwarg and that syntax in invalid

#

maybe learn python and read the docs

#

I learning

#

then learn first

#

yerl chad lmaoooo

#

ok

#

Thanks

regal pulsar
#

oh

#

im late again ;/

sick birch
cerulean folio
#
def check(m):
      urls = list()
      urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', message.content)
      if urls or m.attachments:
        return True
      return False

I want to check message contains urls or attachements, is that correct?

regal pulsar
#

right before he left to buy milk lemon_pensive

sick birch
#

sad

slate swan
unkempt canyonBOT
#

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

['http://nevergonnagiveyou.up']
slate swan
#

yea

cerulean folio
#

Because like...

msg = await client.wait_for('message', check=check)
  if msg.content.lower() == 'cancel':
    return False
  else:
    if msg.attachments:
      img_uploads = [x.url for x in msg.attachments if x.content_type.startswith('images')]
    print(img_uploads)
    urls = list()
    urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', message.content)
    print(urls)
    send = (',').join(urls + img_uploads)
    if send:
      return send
    else:
      return None
#

It returns an empty list i'm so pissed XD

short silo
#

There is a limit of 15 on Option choices right ?

jagged adder
#

how do i define ctx for a command that is in a diff file? i have my main game running in my core file, with it referencing a second file for the game choices. i have got to a point tho where i am tryin to use a wait.for, and i cant use bot or ctx because there is no context for it

potent spear
jagged adder
#

i believe so yeah

potent spear
#

try now to be as specific as possible, including code

cerulean folio
hard socket
#

ImportError: cannot import name 'music_cog' from 'music_cog'
does somebody knows how i can fix this?

cerulean folio
#

it's pissing me off i can't fix it XD

hard socket
potent spear
hard socket
potent spear
cerulean folio
potent spear
#

you don't even have to import the file to load it

slate swan
# jagged adder actually no

get the command first (Bot.get_command), then invoke it using the invoke method (Command.invoke) with the required arguments

heady sluice
#

also why would you import the cog

jagged adder
#

basically, the entire code is set up within 1 command (new_game), than references defs in a separate file to provide a multi choice option, and to provide the text. the issue is when i try to use

Choice = await ctx.wait_for('message', check=lambda m: m.content.lower() in ['a', 'b'] and m.channel == game_channel)
        if Choice.content.lower() == 'a':

like i would in the main file, it cant reference the bot

#

i believe i got it right anyways

heady sluice
#

bot.wait_for

#

not ctx.wait_for

jagged adder
#

ye just says unresolved reference 'bot'

#

same w ctx

heady sluice
#

or ctx.message.get_context().bot.wait_for

slate swan
heady sluice
#

or ctx.message.get_context().message.get_context().message.get_context().message.get_context().message.get_context().bot.wait_for()

cerulean folio
heady sluice
#

my bad it doesn't exist

slate swan
unkempt canyonBOT
#

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

Returns the invocation context from the message or interaction.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Note

In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
slate swan
#

typo smh

potent spear
slate swan
#

its origin in 2.0 cause slashhhhh

slate swan
#

lmao

heady sluice
#

well

#

then it's

#

ctx.bot.get_context(ctx.message).bot

potent spear
#

bruh πŸ˜†

cerulean folio
jagged adder
#

considering it still doesnt recognise either bot nor ctx, still got an issue :l

heady sluice
placid skiff
heady sluice
#

you probably don't define the check in the command

#

but even then it should recognize bot

#

you don't use a check function

#

I have to sleep

placid skiff
#

bruh check or not the check works with the context

#

shows where you declare the command

slate swan
jagged adder
#

the command is in file 1, while the def is in file 2. thats where the issue is i think, as i cant just import bot or somethin

potent spear
#

please don't

heady sluice
#

just put the def in file 1

#

wait what

placid skiff
#

decorators take a function as parameter how you've even done that

heady sluice
#

yes

#

you imported bot or smth?

slate swan
heady sluice
#

do you use cogs

jagged adder
#

i remember someone explaining em to me, but no i dont

cerulean folio
#

@potent spear thanks a million times for your idea !
The regex was incorrect, and it was only capturing a https://www.example.com
Correct regex is:
((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z]){2,6}([a-zA-Z0-9\.\&\/\?\:@\-_=#])*
This shit captures ANY link

placid skiff
#

bruh decorators must be declare above a command you can't write a decorator and then pretend that it will works for an outside function

heady sluice
#

I kinda wanna just ask BlvckTvrsier's question again

#

how did you do @bot.command()

#

without bot

placid skiff
#
@my_deco()
def my_func():
```this works

```py
def my_func():
  #code

@my_deco()
my_func()

this doesn't

jagged adder
#
@bot.command(name="new_game")
@commands.check(new_game_check)
async def command_new_game(ctx: commands.Context):
    await ctx.message.delete()
#

thats in the main file

#

but the wait_for im tryin to do is within a definition in file 2

heady sluice
#

😭

jagged adder
#

its how it was suggested to me when i was writing it ;-;
havent been doing this long so if i shoulda been doing it differently, lmk why lol

potent spear
#

have you read the error?

#

what's there to not understand? it's in plain english

#

last line

quaint epoch
potent spear
#

close

slate swan
#

Lol

quaint epoch
#

got it now?

#

where are you hosting it?

#

locally atm?

placid skiff
#

He is using json so replit or heroku if he is hosting it somewhere

potent spear
#

probably some rpi or something
and he messed up the json to the point where it's a huge file or something

quaint epoch
#

databases exist yk (im a hypocrite)

potent spear
#

yeah, he followed a yt video, that's for sure

placid skiff
#

databases exists yeah, but why don't use a javascript object notation as a database?

quaint epoch
#

what files are on it? (the device)

potent spear
#

it's not its intended use, a json is shit for that

quaint epoch
#

how much free space do you have?

#

seems normal, what other files do you have

potent spear
#

do you even know what you wrote? xd

quaint epoch
#

how much free space do you have on your plan?

potent spear
#

F

slate swan
#

Bro

quaint epoch
#

im not asking about your json file

slate swan
#

Where are u hosting ur bot

quaint epoch
slate swan
#

Which hosting

quaint epoch
#

which one

slate swan
#

3tb?

quaint epoch
#

3 what?

slate swan
#

Or 3 bytes πŸ’€

scarlet aurora
#
        { "number": 136, "roast": "weee" },
        { "number": 137, "roast": "we" }``` how can I randomize these ?
slate swan
#

bits

quaint epoch
#

im not asking that

slate swan
#

Bruh

placid skiff
#

3 potatoes

slate swan
#

Lol

quaint epoch
#

how much total space do you have on hosting site?

slate swan
#

He's trolling

quaint epoch
#

i have about 600 mb of free space where i host my bot

slate swan
#

U using replit right

quaint epoch
#

how much do you have?

scarlet aurora
#
        { "number": 132, "roast": "You shouldn't play hide and seek, no one would look for you." },
        { "number": 133, "roast": "You're so ugly, when you threw a boomerang it didn't come back." },
        { "number": 134, "roast": "The clothes you wear are so ugly even a scarecrow wouldn't wear them." },
        { "number": 135, "roast": "You're so ugly, when you got robbed, the robbers made you wear their masks." },``` how can I randomize these as the result for running the command?
slate swan
#

Theb

scarlet aurora
#

yeah how do I call the roasts

slate swan
#

wait what

potent spear
#

oh lord

slate swan
#

okay am blind

quaint epoch
slate swan
#

Why did I see that as a list twice...

quaint epoch
#

and do you have to include the {"number": 132}?

#

it seems redundant

potent spear
quaint epoch
scarlet aurora
#

ot

#

it's to choose the roast, that's what the numbers for

quaint epoch
#

!e
import json
json.dumps("['1', '2', '3' ]")

unkempt canyonBOT
#

@quaint epoch :warning: Your eval job has completed with return code 0.

[No output]
potent spear
warm flame
#

guys is there a way to implement cogs in other projects?

quaint epoch
#

you don't need the numbers

potent spear
potent spear
paper sluice
scarlet aurora
warm flame
scarlet aurora
#

then get the output

quaint epoch
warm flame
#

is there an alternative?

slate swan
#

Can 1 cog used by 2 main files?

quaint epoch
#

your dict structure is weird

potent spear
paper sluice
quaint epoch
#

bro

warm flame
slate swan
quaint epoch
#

that's NOT what we are asking

slate swan
#

@quaint epoch he's trolling for sure

quaint epoch
#

how many mb of space do you have?

paper sluice
slate swan
quaint epoch
#

im out

#

this is too much

slate swan
#

πŸ˜‚

quaint epoch
#

tl;dr you don't have enough space on your device, find which files are taking up the space and fix it

slate swan
#

U know what's storage size

quaint epoch
#

see? i have 725 gb of 953gb space, how much space do you have?

paper sluice
quaint epoch
slate swan
quaint epoch
#

which is why it isn't the problem

quaint epoch
slate swan
#

oh ok

paper sluice
slate swan
#

Bruh

#

He don't mean that

quaint epoch
#

okay, now

#

how much data are you writing to the json?

#

because it should be less than 50 kb i bet

#

cya

#

@slate swan you take care of this

#

and hunter too

#

πŸ‘‹

slate swan
#

spaces between code like ```
a = "hi"
To
a="hi"

slate swan
maiden fable
quaint epoch
heady sluice
#

thank god he doesn't even think of me when he sees json

slate swan
maiden fable
quaint epoch
slate swan
#

Bro

#

Can't u read

potent spear
#

that's not what's happening
most likely, you're just never writing to it

slate swan
#

πŸ’€

#

Listen like it's saying ex ur space is like 10mb and ur files have used all 10mb so it's raising the error

potent spear
#

the device where you're hosting the bot 🧠

slate swan
#

Ur hosting has no storage

#

It's trash

#

Bro that's node

#

See there

#

Space

maiden fable
#

half of the space is empty

slate swan
#

Which hosting bte

paper sluice
#

64mb ram sadgr

slate swan
maiden fable
#

They make good animations

heady sluice
#

does that 4th shit mean ram

paper sluice
paper sluice
heady sluice
#

62MB for a small bot

slate swan
heady sluice
#

damn

slate swan
maiden fable
#

I guess that is what they wanted

slate swan
#

or my thinking's way too weird Β―_(ツ)_/Β―

maiden fable
#

Power Rangers are bots like Dynos and MEE6 and uh, automod is.... automod

#

Nice, one of my servers actually got Automod

slate swan
#

How's the uptime?

#

Is it fine?

slate swan
maiden fable
#

Eh, I don't really think many servers gonna use it anyways since they don't really care about swears

slate swan
slate swan
maiden fable
#

out of the 96 servers I am in, in about 90 (if not all) don't give a fuck about swearing

potent spear
slate swan
#

!ot <-

unkempt canyonBOT
slate swan
#

πŸ₯΄

sick birch
#

I believe we have automod configured here to some extent, I've seen the warning messages in internal channels before (i think)

maiden fable
maiden fable
#

So I am in ~96 servers

slate swan
#

100 is max

maiden fable
#

Ik

slate swan
#

200 with nitro

paper sluice
#

Discord tryna get bread

slate swan
#

potatoes :)

sick birch
#

better than adverts on the app

slate swan
#

they came out with the idea of nitro on morning potatoes

maiden fable
#

Of course, they thought of the idea of Nitro over morning breakfast potatoes

#

Damn it I am slow

maiden fable
paper sluice
jagged adder
slate swan
#

Does anyone know how to make a system for my bot to publish messages in the announce channels?

#

but bot publish

#

!d discord.Message.publish

unkempt canyonBOT
#

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

Publishes this message to your announcement channel.

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

If the message is not your own then the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is also needed.
slate swan
#

error

gaunt ice
#

hello guys

#

i need help

sick birch
slate swan
gaunt ice
#

can bots get message in dms of the user

slate swan
#

Yes

gaunt ice
#

how

sick birch
#

I believe so, yes

sick birch
# slate swan ?

You need the actual instance of discord.Message, not the class itself

slate swan
sick birch
unkempt canyonBOT
#

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

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

Examples

Usage...
slate swan
#

do i need to create a class?

sick birch
#

Why are you trying to publish if you just need to send an embed?

#

You're aware of what publishing does?

slate swan
#

a = await ctx.send()
await a.publish()

#

i need something like this for my bot

#

because my bot has some systems that stop working when I restart

sick birch
#
embed = discord.Embed(...) # construct embed

msg = await ctx.send(..., embed=embed)
await msg.publish()
slate swan
sick birch
#

no prob

slate swan
nova sandal
#

hello .. I am new here . I know C programming and want to learn Python now .. where can i find help ??

unkempt canyonBOT
#
Resources

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

slate swan
#

here are some good resources for learning python

nova sandal
#

so I can learn python from the basics right ??

#

my teacher says that as i know C Programming, i will find python easier

slate swan
#

Yeah

#

Python is much easier from c

#

error

#

discord.app_commands.errors.CommandInvokeError: Command 'reiniciar' raised an exception: AttributeError: 'NoneType' object has no attribute '_state'

slate swan
#

Code

slate swan
slate swan
slate swan
#

Replace discord.Messsage with msg

slate swan
#

i am using slash command system

slate swan
#

Dear, please tell me why it gives an error?

nova sandal
slate swan
slate swan
heady sluice
#

it's Robin isn't it

slate swan
#

So it will be await msg.publish()

#

ctx for some reason doesn't work in my code

slate swan
slate swan
slate swan
slate swan
heady sluice
slate swan
#

Ye

heady sluice
slate swan
heady sluice
slate swan
slate swan
# slate swan Ye

discord.app_commands.errors.CommandInvokeError: Command 'reiniciar' raised an exception: AttributeError: 'NoneType' object has no attribute 'publish'

#

aaaaaaaaaaaaaaaaaaaaaaaaa

heady sluice
#

use self.bot.get_emoji instead of the string

slate swan
heady sluice
#

emoji = self.bot.get_emoji(986774079191285790)

#

then
await ctx.guild.delete_emoji(emoji)

#

that should work

slate swan
#

Works Works. Hurrah Hurrah. just one more question. Is it possible to recognize an emoji ID with just a name?

heady sluice
#

Guild should have an attribute like that but I've never seen it

#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI.

x == y Checks if two guilds are equal.

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

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
honest shoal
#

how to pin message

heady sluice
#

no I don't see it

#

guess you have to loop through ctx.guild.emojis @slate swan

#

!d discord.Message.pin

unkempt canyonBOT
#

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

Pins the message.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to do this in a non-private channel context.
heady sluice
#

@honest shoal you just do await message.pin()

slate swan
#

It doesn't work for some reason

heady sluice
slate swan
heady sluice
#

you only have to put an emoji after the command to have an Emoji object

#

i.e !counter zig_hello

#

you wanna delete the emoji sent?

slate swan
#

Still gives an error

#

(((

heady sluice
#

what did you type in discord

#

you have to type !counter <emoji>

stiff fern
#
@app_commands.command(name='unload', description='Disable a command')
    @app_commands.describe(command_name="Command Name")
    async def unload(self, interaction: discord.Interaction, command_name: str):
        if command_name != 'critical':
            await self.bot.unload_extension(f'{command_name}')

Command 'unload' raised an exception: AttributeError: 'Main' object has no attribute 'unload_extensions'
Anything obvious I did wrong here?

slate swan
#

.counter

heady sluice
#

.counter <emoji>

#

but it won't work cuz you replaced the arg in delete_emoji()

slate swan
#

And you can not enter emoji.

vale sierra
heady sluice
#

why

heady sluice
#

did you save and restart the bot

stiff fern
#

oh

stiff fern
#

Yea I did

slate swan
#

I need to enter a command. emoji were created, sent to the chat and deleted. for profile

stiff fern
#

Its only 100 lines and its just unload/load/reload commands

#

I didnt include all of it but it says unload bc thats what I tried doing

vale sierra
heady sluice
#

then somewhere you wrote unload_extensions instead of unload_extension

heady sluice
stiff fern
#

Ooh

heady sluice
#

remove emoji in
async def counter(self, ctx, emoji)
if you don't want it @slate swan

potent spear
slate swan
#

without this argument it gives an error here

heady sluice
#

that doesn't make sense anyways...

slate swan
#

And how can I delete emoji if I only know that the name of the emoji is 321

heady sluice
#

you can't just get an attribute and call it

potent spear
heady sluice
#
for emoji in ctx.guild.emojis:
    if emoji.name == "321":
        await ctx.guild.delete_emoji(emoji)
heady sluice
#

damn

slate swan
potent spear
#

check out how to use discord utils get first

#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, /, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

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

Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s...
heady sluice
#

emoji = discord.utils.get(ctx.guild.emojis, name="321")

#

yes

#

but when you actually use create_emoji before, you already have this Emoji object

#

and you don't have to use this

slate swan
#

Wow works. Thanks a lot. I'll take a look at how discord.utils.get works, otherwise I didn't fully understand it. and thanks everything works!!!!

maiden fable
#

I hate rewriting my bot πŸ˜”

potent spear
#

version control is key

maiden fable
#

Yea it is

sick birch
maiden fable
#

Agreed

sick birch
#

"can i get a code review please? thanks"

#

2 minutes later
lgtm πŸ‘

maiden fable
#

Can I get ||help for the rewrite||

sick birch
#

πŸ€”

maiden fable
#

I made it open sourced because people wanted me to and now rip πŸ˜”

maiden fable
shrewd apex
#

book marked it

maiden fable
#

thanks

shrewd apex
#

starred it too

#

lmao will try to help...

maiden fable
#

Haha its fine

shrewd apex
#

what bot it is btw?

maiden fable
#

The AI bot

cloud dawn
#

Using asyncio.create_subprocess_shell to get an async program to run it only prints out the stdout after the program has finished, any way to get live feedback?

shrewd apex
slate swan
maiden fable
#

Totally me

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

maiden fable
#

what if he is making a shell command?

shrewd apex
#

...

maiden fable
#

Tbh the help I am gonna be needing with, is the help command cz I hate making those

shrewd apex
#

ic

shrewd apex
maiden fable
shrewd apex
#

oh

#

well the graphical part is always a chore

maiden fable
#

Wym

shrewd apex
#

designing the embed so it looks good and formatting text in description type of stuff

maiden fable
#

Ah yea

slate swan
shrewd apex
#

np

short silo
#

There is a limit of 15 on Option choices right ?

maiden fable
#

25

shrewd apex
#

25 reactions 25 button 25 choices

#

25 everything

short silo
#

Okay, thanks.

short silo
# maiden fable 25

Is there any way to overcome that limit though.

Something like a List Builder/ Autocomplete ?

maiden fable
#

no

short silo
#

It's fine if the user gives some other input than the options, i require something like an autocomplete

maiden fable
#

u gotta use nested options

short silo
#

I see

shrewd apex
#

there is one i think not sure tho

maiden fable
#

or add smth like "More options"

short silo
shrewd apex
#

u could send another message with 25 options

maiden fable
#

@shrewd apex opinion

shrewd apex
#

and edit the message to none nothing shortly after

#

will look kinda connected ig

maiden fable
#

Should I send a modal for showing the user information the bot has, or make a paginator?

shrewd apex
#

hmm

#

modal for main help menu

maiden fable
#

huh

short silo
#

how does discord.Member as an option work, isn't that kind of a list builder, is it not implementable ?

shrewd apex
#

wdym?

shrewd apex
maiden fable
#

Cool thanks

short silo
# shrewd apex wdym?

discord.Member gives a list of all users present in the server as an option, does it not ?

maiden fable
#

istg if the limit is 25 for TextInput

short silo
#

What does it do then as a choice

maiden fable
#

Nice there is a limit of 25 text inputs in a modal

#

TIL u can also host a discord bot on cloudflare worker

shrewd apex
#

discord is a class Member is an attribute under it so thus discord.Member give an object like class object discord.Member object

maiden fable
shrewd apex
#

nice

maiden fable
#

rip only for js

shrewd apex
#

sed

maiden fable
#

Lemme confirm

shrewd apex
#

i am gonna use rpi for mine ig

#

have to make a battery pack tho for it

#

power cutsβœ‚οΈ

shrewd apex
#

two messages in a row each 25 options

maiden fable
#

@shrewd apex help me make a modal paginator

slate swan
#

Im bored entertain me

maiden fable
#

!ot

unkempt canyonBOT
maiden fable
#

Yea, u cannot use Python on cf workers πŸ˜”

slate swan
shrewd apex
maiden fable
shrewd apex
#

i would love to but i am on phone rnπŸ˜”

short silo
#

But okay got it

maiden fable
shrewd apex
#

i have to make a help command for mine as well which i will start tom or day after

maiden fable
heady sluice
#

πŸ˜”

maiden fable
#

@shrewd apex wanna see smth cursed?

shrewd apex
#

show

heady sluice
#

make it 31 for duck's sake

maiden fable
maiden fable
heady sluice
#

options for a whole month

shrewd apex
#

py+js

maiden fable
#

Yes lol

heady sluice
#

pysConfused_Dog

maiden fable
#

pythonscript!

shrewd apex
#

or pj

#

lmao

maiden fable
#

rip cannot make a modal paginator

#

a modal cannot send another modal

shrewd apex
#

the def tho

shrewd apex
heady sluice
shrewd apex
#

can a modal send a message?

heady sluice
#

people in africa are suffering because of it

slate swan
maiden fable
heady sluice
#

lmao

maiden fable
shrewd apex
#

hmm ic

heady sluice
#

did you name yourself rip because of this

maiden fable
#

A modal is just this

slate swan
maiden fable
#

nothing more nothing less

heady sluice
#

rip

maiden fable
#

@heady sluice u got a spare bot on yr laptop rn?

slate swan
maiden fable
#

computer/laptop

shrewd apex
#

hmm we could try tho it might not work with subclass we could try it in the command like send a modal on button callback from paginator

heady sluice
#

probably

maiden fable
#

I need u to test smth πŸ₯Ί

heady sluice
#

but I've been on phone for 2 weeks

maiden fable
#

Sad

heady sluice
#

I'm on vacation

slate swan
maiden fable
#

u got a bot?

shrewd apex
slate swan
#

yes

maiden fable
#

Make a command and send a button

shrewd apex
slate swan
heady sluice
#

I can't say that now

maiden fable
#

Nice

slate swan
#

i don't even know what lib i need for buttons

maiden fable
#

disnake

shrewd apex
#

rip rip

heady sluice
slate swan
heady sluice
slate swan
heady sluice
#

it's an API

#

you can make your own API wrapper

slate swan
heady sluice
#

you can implement shit

#

you can hack discord to implement shit so you can implement shit in your API wrapper

shrewd apex
#

lmao hunter u are better of making it on replit in phone it will get done faster

heady sluice
#

πŸ˜”

maiden fable
#
@bot.command()
async def smth(ctx):
    v = disnake.ui.View()
    btn = Button(text="Test")
    v.add_item(btn)
    btn.callback = callback

async def callback(inter):
    modal = disnake.ui.Modal()
    btn = disnake.ui.Button(text="New")
    modal.append_component(btn)
    btn.callback = cb2
    await inter.response.send_modal(modal)

async def cb2(inter):
    modal = disnake.ui.Modal()
    btn = disnake.ui.Button(text="New")
    modal.append_component(btn)
    btn.callback = cb2
    await inter.response.send_modal(modal)
#

Looks good?

#

Nvm, cannot add buttons too, to modals πŸ˜”

shrewd apex
#

indents

#

sending a modal on pressing a button that might be simpler to achieve

maiden fable
#

Indents are fine tho

slate swan
#

same question ngl

maiden fable
#

label*

left idol
#
if discordID in [301480016657776642, 464721355116380160]:
    a = 0
    b = 10
elif discordID in [92786442891169792, 746850928417701990]:
    a = 85
    b = 99
else:
    a = 49
    b = 99

Spiking = np.random.randint(a, b)
embed = discord.Embed(title = "STATS", description = Spiking, color = discord.Color.blue())
await ctx.respond(embed=embed)

i was changing my command to give different results for different ids but do i have my if statement incorrect? it only works for the first if and else, not eliuf

maiden fable
#

Eh, didn't really use the code anyways. Modals can't have buttons

slate swan
left idol
#

wait wym

maiden fable
#

discordID is never any of those 2 in the lists

left idol
#

can i instead make a nested if statement?

maiden fable
#

Sure

slate swan
#

nested if statement? but why?

left idol
#
if discordID in [301480016657776642, 336895085511835649]:
    a = 0
    b = 10
else:
    if discordID in [92786442891169792, 746850928417701990]:
        a = 90
        b = 99
    else:
        a = 45
        b = 99

something like this instead?

#

im just rigging the stat that comes depending on the user

#

if they are in list one, give them bad stuff, if in list two, give them good stuff, else normal

slate swan
#

and that's the reason where inequality starts

cloud dawn
haughty nova
#
from re import A
import discord
from discord.ext import commands
import datetime
import asyncio
import random

TOKEN = ""

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

@client.command()
@commands.has_role("Developer")
async def gstart(ctx, mins : int, *, prize: str):
    embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)

    end = datetime.datetime.now() + datetime.timedelta(seconds = mins/60)

    embed.add_field(name = "Slutter kl:", value = f"{end}")
    embed.set_footer(text = f"Slutter om {mins} minutter!")

    my_msg = await ctx.send(embed = embed)

    await my_msg.add_reaction(":tada:")

    await asyncio.sleep(mins)

    new_msg = await ctx.channel.fetch_message(my_msg.id)

    users = await new_msg.reactions[0].users().flatten()
    users.pop(users.index(client.user))
    

    winner = random.choise(users)

    await ctx.send(f"Tillykke! {winner} du vandt {prize}!")



client.run(TOKEN)```
When i start a giveaway it never ends and in the teminal in vscode its writes "Command raised an exception: AttributeError: module 'random' has no attribute 'choise'"
cloud dawn
#

!d random.choice

unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
cloud dawn
regal pulsar
haughty nova
#

shit i just saw it now

slate swan
#

english is hard so calm down

regal pulsar
#

im calm ;/

cloud dawn
haughty nova
#

no it isn't my main language so sometimes i write a little wrong

slate swan
#

give me a break

cloud dawn
#

Lol

#

I'm still coding my discord mc server

slate swan
#

what is it about?

cloud dawn
#

Connecting a whole minecraft server to the bot.

sick birch
#

How so? Sounds interesting

slate swan
#

mhm interesting

haughty nova
#

!tag

unkempt canyonBOT
#
Available tags

β€’
Β» args-kwargs
Β» async-await
Β» blocking
Β» botvar
Β» class
Β» classmethod
Β» codeblock
Β» comparison
Β» contribute
Β» customchecks
Β» customcooldown
Β» customhelp
Β» decorators
Β» defaultdict

regal pulsar
cloud dawn
#

Cross commands but more that people can chat in the Minecraft chat and discord chat and allowing them to start/stop/restart the server. It's a private guild/ mc server.

haughty nova
#

how do i get the help page about how i tag people when discord bot chats?

slate swan
#

i wanna try machine learning to make an ai in minecraft idk it sounds fun

sick birch
haughty nova
#

how do i do that the discord bot tags the person in the text?

cloud dawn
slate swan
sick birch
slate swan
#

the string dunder returns the whole tag of the user

sick birch
#

It's already done, and if it's one thing us programmers love, it's work that's already been done by other people

sick birch
#

understandable. I'm curious, how are you getting it to work so far?

#

Does Minecraft have some sort of IPC you can hook into?

haughty nova
#

can you do so that the text that the bot sends is in color?

cloud dawn
sick birch
#

ah okay

#

I mean i probably would've done an approach where I write a quick Java plugin to stream messages to a websocket server in python, handle things from there

cloud dawn
cloud dawn
sick birch
#

Only a bit

#

But some people believe a bit of java is too much java

haughty nova
#

!tagperson

#

!tags

unkempt canyonBOT
#
Available tags

β€’
Β» args-kwargs
Β» async-await
Β» blocking
Β» botvar
Β» class
Β» classmethod
Β» codeblock
Β» comparison
Β» contribute
Β» customchecks
Β» customcooldown
Β» customhelp
Β» decorators
Β» defaultdict

sick birch
#

#bot-commands please and thank you

cloud dawn
#

If I can achieve it by doing this it would save time and the hassle of searching how to create plugins for 1.6.4 lol

stiff fern
#
    @load.error
    async def load_error(self, ctx, error):
        if isinstance(error, commands.NoEntryPointError):
            await ctx.send(embed=self.error_nosetup_embed)

        elif isinstance(error, commands.ExtensionNotLoaded):
            await ctx.send(embed=self.error_notloaded_embed)
        
        elif isinstance(error, commands.ExtensionNotFound):
            await ctx.send(embed=self.error_nosetup_embed)
        else:
            raise error

So I'm trying to catch errors w/ slash commands and it doesn't seem to work, it doesn't error (of course) and I think it has to do with the Context.send just because .send doesn't autocomplete which Ive just learned means its probably not going to work

pliant gulch
stiff fern
#

Ive tried doing it other ways but Im not sure how to basically send the message

haughty nova
#
await ctx.send(f"Tillykke! @{winner} du vandt giveawayen pΓ₯ {prize}!")```
#

how do i do that the winner gets tagged?

stiff fern
#

what is winner

#

is it their id or their user

haughty nova
#

of a id

stiff fern
#

oh wait

#

try winner.mention

#

im stilll a noob so idk im just guessing

haughty nova
stiff fern
#

keep the {}

#

{winner.mention}

#

if it doesn't autocomplete when you type winn then its prob not going to work

#

assuming youre using vscode like me, pro tip

haughty nova
#

thank you!

#
client = commands.Bot(command_prefix ="!")

@client.command()
@commands.has_role("Developer")
async def gstart(ctx, mins : int, *, prize: str):
    embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)

    end = datetime.datetime.now() + datetime.timedelta(seconds = mins/60)

    embed.add_field(name = "Slutter kl:", value = f"{end}")
    embed.set_footer(text = f"Slutter om {mins} minutter!")

    my_msg = await ctx.send(embed = embed)

    await my_msg.add_reaction(":tada:")

    await asyncio.sleep(mins)

    new_msg = await ctx.channel.fetch_message(my_msg.id)

    users = await new_msg.reactions[0].users().flatten()
    users.pop(users.index(client.user))
    

    winner = random.choice(users)

    await ctx.send(f"Tillykke! {winner.mention} du vandt giveawayen pΓ₯ {prize}!")



client.run(TOKEN)```
#

how could i remove the massage !gstart 10 test

#

like this

async def gstart(ctx, mins : int, *, prize: str):
    delete message
    embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)```
#

?

slate swan
haughty nova
#

thanks

stiff fern
#

maybe its bc im using app_commands but idk

stiff fern
#

discord?

#
from discord import Guild, Interaction, app_commands
from discord.ext import commands

like this but im using app_commands for slash commands instead of commands

slate swan
#

on a side note, it has an Interaction not Context
welcome

stiff fern
#

I tried that too I did Interaction.response but I just assumed send_message wouldnt work but ill try it

#

oh wait

#

I need to change ctx in the function

slate swan
#

yes...

haughty nova
stiff fern
#

ooo

#

big brain

slate swan
haughty nova
#

maby just me that write it in the wrong place

#

no problems

slate swan
stiff fern
#

:D

#

I do have another question, when trying to unload extensions it says that they were not loaded which doesn't make sense because I can still use the commands in that file

slate swan
#

did you try restarting the bot?

stiff fern
#

Like just re running it

slate swan
#

yeah

stiff fern
#

ye

slate swan
#

weird

#

can i see the traceback?

stiff fern
#

Like I load it here in the main file, and I just assume its loaded bc the commands work

#
@app_commands.command(name='load', description='Enable a command')
    @app_commands.describe(command_name="Command name")

    async def load(self, interaction: discord.Interaction, command_name: str):
        if command_name != 'critical':
            await self.bot.load_extension(f'{command_name}')

This is how im basically organizing the commands for it

#

But it's also a cog

#

so I dont know if thats why, because when I tried to put it in with the main file it wouldnt work

slate swan
#

weird, dunno the issue for that myself

#

or cz im just too dumb

stiff fern
#

oh alright

narrow grail
#

how to send a direct message to an user which is not me trough interaction.response?

narrow grail
unkempt canyonBOT
slate swan
#

thats prolly not it

#

ok so you can do it

#

but not using interaction.response

#

you can use interaction

#

interaction.user.send("message")

#

i think this will work

slate swan
unkempt canyonBOT
stiff fern
#

So I changed it to use on_command_error so Im not repeating myself w/ each individual command but its not actually catching anything, idk if maybe I used the wrong @event or something maybe thats different to with slash commands

#
    @app_commands.command(name='reload', description='Reload a command')
    @app_commands.describe(command_name="Command name")

    async def reload(self, interaction: discord.Interaction, command_name: str):
        if command_name in ['all', '*']:
            for ext in self.initial_extensions:
                await self.bot.unload_extension(ext)
                await self.bot.load_extension(ext)
        else:
            if command_name != 'critical':
                await self.bot.unload_extension(f'{command_name}')
                await self.bot.load_extension(f'{command_name}')


    @commands.Cog.listener()
    async def on_command_error(self, interaction: discord.Interaction, error):
        if isinstance(error, commands.NoEntryPointError):
            await interaction.response.send_message(embed=self.error_nosetup_embed, ephemeral=True)

        elif isinstance(error, commands.ExtensionNotLoaded):
            await interaction.response.send_message(embed=self.error_notloaded_embed, ephemeral=True)
        
        elif isinstance(error, commands.ExtensionNotFound):
            await interaction.response.send_message(embed=self.error_nosetup_embed, ephemeral=True)

        else:
            await interaction.response.send_message(embed=self.error_failed_embed, ephemeral=True)
            print('works')
            raise error
slate swan
#

discord py?

stiff fern
#

yes

haughty nova
#

somebody that have a good website that hoste you'r bot 24/7 free?

slate swan
#

not interaction

stiff fern
#

so generic resources on the internet aren't as helpful so I basically fix one thing and then someone else doesnt work lol

slate swan
#

so you are using other module for slash?

stiff fern
#

I thought discordpy was still apart of it

#

Oh but yk what I did have to install something else w/ pip for slash commands

left idol
#

why does my bot alternate being able to @ them and sending this?

haughty nova
#
async def gstart(ctx, mins : int, *, prize: str):
    ctx.message.delete()
    embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)```
why doesn't the command !gstart 10 test get removed?
stiff fern
#

These are the libraries im using

haughty nova
#

if that what you mean

slate swan
stiff fern
#

right but I think you have to make message = to whatever ur trying to delete

sick birch
stiff fern
#

do yk which one has the best uptime

#

i used heroku but someone told me to use some other one

sick birch
stiff fern
#

o

sick birch
#

They rarely go down and if they do, they'll be back up very fast

#

Consider many companies small and large rely on them, they need to be very reliable

stiff fern
#

is there a different event for that specifically

haughty nova
#
async def gstart(ctx, mins : int, *, prize: str):
    message = "!gstart"
    ctx.message.delete()
    embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)```
still doesn't remove de message/command
stiff fern
#

o

crisp drift
stiff fern
#

What is a commandtree

sick birch
#

A "tree" that holds all the commands

stiff fern
#

so would that be the class

sick birch
#

I quote it because it's not really a "tree"

#

In the sense of a binary search tree, for example

slate swan
stiff fern
#

So how would I "pass" it

#

Am I needing to put it in as a parameter or something

sick birch
#

Pass it where?

haughty nova
stiff fern
#

He said I need to pass it to the command tree

slate swan
crisp drift
#

self.bot.tree.on_error = your_error_handler πŸ™‚

sick birch
stiff fern
sick birch
#

You can also subclass

stiff fern
#

Is that just a class in a class

sick birch
#

No, are you familiar with inheritance?

stiff fern
#

no but I can look it up rq

crisp drift
#

Obv not, just assign your handler to your tree and it will catches all the errors coming from the app_commands

#

otherwise you would need a local handler

sick birch
#

Personally I find subclassing better because it keeps everything in one place, also more OOP if you get what I'm saying

stiff fern
#

yup yup

crisp drift
#

In that case you could just set it up inside your bot's subclass since it contains the three which is equivalent to what i said (Doing self.tree.on_error = ... Instead). I see no point on making a whole new class for that

stiff fern
fading marlin
#

it takes a discord.Interaction param too

crisp drift
#

no ? py bot.tree.on_error = all_errors (I suppose that is your errors handler)

Note that your command handler need Interaction and error parameters

#

Errors handler*

stiff fern
#

Oh the command handler is what has it okay okay

#

So like this

#

critical is the class

slate swan
stiff fern
#

oh alright

slate swan
#

and bot.tree.on_error = func_name

stiff fern
#

It says expected parameter name when I use a =

crisp drift
#

You do not need a listener and you overload the function within your cog class not in add_cog method..

stiff fern
#

I got rid of the listener, not sure what you mean with overloading the function

#

Oh nvm

#

I see what youre saying

#

I thought you were saying add_cog is wrong

crisp drift
#

it is. You only do self.bot.tree.on_error = self.on_command_error in your def init

stiff fern
#

Oh it goes inside the init

#

Makes sense now πŸ™

slate swan
#

new gatewayevents with the automod seems like a cool feature

crisp drift
dry kelp
#

anyone could help me with sql?

potent spear
dry kelp
#

creating models

potent spear
#

in...?

#

what lib?

sick birch
#

You don't necessarily need a library to create models

#

pen and paper does just fine

potent spear
#

Imagine OCR programming it for you

sick birch
#

A model isn't really something you can "program"

#

It's more of a layout of how you believe your database should look like

#

sort of like psuedocode

#

Though Prisma for example, has their own modelling language

potent spear
#

I'm just thinking about plain SQL
CREATE TABLE ...
where you just draw a model with some columns and relationships
the hardest part would be decrypting my handwriting πŸ˜†

balmy bobcat
#

hello! I need some help for my discord bot

nocturne kelp
#

Having issues with this python bot```py

telnyx lookup

@slash.slash(name="lookup",description="number to lookup",guild_ids=guild_ids)
@commands.has_permissions(administrator=True)
@bot.command(name='lookup', aliases=['pb'])
async def lookup(ctx: SlashContext, phone_number):
try:
await ctx.message.delete()
#async with ctx.typing():
#await asyncio.sleep(1)
i = requests.get(f"https://api.telnyx.com/v2/number_lookup/1{phone_number}")
response = i.json()
embed=discord.Embed(title="Personal Check", description=f"Admin Check" ,color=0x81E15C, timestamp=datetime.utcnow())
embed.set_thumbnail(url="https://www.tillsonburghydro.ca/images/fraud.jpg")
embed.add_field(name="Phone Number:", value=f"{str(response['data']['phone_number'])}", inline=False)
embed.add_field(name="Deep Carrier:", value=f"{str(response['data']['carrier']['name'])}", inline=False)
embed.add_field(name="Country Of Origin", value=f"{str(response['data']['country_code'])}")
embed.add_field(name="Network Node", value=f"{str(response['data']['portability']['ocn'])}", inline=False)
embed.add_field(name="Line", value=f"{str(response['data']['carrier']['type'])}", inline=False)
embed.add_field(name="Note:", value=f"Thank You For The Help!", inline=False)
embed.set_footer(text=f"Resquested By: {ctx.author.name}#{ctx.author.discriminator}", icon_url=ctx.author.avatar_url)
await asyncio.sleep(1)
await ctx.send(embed=embed,delete_after=50)

 except Exception as error:
   async with ctx.typing():
    await asyncio.sleep(4)
   embed=discord.Embed(title="Invaild Number Pal!", description=f"{phone_number}", color=0xff0000)
   await ctx.send(embed=embed,delete_after=10)

 print(i)
stiff fern
#

mood

balmy bobcat
#

Is there any way to access global variables inside async def?

stiff fern
#

super() is my guess but idk

nocturne kelp
#

TypeError: lookup() got an unexpected keyword argument 'kwargs'

stiff fern
#

Is there a way to name a variable with a space?