#discord-bots

1 messages ยท Page 1073 of 1

placid skiff
loud junco
#

disgrace to my family ;-;

#

btw help

silk fulcrum
#

bruh Xmillion

loud junco
#

how should i write it

#

rpm reload commands.reload right?

#

by any chance not loaded means its still same?

vale wing
#

@loud junco try raising the received exception it might contain useful traceback

#

Yesterday I had this

silk fulcrum
#

glhf

vale wing
#

Now I have this

#

Wtf

slate swan
#

why

loud junco
#

u sponsor

#

then i can use vps

slate swan
#

i mean

#

why u edit on replit

#

not host

loud junco
#

i edit and host on replit

slate swan
slate swan
#

its not loaded

#

so it can reload

loud junco
#

what does that mean

slate swan
#

..

slate swan
vale wing
#

Above

loud junco
#

i dont understand it

slate swan
#

bot.load_extention

loud junco
#

somebody explain the error? ๐Ÿ˜ญ

slate swan
#

listen

loud junco
#

it is loaded

loud junco
loud junco
slate swan
#

How do I make a discord bot?

loud junco
slate swan
#

yes please

loud junco
slate swan
#

thank you

loud junco
#

np

slate swan
#

back

slate swan
slate swan
loud junco
#

?

loud junco
slate swan
#

no

loud junco
#

then?

slate swan
#

uh try changing the folder name

loud junco
#

?

#

why

loud junco
slate swan
#

what does this error mean

slate swan
#

I dont know how to change sorry

loud junco
#

token is None

#

declare token

#
token = #ur token
slate swan
#

I have token = os.getenv("token")

#

let me try different way

#
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "fm" is not found
``` got this error
i have fm command in a cog
loaded the cog, all the other commands in the cog works but not this one
#

it work now

loud junco
#

the @commands.command and bot.load_extension

slate swan
#

oh

#
@client.command()
@commands.is_owner()
async def load(ctx, extension):
  print ('1')
  await client.load_extension(f"cogs.{extension}")
  print(f'loaded {extension}')

@client.command()
@commands.is_owner()
async def unload(ctx, extension):
  client.unload_extension(f"cogs.{extension}")

to load ^

#
    @commands.group()
    @commands.guild_only()
    @commands.has_permissions(ban_members=True)
    async def fm(self, ctx):
        if ctx.invoked_subcommand == None:
            await ctx.send("Please Send A Valid Option. \n `[p]fm on` or `[p]fm off`")

    @fm.command()
    @commands.has_permissions(ban_members=True)
    @commands.guild_only()
    async def on(self, ctx):
        await commands.load_extension("cogs.fmode")
        await ctx.send("Freeloader Mode Enabled")

    @fm.command()
    @commands.has_permissions(ban_members=True)
    @commands.guild_only()
    async def off(self, ctx):
        await commands.unload_extension("cogs.fmode")
``` command in cog
slate swan
loud junco
#

why load like this

#

no idea

slate swan
#

how do i remove the default help command?

slate swan
loud junco
slate swan
#

thx

loud junco
#

i need self.bot

#

๐Ÿคฆ its fixed

paper sluice
slate swan
#

to get my own...

paper sluice
#

subclass the builtin help command

#

^

manic path
#

What would iter(guild.audit_logs(action=action)) return?

slate swan
#

is it possible to make my bot reply to the command author with a message only they can see?

slate swan
#

how would I go about doing that?

hushed galleon
kindred kernel
#

If with dpy, then using interactions

kindred kernel
unkempt canyonBOT
#

class discord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
slate swan
loud junco
slate swan
#

didn't observe that

loud junco
#

lol

slate swan
#

;-;

slate swan
loud junco
#

no

slate swan
#

nextcord

#

for sure

loud junco
#

help me help this? ;-;

slate swan
#

ye its a coro

#

and in ur code its not so

loud junco
#

is it the same with reload_extension

slate swan
#

what

loud junco
#

help me find this @slate swan ;-;

hushed galleon
#

yeah in the latest dpy 2.0 versions

loud junco
#

how to check my version

manic path
#

If reason isn't provided while banning will banentry.reason be None?

loud junco
#

pip version dpy?

#

not working

#

oops mb

#

its 1.7.3 only

slate swan
loud junco
#

๐Ÿ’€

slate swan
loud junco
slate swan
#

huh?

loud junco
#

i can do that?

slate swan
#

ye ig

loud junco
#

how

#

pip install dpy 2.0

#

๐Ÿคฃ

slate swan
#

no lol

#

wait a sec

loud junco
#

ok

slate swan
#
Ignoring exception in command fm on:
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\Jaisman's PC\Desktop\ACLib\bot.py", line 362, in on
    await client.load_extension("cogs.fmode")
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 992, in load_extension
    raise errors.ExtensionNotFound(name)
discord.ext.commands.errors.ExtensionNotFound: Extension 'cogs.fmode' could not be loaded.

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 1614, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ExtensionNotFound: Extension 'cogs.fmode' could not be loaded.
``` got this error ^
#

ye

#
@client.group()
@commands.guild_only()
@commands.has_permissions(ban_members=True)
async def fm(ctx):
  if ctx.invoked_subcommand == None:
    await ctx.send("Please Send A Valid Option. \n `[p]fm on` or `[p]fm off`")

@fm.command()
@commands.has_permissions(ban_members=True)
@commands.guild_only()
async def on(ctx):
  await client.load_extension("cogs.fmode")
  await ctx.send("Freeloader Mode Enabled")

@fm.command()
@commands.has_permissions(ban_members=True)
@commands.guild_only()
async def off(ctx):
  await client.unload_extension("cogs.fmode")
  await ctx.send("Freeloader Mode Disabled!")

code ^

#

k

#
import discord
from discord.ext import commands

class fmode(commands.Cog):
    
    def __init__(self, client):
        self.client = client

        @commands.Cog.listener('on_member_remove')
        async def fm(member):
            await member.ban(reason="User Left While Freeloader Mode Was On.")
            await member.send(f"`Whoops you left {member.guild.name} while they had freeloader mode enabled, now you've been banned permanently. You can appeal this ban in BA server.")
            

async def setup(client):
    await client.add_cog(fmode(client))
#

i have a file named fmode

slate swan
#

oh

#

so what should i use?

#

load_extension("fmode")?

#

now it works

#

cogs.cogs.fmode works

#

How do i fix this?

kindred kernel
#

you need to fill it

slate swan
#
@bot.event
async def on_message(message):
    channel = discord.utils.get(message.guild.channels, name='logs')
    embed = discord.Embed(title = "Message sent", description = message.author, color = message.author.color)
    embed.add_field(name = "The message is", value = message.content)
    embed.add_field(name = "The channel is", value = message.channel)
    embed.set_footer(text = "Coded with ๐Ÿ’› by Caleem1212")
    
    await channel.send(embed = embed)
    slowprint(f"Message sent by: {message.author}\r\nContent: {message.content}\r\nChannel: {message.channel}", 0.2)

@kindred kernel what's wrong with this?

#

i was adding perms to cmds but im confused what perms to add in which cmd can anyone help

kindred kernel
#

try str(message.content) + '.' (this will a dot to original message but at least then it shouldn't give an error)

slate swan
#

ok thanks

dull terrace
#

My bot grew to 100 servers in 8 days, then I got lucky and discord verified it within 20 mins but then discord had a bug where it still didn't have the verified badge or is able to be invited to servers. It's been almost a week now and I haven't heard back from a support email. I've missed really important initial growth for my bot.

Thanks for coming to my TED talk, i will now go cry in a corner.

kindred kernel
#

sed

slate swan
kindred kernel
slate swan
carmine hearth
#

how to make kick command?

kindred kernel
unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.kick "discord.Guild.kick").
kindred kernel
unkempt canyonBOT
#

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

Kicks 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 [`kick_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.kick_members "discord.Permissions.kick_members") permission to do this.
loud junco
#

my bot is online but its doing nothing =.=

slate swan
dull terrace
loud junco
#

jesus

kindred kernel
dull terrace
#

what are the ones you're confused about

kindred kernel
slate swan
carmine hearth
#

await kick(*, reason=None)
and
await kick(user, *, reason=None)
?

dull terrace
#

wait why would you need to define the permissions

slate swan
#

huh?

dull terrace
#

just enable kick members here

#

when you make invite links

slate swan
#

ok u didnt understand

#

like x command can be used with y perms

dull terrace
#

ohhh okay

slate swan
#

ill give x and u tell me y

loud junco
dull terrace
#

i have no idea, i always do that within the function if i need to

dull terrace
#

discord py?

slate swan
#

disnake

slate swan
loud junco
#

no

slate swan
#

uh

loud junco
#

its not doing anything

kindred kernel
slate swan
#

what u added recently

loud junco
#

even i write the wrong command it wont show the error

#

reload and load_extension

slate swan
#

remove it for a sec then try

dull terrace
#

try @commands.has_permissions(administrator=True)

slate swan
#

copy

slate swan
#

ig u didnt understand now too

loud junco
tidal hawk
#

What are the methods for making tracker inviter system, aside from comparing two different invitation lists

carmine hearth
#

@bot.command()
async def kick():
await kick(user, *, reason=None)

#

is this right?

slate swan
#

can someone help me

@bot.event
async def on_message(message):
    channel = discord.utils.get(message.guild.channels, name='logs')
    embed = discord.Embed(title = "Message sent", description = message.author, color = message.author.color)
    embed.add_field(name = "The message is", value = f"{str(message.content)}"or None)
    embed.add_field(name = "The channel is", value = message.channel)
    embed.set_footer(text = "Coded with ๐Ÿ’› by Caleem1212")
    
    await channel.send(embed = embed)
    slowprint(f"Message sent by: {message.author}\r\nContent: {message.content}\r\nChannel: {message.channel}", 0.2)
carmine hearth
slate swan
#

logs sent messages

carmine hearth
#

ok

slate swan
#

and outputs them into the terminal and sends them in discord as an embded

carmine hearth
#

i dont need it

dull terrace
#

found the documentation

#

looks like the permission name will be the discord name but without spaces

slate swan
#

can someone help me?

dull terrace
#

so the permission would be (kick_members=true)

slate swan
#

;-;

#

thats not what i want

dull terrace
dull terrace
loud junco
#

still not working @slate swan

#

๐Ÿ’€ gg the whole bot

slate swan
#

๐Ÿ’€

carmine hearth
#

what do guild kick?

loud junco
#

u

dull terrace
#

lool what are you asking for sparky

slate swan
#

๐Ÿ’€

#

i have writen paragraphs

loud junco
slate swan
#

but u cant understand

loud junco
#

?

dull terrace
#

you keep asking for something that makes it only so that people with kick members permissions can use the command

loud junco
#

whats the problem sparky

dull terrace
#

that's what i just showed you how to do

vale wing
loud junco
#

๐Ÿคฃ

dull terrace
slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

loud junco
#

exenifix help me ;-; my bot is not doing anything

#

its online but ded

slate swan
#

;-;

#

try regenerating token

dull terrace
loud junco
#

ok

loud junco
stone beacon
#

If your bot is online it's clearly not the token

slate swan
#

ye

dull terrace
vale wing
dull terrace
#

if it's not getting to on_ready then your token is wrong

slate swan
loud junco
carmine hearth
vale wing
slate swan
#

bruh

loud junco
slate swan
stone beacon
loud junco
#

alright

vale wing
loud junco
#

still not working

#

legit alive ded bot

carmine hearth
vale wing
#
  • means all args after it are keyword-only
dull terrace
vale wing
#

It's not an arg itself

slate swan
loud junco
slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

stone beacon
vale wing
#

@loud junco print literally any message's content in on_message

loud junco
dull terrace
loud junco
#

its printing it

vale wing
#

Just print the content

slate swan
carmine hearth
#

@bot.has_permissions(administrator=True)
async def kick():
await member.kick(reason=None)

loud junco
carmine hearth
#

is this right?

slate swan
#

no

dull terrace
#

try removing the if return statements for a second and see if that fixes

vale wing
slate swan
#

https://paste.pythondiscord.com/xohohopaxe

I am making so that when there is spam or many messages in chat the bot sends a random pokemon from the list, but it gives me this error
AttributeError: 'Message' object has no attribute 'send'

dull terrace
#

or print stuff between them

slate swan
#

pwease help

slate swan
dull terrace
#

just add random prints in your code until you find where it's messing up, add one at the start of on_message to make sure it's being triggered

slate swan
#

wait let me send teh full one

stone beacon
loud junco
#

but where do i add

stone beacon
#

It's not a command it doesn't take context

loud junco
#

its not even doing anything

stone beacon
#

save yourself the eye and brain hurt

slate swan
vale wing
#

Shame we can't make threads right here

dull terrace
#

after async def on_message(message):

add on the next line print("is this working?")

tough lance
slate swan
slate swan
loud junco
slate swan
#

cool

stone beacon
#

1 - on_message takes in a discord.Message object as the argument, not context. You cannot do message.send() as that's not a thing. You can do message.channel.send() however.

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your botโ€™s own messages and private messages are sent through this event. This can lead cases of โ€˜recursionโ€™ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
dull terrace
#

what do you mean it only works when someone votes for your bot? It is used whenever someone sends a message

slate swan
#

huh

vale wing
slate swan
loud junco
slate swan
#

What is @bot.user_command?
Is it like DM slash commands?

slate swan
stone beacon
vale wing
loud junco
carmine hearth
slate swan
#

๐Ÿ’€

dull terrace
vale wing
#

๐Ÿ˜ฉ

tough lance
#

._.

slate swan
#

@carmine hearth can u show ur whole code

#

@stone beacon that worked thanks

#

lets see

dull terrace
#

this channel is chaos today

slate swan
#

ye

slate swan
carmine hearth
loud junco
#

anyone wanna join my replit multiplayer and fix it?

stone beacon
loud junco
#

im frustrated

slate swan
#

@paper sluice 's alt

#

jk

vale wing
stone beacon
loud junco
slate swan
loud junco
#

mind to help me in replit multiplayer?

slate swan
#

tbh

stone beacon
carmine hearth
stone beacon
#

what is "anything"

vale wing
#

I remember how discord gifted me nitro once it was weird

loud junco
#

everything

loud junco
#

doesnt show error doesnt output doesnt do thing

paper sluice
slate swan
stone beacon
#

well where's the code

unkempt canyonBOT
drifting arrow
#

How do I add an image to an embed? I tried doing set_image but it doesnt work.. embed.set_image(myimage)

slate swan
#

wtf

#

it pinge d me

vale wing
#

Oh yea I know who to beg for nitro

loud junco
dull terrace
#

they have on_message which they say they only use when someone votes, so it's a little confusing what they're trying to do @stone beacon

loud junco
#

if u dont mind

vale wing
slate swan
#

๐Ÿ’€

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
vale wing
#

Elon doesn't know that prolly

loud junco
#

my dude sends his company flying

stone beacon
#

Has to be a https url. If you want to use a local pic well you can easily send it on discord and just use the discord link to the img

carmine hearth
stone beacon
loud junco
#

anyone help me

stone beacon
#

send your problem here

loud junco
slate swan
dull terrace
slate swan
loud junco
stone beacon
#

Can't you just paste the code using !paste

tough lance
#

What's the error?

slate swan
stone beacon
#

and ofc do not show your token..

dull terrace
#

ffs don't show your token to anyone doge_kek

stone beacon
unkempt canyonBOT
#
Did you mean ...

ยป pathlib
ยป relative-path
ยป windows-path

slate swan
#

bruh

stone beacon
#

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

carmine hearth
#

oh

vale wing
#

Imagine not storing your token as github runner secret

slate swan
unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

loud junco
#

lol

carmine hearth
#

!paste

slate swan
#

lol

carmine hearth
#

!paste

tough lance
carmine hearth
#

how

#

to

#

paste?

shrewd apex
#

hello

stone beacon
#

It's right here man

stone beacon
vale wing
#

Imagine creating text file token.txt and writing token straight to there

tough lance
#

Wth is even happening in this channel anymore

stone beacon
slate swan
shrewd apex
#

how did your exam go?

vale wing
#

Anyway this looks cool

stone beacon
#

Haven't begun yet, I gtg at 11

shrewd apex
#

oh gl

stone beacon
#

I just realized it's pretty similar to that JIt thing in India

shrewd apex
#

all the best ๐Ÿ‘

stone beacon
#

Just not as hard fsfs

stone beacon
#

I forgot the name

shrewd apex
#

u mean jee..

stone beacon
#

JIT is eng?

slate swan
#

lol jee

stone beacon
#

ahhh my bad

shrewd apex
#

lmao

slate swan
#

its IIT

carmine hearth
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

Hey! I just got an hoster and when i wanted to start it it said this: See screenshot

In short; It couldnt ping...

How can i fix this?

shrewd apex
#

ah

vale wing
vale wing
#

@carmine hearth

  1. Don't overwrite builtins
  2. Subclass help command (although for such a light one you may just parse name kwarg to deco and name the function differently)
  3. Replit sucks
carmine hearth
loud junco
#

jesus

loud junco
vale wing
#

Point 3

tough lance
dull terrace
#

why do so many use replit ๐Ÿ—ฟ

loud junco
tough lance
#

Cuz of freecodecamp

vale wing
brazen raft
#

discord.Client is not bad if you only need to use events or something

tough lance
loud junco
#

i cant find tutorial with bot =

stone beacon
tough lance
#

Besides there aren't using Bot and naming it client

vale wing
#

Oh hold up at the bottom they use Bot

loud junco
vale wing
#

Why tf use client at all it looks like abstract class

#

Confusing beginners

stone beacon
#

What

vale wing
#

They all just start putting commands into on_message

#

Imho it's better to start from teaching what Bot is

stone beacon
#

Idk how you see client as an abstract class ๐Ÿคฃ but yes it would be more beneficial to learn Bot first especially as newbies like to jump on that command train

dull terrace
vale wing
#

๐Ÿฅฒ

dull terrace
#

does this trigger you froggy_chill

tough lance
#

๐Ÿ’€

loud junco
#

anyone wanna join me and sparky?

tough lance
#

No thanks SubaSip

loud junco
#

in replit multiplayer

vale wing
#

It's not abstract ofc

stone beacon
#

That would be a bit unfair

#

The discord api isn't just for making bots

tough lance
dull terrace
#

it'd be pretty interesting if we had an event where we all worked on a single replit instance to make a random bot

loud junco
stone beacon
#

If you're making a commandless webhook or something you'd simply use a client

#

Or use bot, but it won't matter

stone beacon
vale wing
#

I make API's with aiohttp to use them as webhooks accepters ๐Ÿคฏ

slate swan
#
@commands.command()
    async def trade(self,ctx, arg1, arg2, arg3 = None, arg4 = None, arg5 = None, arg6 = None):
       await ctx.channel.purge(limit=1)
       tradeE = discord.Embed(title=f"{ctx.author.name} is waiting for a trade!", description=f"{ctx.author.mention} Is trading {arg1} for {arg2} \n {arg3} - {arg4} \n {arg5} - {arg6} \n \nAny Trade Scam Done Via This Trade Command Will Not Be Tolerated.",
       color = discord.Colour.random())
       tradeE.set_footer(text="Click The Button Below If You Want To Trade")
       button = Button(label = "Trade", style = discord.ButtonStyle.green, emoji=':Pepe_Business:')
       async def button_callback(interaction):
           await interaction.response.send_message(f"Hey {ctx.author.mention} **{interaction.user.mention}** has accepted your trade!")
           view = View()
           view.add_item(button)
           await ctx.send(embed=tradeE, view=view())
``` no errors in terminal
embed isnt sent
vale wing
#

Holy hell

slate swan
#

wait

vale wing
#

Wtf are those args

loud junco
#

:/

vale wing
#

Just use args list

#
async def cmd(self, ctx, *args)```
loud junco
#

arg1 arg2 arg3 arg4 arg5 arg6 arg7 arg8 arg9 arg10

#

@vale wing u mind helping me?

vale wing
#

And that thing

await ctx.channel.purge(limit=1)

Must be replaced with

await ctx.message.delete()```
vale wing
vale wing
#

Nah I can't help with that I am not on PC

loud junco
#

alright

#

np

vale wing
#

Also switch to normal IDE for god's sake

tough lance
#

What's your issue

vale wing
#

Just install python interpreter and the ide itself

loud junco
tough lance
#

What's the issue

loud junco
vale wing
#

Ye

loud junco
#

huh

#

what ide

vale wing
#

"code editor"

loud junco
slate swan
tough lance
#

Vscode

slate swan
#

Replit is not good

loud junco
slate swan
#

.

vale wing
loud junco
#

fyi i read > 30 times already

slate swan
#

After I sent the interaction for button

vale wing
#

Well then it's not a full command

slate swan
#
@client.command(aliases=['StartSpam'])
async def Spam(ctx, amount=20):
    amount = amount 
    if amount > 500:
        await ctx.send('Cannot Spam more than 500 times at once!')
    if not ctx.author.id == (f'625025751413948436'):
        await ctx.send('Your not Clicks!')
    else:
        for x in (n+0.4 for n in range(20)):
            await ctx.send(f'Spam')``` it says 'Your not Clicks!' on both my main account (Clicks#8882) and my alt account
vale wing
#

Could you use a pasting service

loud junco
#

who is harris

vale wing
#

also my recommendation is to subclass views to implement buttons

slate swan
vale wing
slate swan
#

lol

vale wing
#

I am gonna make a new tutorial anyway

#

The one on my channel is already outdated

slate swan
slate swan
river rain
#

hi there, i'm getting a slight error right now and it's kinda annoying:

when I use the ctx.guild.id variable everything works fine, but as soon as I also use ctx.guild.name in the same event (on_message) I start getting errors saying

AttributeError: 'NoneType' object has no attribute 'name'

any ideas why?

brazen raft
warped mirage
#

With welcome system xd

vale wing
#

For multiple you would need the database and some commands for setting welcome channel

warped mirage
#

Need help doing the set welcome message / deleting it

slate swan
vale wing
#

Then just add welcome_channel_id column to your guilds table and operate with the actual channel IDs, if no welcome message channel is set you could just put NULL into the field

warped mirage
#

Idk how Lmao I tried myself but nothing works ever

vale wing
slate swan
vale wing
#

Also yeah the callback should have self attribute as well

slate swan
#
@commands.command()
    async def trade(self,ctx, arg1, arg2, arg3 = None, arg4 = None, arg5 = None, arg6 = None):
       await ctx.message.delete()
       tradeE = discord.Embed(title=f"{ctx.author.name} is waiting for a trade!", description=f"{ctx.author.mention} Is trading {arg1} for {arg2} \n {arg3} - {arg4} \n {arg5} - {arg6} \n \nAny Trade Scam Done Via This Trade Command Will Not Be Tolerated.",
       color = discord.Colour.random())
       tradeE.set_footer(text="Click The Button Below If You Want To Trade")
       button = Button(label = "Trade", style = discord.ButtonStyle.green, emoji=':Pepe_Business:')
       async def button_callback(interaction):
           await interaction.response.send_message(f"Hey {ctx.author.mention} **{interaction.user.mention}** has accepted your trade!")
           button.callback = button_callback
           view = View()
           view.add_item(button)
           await ctx.send(embed=tradeE, view=view())
vale wing
#

Why are you setting callback inside the callback lmao

#

Here's the correct version (the correct one would be to subclass View, see examples folder on the repo)

embed = ...
view = discord.ui.View()
button = discord.ui.Button(...)
async def callback(self: discord.ui.Button, inter: discord.MessageInteraction):
    ...

button.callback = callback
view.add_item(button)
await ctx.send(embed=embed, view=view)```
slate swan
warped mirage
#

Exefinix do u think u could help me make finish the welcoming off or nah

slate swan
slate swan
# vale wing Here's the ~~correct~~ version (the correct one would be to subclass View, see e...
@client.command(aliases=['StartSpam'])
async def Spam(ctx, amount=20):
    amount = amount 
    if amount > 500:
        await ctx.send('Cannot Spam more than 500 times at once!')
    if ctx.author.id == (f'625025751413948436'):
                for x in (n+0.4 for n in range(20)):
                    await ctx.send(f'Spam')
    else:
        await ctx.send('Your not Clicks!')``` now its sending both "Your not Clicks!" & its spamming, also how do I make it spam the amount I inputed?
terse coyote
#

how to check who pressed button ds_components?

stone beacon
#

Idk that library, but it should have a callback somewhere

stone beacon
stone beacon
#

Playful or not , they know

slate swan
#

me and my friends are doing a challenge

stone beacon
#

Yea so was mine

stone beacon
#

range returns ints not floats

#

why even add

slate swan
#

?

frozen quarry
slate swan
#

how do i make a bot send a message when a button has been pressed 2 times?

shrewd apex
slate swan
#

is there any examples?

manic path
#
-   A member joins a voice or stage channel.
-  A member leaves a voice or stage channel.
-  A  member is muted or deafened by their own accord.
-  A member is muted or deafened by a guild administrator

Beside the mentioned actions above what other things can trigger on_voice_state_update

slate swan
#

hunter's answers do be based

maiden fable
#

Nvm

placid skiff
maiden fable
manic path
#

That makes sense. Thanks.

fading kestrel
#

Iโ€™m trying to create a daily command for my economy bot in discord.py and I want it to reset the daily at 00:00 utc everyday how would I do that?

slate swan
# slate swan is there any examples?
class _(ui.View):
     def __init__(self):
         self.count = 0

     @ui.but...
      async def __(self, button, inter):
          if self.count >= 2:
               return await inter.response.send_message(...)
          self.count += 1
          

i may have messed up the indents

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").
placid skiff
slate swan
#

and the datetime module

fading kestrel
#

Tasks loop?

fading kestrel
#

How would that solve the problem?

#

@placid skiff

placid skiff
#

Bruh click the link to the documentation, it is all written D_D

fading kestrel
#

Ok ok sorry

placid skiff
#

loop creates a function which will be executed every amount of time or in a specific moment of the day

maiden fable
manic path
#

Oh. Thanks! Really apprecieate it

loud junco
slate swan
#

await bot.load_ext....

loud junco
#

but i cant await it outside a function

slate swan
#

then await it inside an async function

loud junco
#

wait... can i do them in on_ready

slate swan
loud junco
#

then how

#

i need to have them loaded once i started the bot

slate swan
placid skiff
#

I think that is time to upload my basic bot setup to github D_D

maiden fable
#

Best of luck

slate swan
# loud junco i need to have them loaded once i started the bot

you have two options, either subclass or run the bot using start

from discord.ext import commands

class MyBot(commands.Bot):
  def __init__(self):
    super().__init_(command_...)
  
  async def setup_hook(self): #this function will be triggered automatically on startup and before any event is dispatched, you DO NOT have to run it explicitly
    await self.load_extension(...)
    await do_more_things_if_required()

or or

import asyncio

async def main():
  async with bot:
    await bot.load_extension(...)
    await bot.start("token") #use this function instead of "bot.run()"

asyncio.run(main())

The second method does not require sub-classing the Bot class and can be used directly instead of simply doing bot.run(), you can create a main function with all your async functions and await bot.start which works the same as bot.run() but recommended to use if in-case bot.run gets deprecated in the future updates

terse coyote
#

how to check who pressed button discord_components?

slate swan
slate swan
warped mirage
#

Hello

#

Asher Good stuff

slate swan
#

Can we have slash command names capitalized and stuff

warped mirage
#

All works now

placid skiff
shrewd apex
#

u can make an async function to load all ur cogs and run the function in async with bot

placid skiff
#

It will be handly for me expecially so maybe i will stop rewriting my setup everytime

warped mirage
#

Hello Asher

shrewd apex
#

hello

warped mirage
#

My bot works now all good

shrewd apex
warped mirage
#

BUT*

#

One more thing left ๐Ÿ˜ข

slate swan
# slate swan NO.

Oh ok but I was actually scared by your message like WHAT WHY CAPS!!!

shrewd apex
#

what?

slate swan
#

oh nvm

#

BTW are you rick ashley?

warped mirage
slate swan
#

that's not funny one bit

shrewd apex
slate swan
slate swan
shrewd apex
#

yeah i saw

slate swan
#

wtf

shrewd apex
#

singer

shrewd apex
slate swan
#

Oh nvm

jagged adder
#

is there a way to call a command from within a function? i have a command that creates a new instance of my 'game', effectively resetting all the variables. i dont know how to call it tho

slate swan
#

How can we get auto complete in slash command's itner?

jagged adder
#

i want to be able to type 'restart' and itll loop back and create a new instance

slate swan
#

Like what is the type hint?

jagged adder
#

how

shrewd apex
#

u can even call a command in another command just do await command_name(*kwargs)

slate swan
jagged adder
#

alr

shrewd apex
#

normally commands in discord just take parameters from users so u just gottad add your own in the code

wet crystal
#

can anyone help me with pytube?

stone beacon
#

I believe not

stone beacon
stone beacon
stone beacon
#

Personally I would not have it

warped mirage
#

I need help developing a set welcome message command

maiden fable
#

@stone beacon how did yr exam go

wispy sequoia
#

quick question
how do I make my bot reply if it gets mentioned?
like, mentioned only
User: @ bot

Bot: why you mentioned me

stone beacon
wet crystal
maiden fable
carmine hearth
#

my code is a peace if shit?

slate swan
stone beacon
stone beacon
stone beacon
stone beacon
carmine hearth
#

is my code is a peace of shit?

#

@stone beacon

slate swan
stone beacon
#

lmao

stone beacon
wet crystal
stone beacon
#

you should enable your intents

warped mirage
#

can someone help me lol

stone beacon
#

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

stone beacon
#

@carmine hearth

warped mirage
placid skiff
carmine hearth
#

f||uck|| this shit i'm out

warped mirage
#

i need a welcome message xd

slate swan
#

how do i make it disable all the buttons in that view when i interact with one button? i tried it this way but it doesnt work```py
button1 = [x for x in self.children if x.custom_id == "decline_trade"][0]

button1.disabled = True```
tawdry perch
slate swan
#

Literally why its not registering this simple command?

class ExtensionCommands:

    @ client.slash_command(name='load', description='Loads an extension, only for the owner.')
    async def load_cmd(inter: disnake.AppCommandInter, extension: str):
        if inter.author.id == 980730313011507220:
            try:
                client.load_extension(f'Extensions/{extension.lower()}')
                await inter.response.send_message('Successfully loaded extension!')
                return
            except:
                await inter.response.send_message('Cannot load extension. The extension does not exist or its already loaded.', ephemeral=True)
                return
        else:
            await inter.response.send_message('Only the bot\'s owner can load or unload extensions.', ephemeral=True)
stone beacon
placid skiff
slate swan
#

Wait... dont say we can't use bot's slash commands in browser?

stone beacon
#

Just iterate over it, type check if the item is a Button with isinstance() and disable it

stone beacon
#

!s_instance

#

!bool

placid skiff
stone beacon
#

how does this thing work again lmao I do not use this bot

slate swan
slate swan
unkempt canyonBOT
#

class bool([x])```
Return a Boolean value, i.e. one of `True` or `False`. *x* is converted using the standard [truth testing procedure](https://docs.python.org/3/library/stdtypes.html#truth). If *x* is false or omitted, this returns `False`; otherwise, it returns `True`. The [`bool`](https://docs.python.org/3/library/functions.html#bool "bool") class is a subclass of [`int`](https://docs.python.org/3/library/functions.html#int "int") (see [Numeric Types โ€” int, float, complex](https://docs.python.org/3/library/stdtypes.html#typesnumeric)). It cannot be subclassed further. Its only instances are `False` and `True` (see [Boolean Values](https://docs.python.org/3/library/stdtypes.html#bltin-boolean-values)).

Changed in version 3.7: *x* is now a positional-only parameter.
tawdry perch
slate swan
#

I am on browser btw

slate swan
carmine hearth
#

ok

slate swan
#

would this work?

    button1 = [x for x in self.children if  x.custom_id == "decline_trade"][0]
    button1 = [x for x in self.children if  x.custom_id == "accept_trade"][0]```
carmine hearth
#

i dont understand this

slate swan
slate swan
#

it will error if no custom_id matches

#

and you index the list

#

!d IndexError

unkempt canyonBOT
#

exception IndexError```
Raised when a sequence subscript is out of range. (Slice indices are silently truncated to fall in the allowed range; if an index is not an integer, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") is raised.)
slate swan
#

im trying to disable both buttons using their custom_id when i react with either button

wet crystal
#

How can I send a custom error into the channel when someone is not filling out arguments on a command?

slate swan
#

wtf why isn't anyone helping me

placid skiff
#

!d discord.ext.commands.MissingRequiredArgument

unkempt canyonBOT
#

exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
slate swan
#

I am sure my code just have a small problem

#
class ExtensionCommands:

    @ client.slash_command(name='load', description='Loads an extension, only for the owner.')
    async def load_cmd(inter: disnake.AppCommandInter, extension: str):
        if inter.author.id == 980730313011507220:
            try:
                client.load_extension(f'Extensions/{extension.lower()}')
                await inter.response.send_message('Successfully loaded extension!')
                return
            except:
                await inter.response.send_message('Cannot load extension. The extension does not exist or its already loaded.', ephemeral=True)
                return
        else:
            await inter.response.send_message('Only the bot\'s owner can load or unload extensions.', ephemeral=True)
#

Help me plsss

#

Its not loading the slash command

maiden fable
#

It takes time for those commands to sync

slate swan
#

Its only 1 server

#

Its not loaded for 2 minutes or so

wet crystal
#

do you have a example

potent spear
potent spear
wet crystal
potent spear
wet crystal
#

I cant remember asking that lo

#

oh yeah that was at 4am while I was on 5 red bulls, remember

slate swan
robust fulcrum
#

from matplotlib import pyplot as plt
import numpy as np

nov = int(input("enter number of values"))
initial = 1
cars = []
while initial<=nov:
	print("enter the value to append")
	apen = input()
	cars.append(apen)
	initial = int(initial+1)

nop = int(input("enter number of values for pie chart"))
initials = 1
data = []
while initials<=nop:
	print("enter the value of pie chart to append")
	apens = int(input())
	data.append(apens)
	initials = int(initials+1)

fig = plt.figure(figsize =(10, 7))

plt.pie(data, labels = cars)
 
plt.savefig("chart.png")

Can anyone help me to covert it to discord command
Which takes input from user

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

Oh my god its finnnnnnnnnnnally registered

magic pond
#
class MyCog(commands.Cog):
  def __init__(self, bot: commands.Bot) -> None:
    self.bot = bot
    
  group = app_commands.Group(name="hyb", description="-")
  
  @app_commands.command(name="test1")
  async def command(self, interaction: discord.Interaction) -> None:
    await interaction.response.send_message("Hello!", ephemeral=True)

  @group.command(name="sub")
  async def test(self, interaction: discord.Interaction) -> None:
    await interaction.response.send_message("Hello!", ephemeral=True)

async def setup(bot: commands.Bot) -> None:
  await bot.add_cog(MyCog(bot))
  print('hybrid')
#

is this correct?

magic pond
#

ohk so need to add server id right

#

the slash cmnds should work in all servers

carmine hearth
#

guys can u watch how much my code is bad?

shrewd apex
#
@bot.command()
async def help(ctx):
  await ctx.send("ะะฐะฟะธัˆะธั‚ะต o!ping ะธ ะฑะพั‚ ะพั‚ะฒะตั‚ะธั‚ pong. ะะฐะฟะธัˆะธั‚ะต o!botping ะธ ะฑะพั‚ ะฟั€ะธัˆั‘ั‚ ัะฒะพะน ะฟะธะฝะณ ะฒ ั†ะธั„ั€ะฐั…(ั ะฝะต ะทะฝะฐัŽ ะทะฐั‡ะตะผ ัั‚ะพ ะฝะพ ัั‚ะพ ั‚ะตัั‚ะพะฒะฐั ั„ัƒะฝะบั†ะธั).")
magic pond
#

is there any other way instead of me addind every server ids in a list ?

shrewd apex
#

dont do this and this is not required def pingg():
return int(bot.latency*1000)

shrewd apex
#

subclass the help command

wet crystal
#

Does anybody know why this appears every time I start my Bot?

DistributionWarning: discord is installed which is incompatible with nextcord. Please remove this library 
by using `pip3 uninstall discord`
  warn(message, DistributionWarning, stacklevel=0)
placid skiff
#

discord and nextcord are incompatible together, so it is suggested to uninstall discord.py

wet crystal
placid skiff
#

you can check by doing pip freeze in your terminal

slate swan
#

I mean, I have all of 'em installed and it works out fine

wet crystal
slate swan
#

no comments

placid skiff
#

it's something related only to nextcord

slate swan
#

weird

placid skiff
#

they added a bit of racisms D_D

frozen flame
#

@client.event
async def on_message(message):
if client.user.mentioned_in(message):
await message.channel.send("what")
I have added this to my code but other commands wouldnt work

wet crystal
slate swan
slate swan
wet crystal
slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

wet crystal
#

yep

#

didnt know that was a thing

placid skiff
slate swan
#

also, client.user.mentioned_in = bad

wet crystal
placid skiff
#

I'm offended now pepe_sad

slate swan
placid skiff
slate swan
#

dont uninstall it manually

frozen flame
slate swan
#

you probably have multiple versions of python installed

placid skiff
wet crystal
slate swan
wet crystal
frozen flame
slate swan
slate swan
placid skiff
slate swan
placid skiff
#

Honestly Freyln it could be everything

wet crystal
#

lol

placid skiff
#

you could using a venv or smth

placid skiff
#

we can't know it D_D

wet crystal
slate swan
#

and yes, venvs are really handy uou should be using them

#

!venv

unkempt canyonBOT
#

Virtual Environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

slate swan
#

tbh thats one of the dumbest cases of how to upvote your library lol

placid skiff
#

Once you will start work you will understand how useful venvs are D_D

slate swan
#

ew

placid skiff
slate swan
#

....?

#

though pipenv works better

#

i don't think everyone would be comfortable with conda, while venvs is something any general python user would use

frozen flame
#
@ban.error
async def ban_error(error, ctx):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("cant ban the air...")
    if isinstance(error, commands.UserNotFound):
        await ctx.send("user not found")

this doesnt work

#

idk why tho

placid skiff
#

it seems all good, but first of all change the second if into an elif

frozen flame
#

yea but still wouldve worked

wet crystal
#

how do I use @command.error with multiple arguments?

placid skiff
#

then add an else and write this:

else:
  print(f"Ignoring exception in command: {ctx.command}", file=sys.stderr)
  traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)

Then look if there is some error in the console

#

You will need to import sys and trackeback

placid skiff
shrewd apex
wet crystal
placid skiff
placid skiff
#

in that case is useless because is an handler for a single command but in on_error event is more usefull

placid skiff
placid skiff
shrewd apex
wet crystal
# placid skiff wdym?

lets say the first arg was found and is valid but the second is missing, how can I handle that?

placid skiff
unkempt canyonBOT
#

exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
placid skiff
#

The arguments that are missing are stored in this class, which is your error

shrewd apex
#

something similar ur intellisensor or linter comes to play here

wet crystal
placid skiff
#

you see that it takes a param as argument?

warped mirage
#

Hey'

placid skiff
#

it is passed automatically when the error is raised

wet crystal
warped mirage
#

i need help making welcome messages lol

placid skiff
#

in your error handler you can do error.param and get that parameter

warped mirage
#

@shrewd apex

shrewd apex
#

?

warped mirage
#
@commands.command()
    async def set_msg(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT welcome TEXT FROM wm where guild_id = ?", (ctx.guild.id, ctx.channel.id,))
            data = await cursor.fetchone()

            if data is None:
                await cursor.execute("INSERT INTO wm(guild_id, channel_id, welcome TEXT) VALUES(?,?,?)", (ctx.guild.id, ctx.channel.id))
                await db.commit()
                await ctx.send(f"Welcome message has been set!")
                return
            
            if data is not None:
                await cursor.execute("SELECT welcome TEXT FROM wm WHERE guild_id = ?", (ctx.guild.id,))
                data3 = await cursor.fetchone()
                result = data3[0]
                await ctx.send("There is no welcome message currently set.", delete_after = 10)
                return``` i just coded this , do u think it will work
shrewd apex
#

dont u need to insert 3 values?

warped mirage
#

oh ye

shrewd apex
#

data3 = await cursor.fetchone()
result = data3[0]
why fetch again u already have fetched it

warped mirage
#

shall i delete it

shrewd apex
#

if not data is more pythonic and u can just do return await ctx.send()

warped mirage
shrewd apex
#

this line is not required since prev if statement prevents this situation already

warped mirage
#

so what do i remove again

#
  
    @commands.command()
    async def set_msg(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT welcome TEXT FROM wm where guild_id = ?", (ctx.guild.id, ctx.channel.id,))
            data = await cursor.fetchone()

            if data is None:
                await cursor.execute("INSERT INTO wm(guild_id, channel_id, welcome TEXT) VALUES(?,?,?)", (ctx.guild.id, ctx.channel.id))
                await db.commit()
                await ctx.send(f"Welcome message has been set!")
                return
            
            if data is not None:
                await cursor.execute("SELECT welcome TEXT FROM wm WHERE guild_id = ?", (ctx.guild.id,))
                await ctx.send("There is no welcome message currently set.", delete_after = 10)
                return
``` current code
shrewd apex
warped mirage
#

i just put ctx.welcome

shrewd apex
#
@commands.command()
    async def set_msg(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT welcome TEXT FROM wm where guild_id = ?", ctx.guild.id)
            data = await cursor.fetchone()

            if not data:
                await cursor.execute("INSERT INTO wm(guild_id, channel_id, welcome TEXT) VALUES(?,?,?)", ctx.guild.id, ctx.channel.id, 'xyz')
                await db.commit()
                return await ctx.send(f"Welcome message has been set!")
           msg = await cursor.execute("SELECT welcome TEXT FROM wm WHERE guild_id = ?", ctx.guild.id)
           mesg = await cursor.fetchone()
           if not mesg: return await ctx.send("There is no welcome message currently set.", delete_after = 10)
           return await ctx.send(f"welcome message is {mesg}")
shrewd apex
heady sluice
carmine hearth
#

guuuuuuuuuuuuys

shrewd apex
#

checks if the new msg or the current message is empty or not

warped mirage
#

i have indent errors thats why im curious

shrewd apex
#

basically i just refined what u wrote

#

i wouldnt do it this way myself...

warped mirage
#

is this good?

shrewd apex
#

remove the msg =

#

that was wrong on my part its not required

carmine hearth
#

i want to die:(

shrewd apex
carmine hearth
#

nope

slate swan
unkempt canyonBOT
warped mirage
shrewd apex
#

yeah

warped mirage
#

K

#
   @commands.Cog.listener()
    async def on_member_join(self, member):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (member.guild.id,))
            data = await cursor.fetchone()
            if data is None:
                return
            else: 
                if data is not None:
                    await cursor.execute("SELECT channel_id FROM wm WHERE guild_id = ?", (member.guild.id,))
                    channel_id = await cursor.fetchone()
                    channel = channel_id[0] 
                    final = self.client.get_channel(channel)
                    await final.send("Welcomes activated!")

                else:
                    return```btw anything here i gotta change
#

or am i good here .

wet crystal
#

Is it possible to add a Dismiss this message button like Clyde has?

warped mirage
#

make ur command ephemeral

warped mirage
# shrewd apex yeah
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: no such column: welcome``` next error
warped mirage
#

hmm ok

shrewd apex
#

u havent created the table properly or using the wrong column name

warped mirage
#
await cursor.execute("CREATE TABLE IF NOT EXISTS wm(guild_id INTEGER, channel_id INTEGER, welcome TEXT, leave TEXT)")```
#

idk

torn sail
#

Change the sessions.get line so itโ€™s not a one liner

#

I think that would work

warped mirage
#
await cursor.execute("CREATE TABLE IF NOT EXISTS wm(guild_id INTEGER, channel_id INTEGER, welcome TEXT, leave TEXT)")``` any ideas
torn sail
#
# instead of this
UKTIME = await sessions.get("https://worldtimeapi.org/api/timezone/Europe/London").json()
# change it to this
resp = await sessions.get("https://worldtimeapi.org/api/timezone/Europe/London")
UKTIME = await resp.json()
# or even better
async with sessions.get("https://worldtimeapi.org/api/timezone/Europe/London") as resp:
    UKTIME = await resp.json()
warped mirage
#

nah it wasnt created

torn sail
#

Yeah you need to change it to what I showed

#

Because both .json() and get() are coroutines but u are only awaiting one of them

shrewd apex
shrewd apex
#

nah i need to go to sleep soon and my heads not working very well rn

slate swan
#

I was testing my dropdown menu and got this error

#

by looking at it i deduced that it is connected to this callback class but i don't know the issue

warped mirage
slate swan
#

here is the callback class

#
async def callback(self, interaction: disnake.MessageInteraction):
      x = self.values[0]
      x = x - 1
      user_id = id_many[i]
      user : discord.user
      for ban_entry in banned_users:
       user = ban_entry.user
       if user_id == user.id:
        return
      await ctx.guild.unban(user)
#

I am using disnake

shrewd apex
slate swan
#

yes

#

I fixed ctx part and still got same error

shrewd apex
#

yeah interactions dont have ctx

#

u have to use interactions.response

glad cradle
slate swan
warped mirage
#

@shrewd apex do u know any typescript support servers ?

#

Like related to this sort of

slate swan
wet crystal
#

How can I make a Interaction on a command which deletes the message?

slate swan
#

huh?

#

I wanna make a horse race discord command. How do i give each of the 6 horses a position, which ofc cant have duplicates?

#

!random.sample

#

!d random.sample

unkempt canyonBOT
#

random.sample(population, k, *, counts=None)```
Return a *k* length list of unique elements chosen from the population sequence or set. Used for random sampling without replacement.

Returns a new list containing elements from the population while leaving the original population unchanged. The resulting list is in selection order so that all sub-slices will also be valid random samples. This allows raffle winners (the sample) to be partitioned into grand prize and second place winners (the subslices).

Members of the population need not be [hashable](https://docs.python.org/3/glossary.html#term-hashable) or unique. If the population contains repeats, then each occurrence is a possible selection in the sample.
slate swan
#

!e

from random import sample
c = [1, 2, 3, 4, 5, 6, 8, 7, 10, 11, 9, 0]
print(sample(c, k=6))```
unkempt canyonBOT
#

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

[6, 7, 10, 8, 9, 5]
heady sluice
#

do you get different results if you do it again

#

is it random

slate swan
#

yeah, it says unique

heady sluice
#

interesting

slate swan
#

!e

from random import sample
c = [1, 2, 3, 4, 5, 6, 8, 7, 10, 11, 9, 0]
print(sample(c, k=6))โ€Š
unkempt canyonBOT
#

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

[0, 7, 8, 6, 5, 3]
slate swan
#

^

#

its just random.choices but with unique elements

#

values*

warped mirage
slate swan
flint isle
#

where do you guys reccomend that i store my bots custom status that changes randomly?

shrewd apex
terse coyote
#

button can use all members... how to fix? I want the button to be used only by people with the role roleforum or rolecur

shrewd apex
#

if the callback is in a command or just pass the user as a parameter

warped mirage
#

guys

#
import discord
from discord.ext import commands, tasks
import asyncio
from config import token


intents = discord.Intents.default()
intents.members = True
intents.presences = True
intents.messages = True
client = commands.Bot(command_prefix = '+', intents=intents)


@client.event
async def on_ready():
    print("HEHE IM READY")


@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        embed = discord.Embed(
            title="You're on a cooldown!", color=discord.Color.blue())

        cd = round(error.retry_after)
        hours = str(cd // 3600)
        minutes = str(cd % 60)

        embed.add_field(
            name="\u200b",
            value=
            f"you cant use dailyspin again\n Wait for `{hours} hours {minutes} minutes`"
        )
        await ctx.send(embed=embed)
    else:
        raise error

async def main():
    async with client:
       await client.load_extension('cogs.rewards')
       await client.start(token)                                                                                  
       print(client.db)
asyncio.run(main())``` anything wrong here ? i have a cog also but the command doesnt respond
flint isle
#

whats the cogs code

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

class rewards(commands.Cog):

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

print("hello")

@commands.command()
@commands.cooldown(1, 86400, commands.BucketType.user)
async def dailyspin(ctx):
    responses = ['100 million coins',
                '10 packs of choice',
                '50 million coins',
                'nothing',
                '1 billion coins',
                '5 packs',
                '5 modded packs',
                '15 packs',
                '1 coin',
                '55 coins',
                '12 million coins']
        
    response = random.choice(responses)
    embed=discord.Embed(title="Daily Spins!", color=0xff0000) 
    embed.add_field(name='You Won: ', value=f'{response}', inline=False)
    embed.add_field(name='How to claim?: ', value=f'Create a ticket', inline=True)
    await ctx.send(embed=embed)



async def setup(client):
    await client.add_cog(rewards(client))```
flint isle
#

indent the command

warped mirage
#
 raise TypeError(f'Command signature requires at least {required_params - 1} parameter(s)')
TypeError: Command signature requires at least 1 parameter(s)``` @flint isle what about this
flint isle
#

did you indent everything in the command

#

and you need self, ctx

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

class rewards(commands.Cog):

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

    @commands.command()
    @commands.cooldown(1, 86400, commands.BucketType.user)
    async def dailyspin(ctx):
        responses = ['100 million coins',
                '10 packs of choice',
                '50 million coins',
                'nothing',
                '1 billion coins',
                '5 packs',
                '5 modded packs',
                '15 packs',
                '1 coin',
                '55 coins',
                '12 million coins']
        
        response = random.choice(responses)
        embed=discord.Embed(title="Daily Spins!", color=0xff0000) 
        embed.add_field(name='You Won: ', value=f'{response}', inline=False)
        embed.add_field(name='How to claim?: ', value=f'Create a ticket', inline=True)
        await ctx.send(embed=embed)



async def setup(client):
    await client.add_cog(rewards(client))``` i think so
flint isle
#

since its in a cog

warped mirage
#

ok'

warped mirage
flint isle
#

... 1 sec

swift axle
#

Hey, so I made a new cog file called "chatbot.py", here's the code :

import discord
from discord.ext import commands

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

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

    @commands.command()
    async def chatbot(self,ctx):
        await ctx.send("test")

I made a similar base structure for my other codes. I've a command that load up commands from cogs by loading + the name of the cog. Example :
v.load mod load the mod.py file commands. So I tried to load this new cog, but for some reasons everything I tried return me this : Extension 'chatbox' could not be loaded.
Do you guys know why this file cannot be loaded ?

flint isle
#

@warped mirage you need self, ctx

slate swan
warped mirage
slate swan
#

errors?

warped mirage
#

nope

flint isle
#
    async def dailyspin(self, ctx):
warped mirage
#

yes i have that

flint isle
#

when i added self it worked fine for me

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

class rewards(commands.Cog):

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

    @commands.command()
    @commands.cooldown(1, 86400, commands.BucketType.user)
    async def dailyspin(self, ctx):
        responses = ['100 million coins',
                '10 packs of choice',
                '50 million coins',
                'nothing',
                '1 billion coins',
                '5 packs',
                '5 modded packs',
                '15 packs',
                '1 coin',
                '55 coins',
                '12 million coins']
        
        response = random.choice(responses)
        embed=discord.Embed(title="Daily Spins!", color=0xff0000) 
        embed.add_field(name='You Won: ', value=f'{response}', inline=False)
        embed.add_field(name='How to claim?: ', value=f'Create a ticket', inline=True)
        await ctx.send(embed=embed)



async def setup(client):
    await client.add_cog(rewards(client))``` hmm is this correct?
slate swan
#

@warped mirage do you have an error handler?

flint isle
#

    @commands.command()
    @commands.cooldown(1, 86400, commands.BucketType.user)
    async def dailyspin(self, ctx):
        responses = ['100 million coins',
                     '10 packs of choice',
                     '50 million coins',
                     'nothing',
                     '1 billion coins',
                     '5 packs',
                     '5 modded packs',
                     '15 packs',
                     '1 coin',
                     '55 coins',
                     '12 million coins']

        response = random.choice(responses)
        embed = discord.Embed(title="Daily Spins!", color=0xff0000)
        embed.add_field(name='You Won: ', value=f'{response}', inline=False)
        embed.add_field(name='How to claim?: ', value=f'Create a ticket', inline=True)
        await ctx.send(embed=embed)
``` that worked for me
warped mirage
#
import discord
from discord.ext import commands, tasks
import asyncio
from config import token


intents = discord.Intents.default()
intents.members = True
intents.presences = True
intents.messages = True
client = commands.Bot(command_prefix = '+', intents=intents)


@client.event
async def on_ready():
    print("HEHE IM READY")


@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        embed = discord.Embed(
            title="You're on a cooldown!", color=discord.Color.blue())

        cd = round(error.retry_after)
        hours = str(cd // 3600)
        minutes = str(cd % 60)

        embed.add_field(
            name="\u200b",
            value=
            f"you cant use dailyspin again\n Wait for `{hours} hours {minutes} minutes`"
        )
        await ctx.send(embed=embed)
    else:
        raise error

async def main():
    async with client:
       await client.load_extension('cogs.rewards')
       await client.start(token)                                                                                  
       print(client.db)
asyncio.run(main())``` is this correct?
#

it must be something

swift axle
#

Or I did it wrong ?

#
import discord
from discord.ext import commands

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

    @commands.command()
    async def chatbot(self,ctx):
        await ctx.send("test")

def setup(bot):
    bot.add_cog(ChatboxIA(bot))
warped mirage
#
import discord
from discord.ext import commands, tasks
import asyncio
from config import token


intents = discord.Intents.default()
intents.members = True
intents.presences = True
intents.messages = True
client = commands.Bot(command_prefix = '+', intents=intents)


@client.event
async def on_ready():
    print("HEHE IM READY")


@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        embed = discord.Embed(
            title="You're on a cooldown!", color=discord.Color.blue())

        cd = round(error.retry_after)
        hours = str(cd // 3600)
        minutes = str(cd % 60)

        embed.add_field(
            name="\u200b",
            value=
            f"you cant use dailyspin again\n Wait for `{hours} hours {minutes} minutes`"
        )
        await ctx.send(embed=embed)
    else:
        raise error

async def main():
    async with client:
       await client.load_extension('cogs.rewards')
       await client.start(token)                                                                                  
       print(client.db)
asyncio.run(main())``` @flint isle is this correct
flint isle
flint isle
#

    @commands.Cog.listener()
    async def on_ready(self):
        print('Cog Loaded')
#

insert that same indention as the command and then re run your code and look for cog loaded in the terminal

flint isle
#

good

#

wait what ide are you using?