#discord-bots

1 messages Β· Page 1063 of 1

vale wing
#

I rewrote my bot like twice

#

First from pickle to sqlite

#

Then from sqlite to asyncpg

#

Now third time to rewrite it to slash commands

#

😩

maiden fable
#

Lmao

#

BTW @vale wing how to specify the tz in datetime.now()?

vale wing
#

Eh wait haven't done that in a while

maiden fable
#

Like if I wanna specify IST

sullen pewter
#

Does anyone know what's wrong in this code

@client.event
async def on_member_join(member):
    button = Button(label = 'Write an introduction', style = discord.ButtonStyle.green)

    async def button_callback(interaction: discord.Interaction):
        await member.send('What would you like your nickname to be? (32 character max)')
        
        async def on_message(message):    
            try:
                message = await client.wait_for("message", check=lambda m: m.content == m.channel == message.channel)
            except asyncio.Timeout.Error:
                await member.send('You took too much to respond.')
            
            else:
                if len(message).content <= 32:
                    await member.send(f'Nickname set to {message}!')
                else:
                    await member.send('Something went wrong please try again.')


    view = View()
    button.callback = button_callback
    view.add_item(button)

    await member.send(f'Welcome to the server {member.mention}! Use the button below to make an introduction and get access to the server.', view = view)
placid skiff
#

it depends on what problems you have

sullen pewter
#

There are no errors

vale wing
#

!d datetime.timezone @maiden fable probably make an object of this

unkempt canyonBOT
#

class datetime.timezone(offset, name=None)```
The *offset* argument must be specified as a [`timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "datetime.timedelta") object representing the difference between the local time and UTC. It must be strictly between `-timedelta(hours=24)` and `timedelta(hours=24)`, otherwise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised.

The *name* argument is optional. If specified it must be a string that will be used as the value returned by the [`datetime.tzname()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzname "datetime.datetime.tzname") method.

New in version 3.2.

Changed in version 3.7: The UTC offset is not restricted to a whole number of minutes.
sullen pewter
#

It's not responding when I send a message

#

@placid skiff

placid skiff
#

do you have any other on_message event in your code?

warped mirage
#

can someone help me fix this

vale wing
#

button_callback must have 2 args: the button itself and the interaction

placid skiff
#

And have you enabled message contents intent?

vale wing
#

Also bad method to assign callback

sullen pewter
vale wing
#

And you get no errors because of improper error handler most likely

light violet
#

how do i get the id or the person authorizing my bot

vale wing
#

It must raise unhandled errors

light violet
#

how do i get it pls help

vale wing
sullen pewter
vale wing
#

Yours has only interaction

sullen pewter
#

yes

vale wing
#

It must also have self

sullen pewter
#

It's not a cog

vale wing
#

The button

light violet
vale wing
#

That's why you should subclass views and not do it like this

sullen pewter
#

idk how to do that

vale wing
sullen pewter
#

maybe

vale wing
#

Nah that's OOP

#

It's an instance of class at the moment of function execution

#

In simple words

vale wing
vale wing
#

Yes

#

Just was going to send this to you lol

sullen pewter
#

lol

sullen pewter
#

I've had a bot without it and it worked fine

vale wing
#

!d discord.ui.Button.callback

unkempt canyonBOT
#

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

The callback associated with this UI item.

This can be overridden by subclasses.
vale wing
#

It's not a staticmethod

#

The self attribute is required

#

In views it is a bit different, self is View, button is Button and interaction is MessageInteraction

#

Or whatever it is in dpy

sullen pewter
#

super().__init__()

vale wing
#

May I ask

sullen pewter
#

Yessir

vale wing
#

Do you know object-oriented programming

sullen pewter
#

yes

#

but I am not good at it

vale wing
#

Ok

sullen pewter
#

I think I only know basics

vale wing
#

super() is a method of accessing the method of the superclass

placid skiff
#

super() is the super constructor, when you create a subclass you can call the super method to access the superclass

vale wing
#

Basically self.method() will call the method you overwrite and super().method() will call original method inherited from superclass

sullen pewter
#

oh ok

placid skiff
#

so super().__init__ will call the constructor of the superclass

#

it means that you will have to pass to the subclass all the parameters that you will originally pass in the superclass

sullen pewter
#

makes sense

placid skiff
#

Exe let's start a python class D_D

light violet
#

How to fetch the user who is autjorizing my bot i need to know that

#

Authorizing* pls help

placid skiff
#

I don't know if it is possible, i will check the doc

sullen pewter
#

How to use button_callback when using view subclass

slate swan
# sullen pewter How to use button_callback when using view subclass
class ExampleView(discord.ui.View):
    @discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
    async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
        await interaction.response.send_message('Confirming', ephemeral=True)
        self.stop()

you mean that?

slate swan
#

oh and the order has changed of the parameters so keeping that in mind

sullen pewter
visual island
vale wing
sullen pewter
#

that makes lots of sense

vale wing
sullen pewter
#

Can I have discord.ui.button(...) inside of async def on_member_join

vale wing
#

You typically define views in a separated module and import them from it

sullen pewter
#

ok

slate swan
vale wing
#

Yes but considered a good practice

slate swan
#

well it indeed is

#

we can also put int

cloud dawn
vale wing
slate swan
#

uh keys

#

ye keys are string

vale wing
#

!e

from json import dumps

print(dumps({10: "yes", 20: True}))```
unkempt canyonBOT
#

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

{"10": "yes", "20": true}
slate swan
#

i thought value sry

vale wing
#

Ok

sullen pewter
#

How to send normal messages after an interaction

slate swan
sullen pewter
#

not interaction.response.send_message

slate swan
#

and its error of end giv method

vale wing
sullen pewter
#

ok, ty

#
@discord.ui.button(label='Write an introduction', style=discord.ButtonStyle.green)
    async def callback(self, interaction: discord.Interaction, button: discord.ui.Button, member):
        await interaction.channel.send(f'Welcome to the server {member.mention}! Use the button below to make an introduction and get access to the server.')
        self.value = True
        self.stop()```
#

Can I add member?

#

in the args

vale wing
#

No

sullen pewter
#

how can I mention the user?

#

interaction.author.mention?

vale wing
#

interaction.author (the attribute may also be interaction.user, depends on lib)

sullen pewter
#

ty

vale wing
#

You should check docs

#

!d discord.MessageInteraction

unkempt canyonBOT
#

class discord.MessageInteraction```
Represents the interaction that a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is a response to.

New in version 2.0...
sullen pewter
#
class Introduction(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    @discord.ui.button(label='Write an introduction', style=discord.ButtonStyle.green)
    async def callback(self, interaction: discord.Interaction, button: discord.ui.Button, member):
        await interaction.channel.send(f'Welcome to the server {interaction.user.mention} Use the button below to make an introduction and get access to the server.')
        self.value = True
        self.stop()

@client.event
async def on_member_join(member):
    view = Introduction()
    await member.send(f'Welcome to the server {member.mention}! Use the button below to make an introduction and get access to the server.', view=view)```
#

solved

#

How to remove this red note under the button after an interaction?

#

There are no errors

#

and interaction works

#

I just want to remove the red thing under it

vale wing
#

Reply to that interaction (I don't think there's any other method to remove it)

#

Deferring it will only give forever "bot is thinking" message

#

Reply with some ephemeral like "go to #welcome to make your introduction"

sullen pewter
#

ic

#

Is there message.content.after bot's message => await message.reply('Blah, blah, blah')

#

wait_for ^

slate swan
#

uh?

sullen pewter
# slate swan uh?

Bot: What would you like your nickname to be? (32 character max)
User: Ronald
Bot: Nickname set to Ronald!

slate swan
sullen pewter
#

wdym

slate swan
sullen pewter
#

Ik but I cant

#

wait_for what

maiden fable
sullen pewter
#

wait_for bot messag

maiden fable
#

Since msg is a discord.Message object

sullen pewter
maiden fable
#

"message"

sullen pewter
#

if I want it to wait for it's own nickname message

maiden fable
#

There are examples in the docs

sullen pewter
slate swan
#
import asyncio
import discord
try:
  msg: discord.Message = await Bot.wait_for("message", timeout=300, check=if_any_custom_check)
except asyncio.TimeoutError:
  ...
maiden fable
#

Ash writing a paragraph

#

Nvm

supple thorn
#

I forgot about ashley

slate swan
#

πŸ˜”

rocky hornet
#

oops wrong channel

maiden fable
#

Lol it's fine

rocky hornet
#

nah ill repost to general

sullen pewter
#
@bot.command()
async def command(ctx):
    await ctx.send("Type: `hello`")
    def check(m):
        return m.content == 'hello' and m.channel.id == ctx.channel.id
    try:#`msg` will receive a message object if check function returns True
        msg = await bot.wait_for('message', check=check,timeout=10)
    except asyncio.TimeoutError:#time out error will be raise when it has been 10 seconds
        await ctx.send("10 seconds has passed, timeout.")
    else:
        await ctx.send(f'Hello {ctx.author}!')```
sullen pewter
maiden fable
#

Ash will help u with this

#

(CC @slate swan)

sullen pewter
rocky hornet
#

so they write their new names in chat?

slate swan
rocky hornet
#

msg = await bot.wait_for(...)
this line gives you a message object of the message that passed your check

sullen pewter
#

but that's not what i want

sullen pewter
#

I want users to change their nicknames after bot offers them to change it

sullen pewter
#

If bot sends Babooey message users have to change their nickname

rocky hornet
#

oh

#

so you want to track nick change or?

slate swan
rocky hornet
#

i still dont get it

#

who changes what

placid verge
rocky hornet
#

what is hello

placid verge
sullen pewter
#

no

placid verge
rocky hornet
#

yeah, so why are you waiting for message, not name change

sullen pewter
#

Example:

slate swan
#

pfffttt

placid verge
rocky hornet
#

bruh

sullen pewter
#

I may be bad at explanation but this is what I meant

rocky hornet
#

wait for message, grab resulting message's content, change msg author's name to this content

sullen pewter
#

||or you just have bad comprehension(I don't mean it in a mean way lol)||

rocky hornet
rocky hornet
#

tells something

slate swan
# sullen pewter I may be bad at explanation but this is what I meant
import asyncio
import discord
try:
  msg: discord.Message = await Bot.wait_for("message", timeout=300, check=if_any_custom_check)
except asyncio.TimeoutError:
  ...
if len(message.content) > 32:
    return "No"
#you should really use some filters to allow in specific characters
await ctx.author.edit(nick=msg.content)
sullen pewter
#

then that just makes me bad at explaining

slate swan
slate swan
placid verge
#

uh maybe don't fight

slate swan
vale wing
#

Wth

placid skiff
#

Ayo calm down

placid verge
#

steps back

slate swan
#

leaves

placid verge
#

runs

rocky hornet
#

awaits

slate swan
sullen pewter
#

lol

light violet
#

how to fix non type object is not subcriptible

#

code = exchange_code('')['access_token']

#

getting error in this

#

!eval
code = exchange_code('')['access_token']

unkempt canyonBOT
#

@light violet :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'exchange_code' is not defined
light violet
#

!eval

code = exchange_code('')['access_token']

unkempt canyonBOT
#

@light violet :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'exchange_code' is not defined
light violet
#

!eval

def exchange_code(code):
print("something")

code = exchange_code('')['access_token']

unkempt canyonBOT
#

@light violet :x: Your eval job has completed with return code 1.

001 | something
002 | Traceback (most recent call last):
003 |   File "<string>", line 4, in <module>
004 | TypeError: 'NoneType' object is not subscriptable
light violet
#

why

maiden fable
#

Calm down share the code

wanton cipher
maiden fable
#

Yes

#

!e None["some useless little attribute"]

unkempt canyonBOT
#

@maiden fable :x: Your eval job has completed with return code 1.

001 | <string>:1: SyntaxWarning: 'NoneType' object is not subscriptable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'NoneType' object is not subscriptable
wanton cipher
#

@light violet I think start by figuring out why it's returning None, or use try excepts maybe

jagged adder
#

can anyone tell me why this pause command isnt working ?

#checks
PAUSE_STATE = False

@bot.event
async def on_message(message):
 
    global PAUSE_STATE

    if message.channel.id not in (x, x):
        return

    if message.author == bot.user:
        return

    if message.content.upper == "PAUSE":
        PAUSE_STATE = True
        return
    if message.content.upper == "RESUME":
        PAUSE_STATE = False

    if PAUSE_STATE:
        return

    if message.content.startswith("Play"):
        #time.sleep(3)
        await message.channel.send("**Act One, Scene One: The Beginning**")

im trying to stop the code from continuing past this point if PAUSE_STATE == True

but its continuing to accept inputs lower down the on_message function

light violet
#

def exchange_code(code):
data = {
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'grant_type': 'authorization_code',
'code': code,
'redirect_uri': REDIRECT_URI
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
r = requests.post('%s/oauth2/token' % API_ENDPOINT, data=data, headers=headers)
r.raise_for_status()
return r.json()

#

getting bad response for this

#

everything is correct

wanton cipher
wanton cipher
jagged adder
#

unless im missing something

vagrant brook
#

Everytime it receives a message that function gets called again

jagged adder
#

feel free to educate me, as im still learnin new things relating to this every day

vagrant brook
#

You need to make pause_state a global variable

jagged adder
#

would actually be appreciated if you were able to explain where the issue is

#

wait...

#

yeah it is atm

vagrant brook
#

global PAUSE_STATE

jagged adder
#

in my code it is, missed it when i was copy pasting selectively

vagrant brook
#

oh yeah I missed that first line but you still need the global keyword

slate swan
jagged adder
#

yeah i have the global in there, ill edit my copy paste sec

slate swan
#

use bot variables instead

#

!botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

wanton cipher
vagrant brook
#

Also upper is a function I think

#

You should call it

slow fog
wanton cipher
slate swan
vagrant brook
#

upper()

jagged adder
#

yeah i been using that loads through the code

slow fog
jagged adder
slate swan
vagrant brook
#

sus

slow fog
#

Suspicious activity

tidal hawk
#

Is there some sort of a Rate limit, how many bots you can run at once?

slate swan
#

and if you are running them from the same ip

#

you'll get blocked faster

tidal hawk
#

Wtf

#

Just woke up and saw that 3 of my bots aint working "disnake.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited."

#

Damn it

slow fog
#

Oh yes

#

Thats why some people are actually using many nodes to host

wanton cipher
jagged adder
# unkempt canyon

how would i go about using this if i have alot of variables? (which i do)

drowsy pendant
#

!userinfo

#

!user_info

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

wanton cipher
jagged adder
#

so this..?

bot.PAUSE_STATE = False

@bot.event
async def on_message(message):

    if message.channel.id not in (x, x):
        return

    if message.author == bot.user:
        return

    if message.content.upper == "PAUSE":
        bot.PAUSE_STATE = True
        return
    if message.content.upper == "RESUME":
        bot.PAUSE_STATE = False

    if bot.PAUSE_STATE:
        return

    if message.content.startswith("Play"):
        #time.sleep(3)
        await message.channel.send("**Act One, Scene One: The Beginning**")
tidal hawk
jagged adder
#

what is the reason to use bot. over a standard variable?

slow fog
#

You got the point

wanton cipher
jagged adder
#

which does ...

tidal hawk
#

Likee.. run bots from different ip?

jagged adder
slow fog
jagged adder
#

the only bot. stuff ive done is based off examples ive been given; i presume itll help somewhere but if i dont know how to use it

wanton cipher
slow fog
#

Supposed

slate swan
#

Hey I want to make my bot 24/7, any help?

slate swan
slow fog
# slow fog Yes

Only if discord are dealing with requests by ips and not by the application id which is gonna be a problem in your case

slate swan
jagged adder
potent spear
slow fog
#

I think you must try to run them with a different ips

potent spear
#

also, you most likely only need that variable in scope of your bot
that's a double kill (you don't have to pass your bot AND that variable as an arg)

slow fog
#

If its still then discord does contain requests by the application id and not by the ip

wanton cipher
jagged adder
#

well the bot is going to become a lot more advanced later on (because of that, id appreciate if someone who knows their shiz would be willing to put aside a bit of time to run through the code with me and see how i can optimize it/implement certain features.)

#

before it grows into a monster job to change everything later :p

wanton cipher
tidal hawk
#

So I'm f-ed? xd

slow fog
#

Are you running them from a vps service?

tidal hawk
#

Mhm

#

Actually 3/6 bots are running, somehow

slow fog
#

Wait im stupid

#

I thought you were the other guy for a moment

tidal hawk
#

xd

wet crystal
#

In the Discord docs, what does the Optional mean under the attributes?

wanton cipher
jagged adder
#

am i the "other guy"? πŸ‘€

slow fog
jagged adder
wanton cipher
jagged adder
wet crystal
wanton cipher
jagged adder
#

wdym by future resistant?

wanton cipher
wanton cipher
# jagged adder wdym by future resistant?

if I want to keep tinkering and tinkering, I try go for the things that save me from completely restating things and/or are more willing to be upgraded with the newer features

jagged adder
#

i see...

#

i mean that sounds like a good idea?

wanton cipher
#

like I said, look into commands, then maybe look into cogs, but as of now, if you doing simple things, the on_message event will work fine for a bit

jagged adder
#

i mean its a text adventure with more complicated features so...

#

prolly relatively simple, once i work out how to make it do what i want

manic path
#

'_overwrites[0].allow{'new_value':1024, 'old_value':0}
What do 1024 represent? I changed view channel for @everyone and i got this from after in on_channel_update.

tidal hawk
#

How can I use response header to get information about my rate limits?

wanton cipher
#

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

maiden fable
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User")...
maiden fable
tidal hawk
#

It doesn't give me those necessary params I want to see. It only says: disnake.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being rate limited.

#

I want to see, for how long am I?

#

and if it's global or user

jovial plover
#

user = client.get_user(int(getUser(ctx.channel.id)))
await user.add_roles(discord.utils.get(ctx.guild.roles, name="Whitelist"))

#

why is this not working

tough lance
#

What's getUser

placid skiff
#

bruh you want to get a user object with the id of a channel D_D

jade tartan
jovial plover
#

User is not None.

#

Any help?

#

AttributeError: 'User' object has no attribute 'add_roles'

supple thorn
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

Only member has that

#

^

slate swan
slate swan
terse coyote
#

how to get amount member's messages?

potent spear
terse coyote
#

yes

potent spear
#

only thing I can think of is loop through every text_channel in the guild and check the history there where you check if the author was the user you're looking for

terse coyote
#

hm

slate swan
terse coyote
#

oh ok, thx

heady sluice
#

then why can we tho

#

if you think about it, we make those API calls too

#

when we click on search and type from:meh

slate swan
#

Bot accounts aren't allowed to use that endpoint iirc

vale wing
gaunt mortar
#

Hi guys, I got issues while trying to catch exceptions on a discord bot project - I did not have this issue while catching exceptions on other projects..
"TypeError: catching classes that do not inherit from BaseException is not allowed"

My Exception class inherit from Exception :

class BalanceInsuffisanteException(Exception):
    pass
    async def on_submit(self, interaction: Interaction):
        if findMiseForBet(interaction.user.id, self.bet["_id"]) is not None:
            embed = discord.Embed(color=0xff2429)
            embed.add_field(name="Pari refusΓ©", value="Tu as dΓ©jΓ  misΓ© sur ce pari", inline=False)
        else:
            try:
                addMiseToDB(interaction.user.id, str(self.children[0]), str(self.choice), self.bet, self.bet['date'], self.bet['heure'], self.idUsed)
                embed = discord.Embed(color=0x152dff)
                embed.add_field(name="Pari validΓ©", value="Tu as misΓ© 500 jetons sur une victoire", inline=False)
            except BalanceInsuffisanteException as e:
                embed = discord.Embed(color=0xff2429)
                embed.add_field(name="Pari refusé", value="Tu ne possèdes pas assez de jetons", inline=False)
            except DelaiDepasseException as e:
                embed = discord.Embed(color=0xff2429)
                embed.add_field(name="Pari refusΓ©", value="Le dΓ©lai pour miser sur ce pari est passΓ©", inline=False)
        await interaction.response.send_message(embed=embed)

Maybe am I doing wrong in catching exceptions since it's an async function & an await at the end ? I don't really know..

vale wing
gaunt mortar
# vale wing Could you show the full traceback

Yep for sure !

Ignoring exception in modal <DoBet timeout=None children=1>:
Traceback (most recent call last):
  File "C:\Users\Utilisateur\Desktop\kothbot\components\modals\DoBet.py", line 26, in on_submit
    addMiseToDB(interaction.user.id, str(self.children[0]), str(self.choice), self.bet, self.bet['date'], self.bet['heure'], self.idUsed)
  File "C:\Users\Utilisateur\Desktop\kothbot\db\Mise.py", line 45, in addMiseToDB
    raise BalanceInsuffisanteException()
exceptions.BalanceInsuffisanteException.BalanceInsuffisanteException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Utilisateur\Desktop\kothbot\venv\lib\site-packages\discord\ui\modal.py", line 187, in _scheduled_task
    await self.on_submit(interaction)
  File "C:\Users\Utilisateur\Desktop\kothbot\components\modals\DoBet.py", line 29, in on_submit
    except BalanceInsuffisanteException as e:
TypeError: catching classes that do not inherit from BaseException is not allowed
placid skiff
#

this is weird lol

slate swan
unkempt canyonBOT
#

discord/http.py lines 727 to 734

if before is not None:
    params['before'] = before
if after is not None:
    params['after'] = after
if around is not None:
    params['around'] = around

return self.request(Route('GET', '/channels/{channel_id}/messages', channel_id=channel_id), params=params)```
vale wing
slate swan
loud junco
#

hi

gaunt mortar
vale wing
gaunt mortar
vale wing
#

Ok that's weird

gaunt mortar
#

Maybe is it related to how I'm raising the exception ? idk

vale wing
#

Print BalanceInsuffisanteException.__mro__ before the critical statement

vale wing
gaunt mortar
vale wing
#

Ok

gaunt mortar
slate swan
#

do you import the class itself?
because from what i see, the name of your file is same as the name of the class~

vale wing
#

Oh yeah

#

Btw follow naming convention for god's sake

#

Are you a java programmer or smth

gaunt mortar
vale wing
#

Cause in java the standard is one class per file

gaunt mortar
#

yep

vale wing
#

In python it's not

#

It's several classes per module

#

Put all exceptions into one module and import them from there

gaunt mortar
#

ok ok, gonna do this

vale wing
#

Most likely you were trying to catch a module lol

flint isle
#

how can i check if my bot has a specific permission

vale wing
#

Specific channel permission or guild

flint isle
#

guild

vale wing
#

!d discord.Member.guild_permissions use ctx.me to get the bot's Member

unkempt canyonBOT
#

property guild_permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions
and not most of the implied permissions or any of the
channel permission overwrites. For 100% accurate permission
calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for")...
flint isle
#

ok

flint isle
slate swan
#

yea

flint isle
#

umm


disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: ExtensionFailed: Extension 'cogs.aboutme' raised an error: TypeError: Couldn't find an interaction parameter in <function aboutme.info at 0x000002E26F09F010>

cogs code
aboutme.py

import disnake
from disnake.ext import commands
from datetime import datetime
import time
from wb import config
from colorama import Fore
class aboutme(commands.Cog):

    def __init__(self, bot: commands.Bot):
        self.bot = bot
        print(Fore.CYAN + 'Loading About Me cog' + Fore.WHITE)

    @commands.slash_command(name='info', description='Tells you about myself.')
    async def info(self):
        embed = disnake.Embed()
        embed.title = 'About Me UwU'
        embed.set_footer(text='❀ Made with Love ❀')
        embed.set_author(name=f'self.bot.user.name', icon_url=f'{self.bot.user.avatar}')
        embed.description = f"""
    """

    @commands.slash_command(name='permissions')
    async def permissions(self, ctx):
        me = ctx.me
        print(me.guild_permissions)
#        if me.guild.permissions == 'administrator'


def setup(bot):
    bot.add_cog(aboutme(bot))
regal pulsar
#

hello

regal pulsar
slate swan
regal pulsar
#

πŸ‘‹ .

placid skiff
slate swan
placid skiff
#

Hi there

flint isle
regal pulsar
#

for the second one

#

not ctx

flint isle
#

yeah

#

is there a way to calculate what perms my bot has using the permission value?

placid skiff
regal pulsar
#

but dont

#

i remember when i called ctx message

placid skiff
#

Well i mostly use my AnyContext object lel

regal pulsar
#

i never fixed it till i learnt cogs

regal pulsar
slate swan
flint isle
#

its in my code but not in that codeblock

robust fulcrum
#

Guys is there any way to add buttons in discord.py 1.7
Cause replit pip trash it not download 2.0

flint isle
#

no.

regal pulsar
#

but you can just use disnake

#

pip install disnake

robust fulcrum
#

Hmm discord.ui?

regal pulsar
#

yeah

#

!d disnake.ui.Button

robust fulcrum
#

Will it work?

unkempt canyonBOT
#

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

New in version 2.0.
flint isle
#

just use disnake XD

robust fulcrum
regal pulsar
#

disnake is just a fork of d.py

#

also original what

robust fulcrum
regal pulsar
#

yeah

robust fulcrum
#

And buttons?

regal pulsar
#

its exactly the same

#

just replace the discord with disnake in your code

robust fulcrum
#

Is pycord or disnake or nextcord better

regal pulsar
#

disnake is the best

robust fulcrum
#

Ok

#

Actually replit is trash

regal pulsar
#

yeah

slate swan
#

none is the best, use dpy 2.0 or a separate discord api wrapper

regal pulsar
#

try railway

slate swan
robust fulcrum
#

πŸ˜‚

regal pulsar
#
Railway

Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.

regal pulsar
robust fulcrum
#

Will it work?

#

But πŸ’°

slate swan
regal pulsar
#

oh

slate swan
#

at the shared ips level

robust fulcrum
#

But bro my parents doesn't allow use money on internet

slate swan
#

but anyways, you cant code with it if you are doing the same with replit

regal pulsar
#

wait a minute

#

do i not know what replit does

robust fulcrum
#

Lmso

regal pulsar
#

uh oh

robust fulcrum
slate swan
#

i think i will just go away

regal pulsar
#

ah it can host

#

i thought you were using replit to host

robust fulcrum
#

For free

regal pulsar
#

not to code πŸ’€

flint isle
#

... dude just self host the bot

robust fulcrum
#

No i used to for code too

regal pulsar
#

why

robust fulcrum
#

Bro Android

regal pulsar
#

just use any ide

#

oh

robust fulcrum
#

XD

slate swan
regal pulsar
#

dont have a pc/laptop?

robust fulcrum
#

I have

slate swan
#

stop

regal pulsar
robust fulcrum
#

But lazy to turn on

regal pulsar
#

. . .

slate swan
#

turn it on once and never turn it off again.

robust fulcrum
#

Mobile easy

#

No need to shut down

regal pulsar
#

you could do 6 hours of android coding in one hour on a pc

flint isle
#

anyways... is there a way that i could run a slash command via a prefix?

robust fulcrum
#

No

regal pulsar
#

its called a slash command

flint isle
#

can i run my /ping command via a $ping

#

as a alternative to people who want to see them in the help documentation

#

or how can i put slash commands in the help documentation lol

slate swan
#

you can invoke your normal command with a slash command but not a message command with a slash one L

grand shell
#
@commands.Cog.listener()
    async def on_guild_channel_delete(self, channel):
        if channel not in channel.guild.categories:
            return
        oldChannels = channel. ???
        for oldChannel in oldChannels:
            await oldChannel.delete()

hey guys, how can i get a list of the text channels that were in a category before it was deleted? normally, when you delete a category, all the channels are freed and dont belong to a category anymore but im trying to delete them if their category is deleted

slate swan
#

channel.channels ~

grand shell
flint isle
#

disnake

slate swan
#

!d disnake.SlashCommand.description

unkempt canyonBOT
flint isle
#

will that show up in the help command?

slate swan
#

you would have to subclass HelpCommand class and override its methods to add the slash commands

flint isle
#

hmm any guides for that?

tidal hawk
#

Where can I see, for how long I've been rate limited?

#

Just got it randomly tonight

flint isle
#

What host are you using lol

loud junco
#

replit

tidal hawk
#

Na

#

Vultr

loud junco
#

porkchop

stray carbon
#
  File "c:/Users/Akai/Desktop/Sugari/main.py", line 10, in <module>
    from .util.bot import Sugari, getprefix
ImportError: attempted relative import with no known parent package
tidal hawk
stray carbon
flint isle
#

Oil @stray carbon remove the dot from before util

stray carbon
flint isle
#

Hmm wtf

#

Can you un collapse utility? In a screenshot

tidal hawk
#

Looks like there are a lot of people getting this issue

#

People are talking about it official Discord developer server

heavy shard
#

isn't "utils" inside of "cogs"? looks like it to me

spring flax
#

what are the benefits or using bot.http.send_message?

stray carbon
stray carbon
wanton cipher
#

!d discord.CategoryChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

Hello, tell me how to make the text limit vertically and horizontally in the white box

wispy sequoia
#

I want to make a command deleting a given role, but of course I'm not able to delete a role created for a bot. how do I make an error handler for that?

#

like, if it recognizes that it's a bot role, it replies saying that

weak moat
wispy sequoia
#

no

wanton cipher
wispy sequoia
#

the command is deleterole

#

I provide the role name/id and it deletes it

#

but you guys know when you make a bot joins a server, it automatically creates a role for itself

#

and that role is not able to get deleted

#

I want my bot to reply it's not able to delete that role if the user provides it

wanton cipher
wispy sequoia
#

already tried

wanton cipher
#

hmm

wispy sequoia
#

I made a try/except thing

#

try:
except discord.Forbidden:
except:

#

it always passes except only

wispy sequoia
#

no clue man

wispy sequoia
wanton cipher
heavy shard
#

@wispy sequoia the documentation is short about it, but i think you're looking for discord.Role.is_bot_managed

wanton cipher
#

welp, there you go xD

unkempt canyonBOT
#

is_bot_managed()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Whether the role is associated with a bot.

New in version 1.6.
wispy sequoia
heavy shard
#

yeah, sure

wispy sequoia
#

it still raises error

#

let me check if I did something else wrong first

wispy sequoia
# heavy shard yeah, sure
@bot.command()
async def test(ctx):
    currentGuild = bot.get_guild(ctx.guild.id)

    try:
        for role in currentGuild.roles:
            print(role.id)

            # if role.is_bot_managed():
            #print("couldn't delete")
            # return
    except:
        return print("error")

this is the code, I modified it so I can see if it's something else. at the moment, it prints all the roles' IDs as it's supposed to do. any clue on what's wrong?

slate swan
#

what, why getting the same guild object again?

wispy sequoia
#

oh yeah

slate swan
wispy sequoia
#

that's not a problem anyways

slate swan
#

wots the issue?

#

ah ```py
for role in roles:
if role.is_bot_managed(): continue

delete role

wispy sequoia
#

yes

slate swan
#

and you also need to ignore the everyone role..

wispy sequoia
#

also

wispy sequoia
#

wait

#

I think I know what's wrong

#

does it start from the bottom? because if so that's the issue, bc it tries to delete @ everyone

heavy shard
#

The first element of this list will be the lowest role in the hierarchy. ... yes

wispy sequoia
#

lol

#

sorry then, I feel stupid πŸ’€

slate swan
#

just if role.id == ctx.guild.id: continue it pBear

wispy sequoia
#

is the @ everyone role

is_default()

?

slate swan
#

!d discord.Role.is_default

unkempt canyonBOT
#

is_default()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Checks if the role is the default role.
slate swan
#

yeah

wispy sequoia
#

nice

slate swan
#

but, eh thats just an extra call, just compare the role id with the current server's id
the id of everyone role is always same as the server's ID

#

thats what that method does essentially

warped mirage
#

Hello can someone help me code my warnsystem

#

Like continue it

slate swan
#

Why does my python bot keeps sending messages when I sent message that isn't even contains in message.content.lower?

#chat bot
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if 'hello' in message.content.lower():
        await message.channel.send(random.choice(greetings))
        time.sleep(1)
        await message.channel.send(random.choice(cq))

wispy sequoia
#

I feel dumb πŸ₯²

warped mirage
#

@slate swan u down or busy

slate swan
#

Intents = discord.Intents.default()
Intents unresolved reference

slate swan
#

what could even be wrong??

glad cradle
slate swan
glad cradle
#

have you tried to run your code?

warped mirage
#

Damn everyone’s mad

#

🀑

glad cradle
slate swan
#

yes and nothing seems to work fine when related to intnets + this first time happens

heavy shard
#

did you make a folder discord ?

slate swan
glad cradle
warped mirage
#

Guys I need help making my warnsystem , I think I made the tables but I need some help with commands and ye . I’m using a cog

glad cradle
slate swan
#
import json
import discord
from discord.ext import commands

import os.path
botinfo = json.load(open('config.json'))
token = botinfo.get('Token')
prefix = botinfo.get('Prefix')
intents = discord.Intents.default()
bot = commands.Bot(command_prefix = prefix, intents=intents)

bot.remove_command("help")
for filepy in os.listdir("./cogs"):
    if filepy.endswith(".py"):
        bot.load_extension("cogs." + filepy[:-3])

bot.run("e")```
glad cradle
warped mirage
#

Ok then I already asked so ima wait

glad cradle
heavy shard
glad cradle
regal pulsar
unkempt canyonBOT
#

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

slate swan
slate swan
vale wing
#

Updating it might help as well

#

pip install -U discord.py

edgy mantle
#

anyone know how i can make these options with app_commands in discord.py and pycord

heady sluice
#

and you don't need an f-string

#

but you might need members intents

edgy mantle
#

Indeed

warped mirage
#

I’m a twine peaks dude lol

edgy mantle
warped mirage
#

I’m pl 115 cuz I haven’t played in awhile

#

What about battle royale I heard there is a new season about to drop

heady sluice
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

heady sluice
#

read the whole thing not just the code

#

from discord import Intents

spring flax
#

what are the benefits or using bot.http.send_message?

slate swan
#

whats a way to get all commands in a bot
in code,
like
getbotcommands
print commands
im using cogs by the way

heady sluice
#

!d discord.ext.commands.Bot.commands

unkempt canyonBOT
stone beacon
#

/

slate swan
#

\

warped mirage
#

guys this is my cog , can someone help me fix the undefined clients first of all

heady sluice
#

pass self

#

use self.client

#

python

warped mirage
#

So in the() do I just add self ?

heady sluice
#

yes

#

setup_db(self)

warped mirage
#

Ok

ashen notch
#

Anyone know off hand if there's any Discord documentation for the new voice channel text channel things? Can't seem to locate anything.

heady sluice
#

can't even find the master api reference now

#

oh it's latest not master

#

oh ForumChannel, might this be it?

ashen notch
#

No that's a separate feature

#

Unless it's how they're doing it...

#

Hmm

heady sluice
#

this is all we got

knotty agate
#

i want my bot to be able to send messages outside of an event
so like lets say i want it to send a message every hour saying 'one hour has passed'

import discord
import time
import threading

client = discord.Client()

def time_alert():
  output_channel = client.get_channel(343944376055103488)
  while True:
    time.sleep(3600)
    |AWAIT| channel.send("one hour has passed")

thread = threading.Thread(target=time_alert)
thread.start()
client.run(token)

the issue with this is i cant use await

heady sluice
#

use tasks

knotty agate
#

what are tasks?

heady sluice
#
from discord.ext import tasks

@tasks.loop(seconds=3600)
async def my_background_task():
    #do your thing

my_background_task.start()
bot.run(TOKEN)
#

since you want to get a channel, you'd have to put await bot.wait_until_ready() at the start of your task

#

so the cache is loaded

ashen notch
heady sluice
ashen notch
#

Ah, gotcha. Was hoping for specific Discord docs rather than d.py

#

But I guess I could comb through the code

#

Odds are good we aren't there yet, though.

heady sluice
#

maybe a fork has it

ashen notch
#

Possible. But I can't even find API docs on it in Discord's Developer docs

heady sluice
#

I have never looked at discord docs itself

ashen notch
#

Oh no wait

#

It is in there? In d.py

#

Whelp, time to roll up my sleeves and get a-hunting

heady sluice
#

I'm not sure I follow 😭

ashen notch
#

Yarp

slate swan
ashen notch
#

Wasn't sure if that's what it was or not

heady sluice
#

wtf

#

what do they mean last message in a voice channel

ashen notch
#

So voice channels are getting a feature where they have a text channel bundled into them. Means we don't have to have #751591688538947646 and #voice-chat-text-0 as separate channels. However I want to see how they work with regards to the API endpoints. I just can't seem to track down the official endpoint docs for this new feature

#

It hasn't been fully rolled out

#

I think it's only on one server I've been on

heady sluice
#

understandable

slate swan
ashen notch
#

I want to know where Danny et al. found it

heady sluice
#

nah it continues

ashen notch
#

Still wouldn't hurt to regen

heady sluice
#

what lib are you using

slate swan
heady sluice
#

haven't seen discord.commands yet

ashen notch
#

Isn't it discord.ext.commands?

#

I genuinely can't remember

heady sluice
#

yeah but that doesn't have slash commands either

slate swan
ashen notch
#

Gotcha

heady sluice
#

or permissions

slate swan
#

ill ask in the dpy server and let you know

#

even better bro

heady sluice
#

maybe they won't be toxic about this one

heady sluice
heavy shard
#

you need to install python-dotenv module

ashen notch
#

Derp

slate swan
slate swan
ashen notch
#

I have no idea why I worded it that cheesily

heady sluice
slate swan
warped mirage
#
    client.db = await aiosqlite.connect("warn.db")
    await client.db.execute(
        "CREATE TABLE IF NOT EXISTS warnsystem (guild_id INTEGER, warns INTEGER, id INTEGER)")
    await client.db.commit()   ``` guys would this work for a multi guild system or nah
ashen notch
#

Point taken

#

Yeah hadn't thought of it that way

#

Hmm

slate swan
#

yeah thats what i meant

heady sluice
#

not client

ashen notch
#

Rest of it would be permissions....

warped mirage
heady sluice
#

yo what have we talked about 5 minutes ago

placid skiff
#

Uhm i see that there is an interesting discussion here

heady sluice
warped mirage
#

self , self.client?

ashen notch
#

I guess the only other thing I'll have to figure out is how visible it is and what not for the end user. Anyway, appreciate the help, folks

heady sluice
#
async def setup_db(self):
    self.client.db = await aiosqlite.connect("warn.db")
    await self.client.db.execute(
        "CREATE TABLE IF NOT EXISTS warnsystem (guild_id INTEGER, warns INTEGER, id INTEGER)")
    await self.client.db.commit()   
warped mirage
#

ok now i need to code the commands , will be tricky

heavy shard
warped mirage
#

nah man

#

well ill try

heady sluice
#

never forget self

slate swan
heady sluice
warped mirage
#

do i just start off with commands.command() ?

heady sluice
#

yes

warped mirage
#

alright

slate swan
heady sluice
#

you know what

slate swan
#

i dont

heady sluice
#

I won't even argue

slate swan
#

me too

heady sluice
#

me neither*

slate swan
#

yes that

warped mirage
#

Guys ima try code but if someone is nice can they help me later on

#

Uknow no attitude needed just answer is good enough πŸ‘

terse coyote
#

how to make the bot send a message every 15 minutes?

placid skiff
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with
optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
edgy mantle
#
@bot.slash_command(guild_ids=[923895612745842718], name='host', description='Host an Endurance')
@option("wave", description='The Current Wave')
@option("endingwave", choices=[25,26,27,28,29,30], description="The wave you want your endurnace to end on")
@option("seats", choices=["One", "Two", "Three"], description="The amount of free seats")
@option("zone", choices=["Stonewood", "Plankerton", "Canny Valley", "Twine Peaks"], description="The zone you are hosting in")
@option("epic", description="Your Epic Games username")
@option("description", description="Any other notes you want to tell others about", required=False)
async def bruh(ctx: discord.ApplicationContext, wave: int, endingwave: int, seats: str, zone: str, epic: str, description: str):

Anyone notice anything wrong with this, the options to add wave endingwave ect. are not showing.

rare saddle
#

How to check if the author role is higher than the bot role and if the author is a server administrator?

paper sluice
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

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

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

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

how to get voicechannel id of ctx.author?

shrewd pasture
#

Should work^

#

!d discord.VoiceChannel

unkempt canyonBOT
shrewd pasture
#

Check that for more info

warped mirage
#
@commands.command()
    @commands.has_permissions(ban_members=True)
    async def warn(self, ctx, member : discord.Member)``` can someone help me do my warnsystem
shrewd pasture
#

And are you using cogs?

warped mirage
shrewd pasture
#

Why

#

Do you know how to use cogs?

warped mirage
#
import discord
from discord.ext import commands
import aiosqlite



class warning(commands.Cog):

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

    @commands.Cog.listener()
    async def on_ready(self):
        print('warning.py has been loaded')


async def setup_db(self):
    self.client.db = await aiosqlite.connect("warn.db")
    await self.client.db.execute(
        "CREATE TABLE IF NOT EXISTS warnsystem (guild_id INTEGER, warns INTEGER, id INTEGER)")
    await self.client.db.commit()    

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def warn(self, ctx, member : discord.Member)
    
     


def setup(client):
    client.add_cog(warning(client))``` full code atm
shrewd pasture
#

Uhm

slate swan
#

What’s the error

shrewd pasture
#

Warn is very very easy

#

You didn’t even code in a system yet

warped mirage
shrewd pasture
#

That’s also easy

warped mirage
#

nice

shrewd pasture
#

You need to setup something to store the guild id

#

Then store everything per guild in their specified place in your db

warped mirage
#

and btw it may be easy for u but i also need to add warns , delwarns

shrewd pasture
#

Is this for a big project

#

Where thousands of people will use it

warped mirage
#

yes
thats correct

shrewd pasture
#

Thousands of people will use it per second ?

warped mirage
#

not per second

#

lol but u do need a warn system for a bot , well u dont but i want i guess.

stone beacon
slate swan
#

You don’t need to do all that

#

You can use roles

shrewd pasture
#

Uh what

warped mirage
#

bro im making a multi guild bot

shrewd pasture
#

That’s stupid

warped mirage
#

not a bot just for one server

warped mirage
slate swan
shrewd pasture
#

You’re using roles for a warning system

#

That’s so ugly imo

warped mirage
#

Josh could u help me by any chance or na

shrewd pasture
#

With what

warped mirage
slate swan
stone beacon
#

id's

#

work best

warped mirage
warped mirage
slate swan
stone beacon
#

Bro

shrewd pasture
clear harness
#

CSS

warped mirage
shrewd pasture
stone beacon
#

Although that's really just raw css and html so.

slate swan
warped mirage
#

so can someone first help me with the add warn command

warped mirage
#

im not using it for one server bro

shrewd pasture
#

A simple !history command is far better

#

And cleaner

slate swan
shrewd pasture
#

Aero please stop

warped mirage
shrewd pasture
#

It’s not what you want it’s what he wants

#

Giving suggestions is fine

slate swan
shrewd pasture
#

But he wants to do it differently

warped mirage
#

i mean as long as someone helps me I don’t mind tbf warning system is a warning system

shrewd pasture
#

What database are you using

warped mirage
#

aiosqlite

shrewd pasture
#

Alright well I can’t really help atm

#

I suggest just looking at the forms or example code for it

warped mirage
#

Oh damn ok

slate swan
#

How familiar are you with python? @warped mirage

warped mirage
slate swan
#

Do you know how to get and post to your db ?

warped mirage
#

Sorta , I would need help

halcyon onyx
slate swan
#

unban*

#

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

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

thanks!

slate swan
#

how do i use d.py app commands in cogs

warped mirage
#

Can someone help me with my warning system first a warn command ( aiosqlite )

slate swan
slate swan
warped mirage
slate swan
slate swan
slate swan
slate swan
warped mirage
#

Well I do know some stuff I mean the general warn system itself

slate swan
warped mirage
# slate swan well just a write something like a command named warn - which *inserts*/*updates...
import discord
from discord.ext import commands
import aiosqlite



class warning(commands.Cog):

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

    @commands.Cog.listener()
    async def on_ready(self):
        print('warning.py has been loaded')


async def setup_db(self):
    self.client.db = await aiosqlite.connect("warn.db")
    await self.client.db.execute(
        "CREATE TABLE IF NOT EXISTS warnsystem (guild_id INTEGER, warns INTEGER, id INTEGER)")
    await self.client.db.commit()    

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def warn(self, ctx, member : discord.Member)
    
     


def setup(client):
    client.add_cog(warning(client))``` full code atm idk if some stuff wrong but ye
slate swan
#

and please learn sqlite before asking for help with it

warped mirage
#

I know some but I don’t know all of it lol and I need help with the warn system because it’s not all about db

slate swan
#

what you have to do

  • send a message to the member to be warned
  • update records in the database
#

and capitalize your class lol

warped mirage
#

Lol this is not easy

slate swan
warped mirage
#

Damn no help L ok I’ll just code on my own till it works I guess

slate swan
#

😳 write an algo and make a flowchart for ur dream viewwarn delwarn commands.

warped mirage
#

…..

slate swan
warped mirage
#

Now ur trying to confuse me way more

#

No thx

slate swan
tulip matrix
#

guys do yall know how to start from scratch i have no knowledge with discord bots in python, could i have website recommendations etc?

slate swan
#

It's bot music

#

@tulip matrix

slate swan
tulip matrix
#

so not much experience

slate swan
#

Does she have any experience?

slate swan
# tulip matrix so not much experience

i would recommended learning some basic concepts like

  • builtin functions like len, sort , etc
  • classes
  • an introduction to asyncio ( async/ await syntax at minimum )
  • control flow, loop logics
    since discord.py is a bit complex library to work with
tulip matrix
#

ah ok

#

ty :)

slate swan
#

pleasure, there are many free resources to learn them πŸ˜„ , you can use !resources command to find it

slate swan
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)
warped mirage
#

Just curious .

slate swan
warped mirage
#

Oh ye

#

Mee6 also breaks yt Tos ?

slate swan
#

No, I don't use YouTube

#

Use Spotify and Sound

#

πŸ™‚

warped mirage
#

I use Spotify/distube well not atm

slate swan
#

Now who can help?

#

πŸ™‚

#

show code

slate swan
#

this error

#

self.argv is a list with 0 or 1 elements

#

!e ["1st element"][1]

unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | IndexError: list index out of range
slate swan
#

this is your issue

#

Well what can i do

heavy shard
#

is privet a subclass of commands.Bot ?

#

in this case, the script is expecting command line argument, the bot token

slate swan
warped mirage
#
    @commands.has_permissions(ban_members=True)
    async def warn(self, ctx, member : discord.Member):

     warn = [0]
     cursor = cursor

    async with self.client.db.execute("INSERT INTO warnsystem (guild_id, warns , id, guild) VALUES (?, ?, ?, ?)"("id, warns, guild.id",)) as cursor:
      await self.client.db.commit()``` xd im so bad
slate swan
#

youtube fucked up real great

warped mirage
#

im trying atleast

warped mirage
slate swan
#

why are you passing the parameters in a single string

warped mirage
#

idk what shall i do

heavy shard
warped mirage
slate swan
slate swan
#

though rythm did announce that they had updates coming out this year?

#

Bro idk why the slash commands dont show up nomo

#

and how will we know-

#

yes, im not sure if its about music, but the say they are working on something "cooler"

#

It says that the cogs are loaded but after hours nothing happens

slate swan
slate swan
#

in the commands deco

#

you probably dont have the app_commands scope

#

disnake has no problematic issues rn ( stable branch )

slate swan
slate swan
#

well, that sould raise an exception in that case...

#

^

#

yeah something like "cannot overwrite....in guild....."

slate swan
slate swan
glad cradle
slate swan
#

arent we wasting our time on this convo too, okimii

#

what....

#

pBear i like how this chat is always on fire.

glad cradle
#

😈

slate swan
#

ill go watch naruto anyways

warped mirage
#

Guys ima send my crap code in a sec which will be the most terrifying thing u will see

slate swan
#

@slate swan btw you said it would raise an error if the permission is missing, which payload sends the perms of the bot? so then disnake would parse it and probably check it and raise a exception?

warped mirage
#

⚠️ DISCLAIMER : don’t watch if u hate bad codes

slate swan
#

because as far as i can see READY doesnt send them

glad cradle
#

I use disnake too, and the first time me too haven't activated application.commands scope

slate swan
#

because ive seen users with the issue of them not having the scope on and errors werent getting raised

glad cradle
#

yes

slate swan
#

maybe some endpoint payloads were updated, i doubt it. mayeb disnake didnt parse it? i doubt it as well.

vocal plover
#

try setting the logging level to debug, you should then see the responses from discord on requests, if you're missing a scope it should be 403ing in those responses

glad cradle
#

idk if sync_commands_debug = True will show the problem, maybe it can be helpful

slate swan
vocal plover
#

yes

slate swan
#

why would they document internals?

vocal plover
#

Honestly I stand in the camp of "internals should be documented" because it means that people gain a better understanding of how the library works, not just what it offers, and is good for contributors

#

I would do that for disnake but I'm too burned out to even consider it rn

slate swan
#

thats what im saying, one could just look at the docs and come the conclusion of why the exception was raised instead of digging into the source