#discord-bots

1 messages Β· Page 22 of 1

slate swan
#

I'd just use a check instead tbh

unkempt canyonBOT
#

Hey @still swan!

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

still swan
#

...

slate swan
#

!paste please use this for long code

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.

#

Hey @still swan!

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

still swan
#

how..

slate swan
#

just open the link, paste the code, save it, copy the url, and send it here

still swan
#

but the error is:

TypeError: unsupported type annotation <class 'bot.converters.Member'>

The above exception was the direct cause of the following exception:
discord.ext.commands.errors.ExtensionFailed: Extension 'bot.exts.moderation.verification_cog' raised an error: TypeError: unsupported type annotation <class 'bot.converters.Member'>
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000013162EEE280>

then the bot is closed: RuntimeError: Event loop is closed
west veldt
#

um tbh it was a fun command thingy like i text like -bam
and it says user#0000 has been banned

#

is it possible?

still swan
#

also that

west veldt
slate swan
still swan
slate swan
#

if yes, custom converters can't be used, atleast this way

still swan
slate swan
#

yeah then converters won't work

still swan
#

oh

still swan
slate swan
#

just use the converter inside the command function

still swan
# west veldt in embed..
@bot.command()
async def bam(ctx, Member: discord.Member):
  await ctx.send(embed=discord.Embed(description=f"{ctx.author} has been banned"))
short relic
#
from http import client
import discord
from discord.ui import Button
from discord.ext import commands
from discord.components import *



bot = commands.Bot(command_prefix="=")
@bot.event
async def on_ready():
    print("Ready to use!")
    await bot.change_presence(activity = discord.Activity(type = discord.ActivityType.playing, name = "Buy stuffs at Magic Shop" ))
    DiscordComponents(client)

@bot.command()
async def buy(ctx):
    await ctx.send(
        "Choose your order",
        components = [
            Button(style=1, label="Hello")
        ]
    )
#

can someone help the button didnt work ofr me

west veldt
#

i was trying to make a fun command thingy like i text like -bam
and it says user#0000 has been banned

#

but it not working somehow

#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='-', intents=discord.Intents.default())

@bot.command()
async def bam(ctx, Member: discord.Member):
  await ctx.send(embed=discord.Embed(description=f"{ctx.member} has been banned" , color="7289DA"))```
#

this my code

sick birch
west veldt
#

-bam @user

slate swan
west veldt
#

then no responce

west veldt
slate swan
#

wait

#

do you want it to actually ban the user mentioned?

short relic
#
from http import client
import discord
from discord.ui import Button
from discord.ext import commands
from discord.components import *



bot = commands.Bot(command_prefix="=")
@bot.event
async def on_ready():
    print("Ready to use!")
    await bot.change_presence(activity = discord.Activity(type = discord.ActivityType.playing, name = "Buy stuffs at Magic Shop" ))
    DiscordComponents(client)

@bot.command()
async def buy(ctx):
    await ctx.send(
        "Choose your order",
        components = [
            Button(style=1, label="Hello")
        ]
    )

is this the correct code to create button? or am i wrong in some parts

slate swan
west veldt
slate swan
west veldt
slate swan
#

that looks like a response to me

west veldt
#

it was like this when i had ctx.auther instead of ctx.member

#

and that colour thing

slate swan
#

oh

west veldt
slate swan
#

What's your code

west veldt
# slate swan What's your code
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='-', intents=discord.Intents.default())

@bot.command()
async def bam(ctx, Member: discord.Member):
  await ctx.send(embed=discord.Embed(description=f"{member.name} has been banned" , color="7289DA"))```
#

here

slate swan
#

check your terminal for errors, you can't expect someone else to read your code and predict errors

slate swan
#

Member: discord.Member
here you define Member as uppercase and refer to it in your code as member without capitalization. if you checked the terminal, you would have seen an error telling you that member is not defined

west veldt
#

discord.ext.commands.errors.MissingRequiredArgument: Member is a required argument that is missing.

slate swan
#

how are you invoking the command?

#
@bot.command()
async def bam(ctx, member: discord.Member) -> None:
  await ctx.send(embed=discord.Embed(description=f"{member.mention} has been banned", color=0))

@west veldt

sick birch
#

Member should be lower case

#

Follow proper naming conventions

#

Also let's not spoonfeed please

slate swan
#

why should it be lower case

#

snake_case naming conventions?

sick birch
#

Python variables need to be snake_case

slate swan
#

what is that

sick birch
#

lowercase your variables, and use underscores instead of spaces

#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

slate swan
#

Oh

#

only class aliases should have UpperWord lol

#

my fault

#

not instances

sick birch
#

and occasionally SCREAMING_SNAKE_CASE for constants

slate swan
sick birch
#

(though I don't think there's an official spec for it)

slate swan
#

isnt it UPPERCASE_WORD or something like that

#

that's screaming snake case, yes

sick birch
#

Usually referred to as screaming snake case

short relic
#

Traceback (most recent call last):
File "c:\Users\ADMIN\Desktop\bot momento\magic bot conf.py", line 4, in <module>
import discord
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_init_.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 38, in <module>
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\state.py", line 36, in <module>
from . import utils, compat
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\compat.py", line 32
create_task = asyncio.async
^^^^^
SyntaxError: invalid syntax

#

what is this error

slate swan
#

Is it 100% necessary to upgrade pip when there is a new version?

slate swan
#

python -m pip install -U https://github.com/Rapptz/discord.py
why's this not unpacking

#

the other time i updated my pip it brokeπŸ˜” pithink

slate swan
slate swan
slate swan
#

"forgot"

#

yes when forget means something other than forget

short relic
#

i didnt know what i do but like

slate swan
#

😭

short relic
#

every single script i execute i got that error

#

how do i fix

slate swan
#

man asyncio.async is not a thing, please explain what you're trying to do. i find it hard to believe that you are writing python aimlessly

short relic
slate swan
#

oh nvm i just re-read your code, i think you're looking for this:

#

!d asyncio.create_task

unkempt canyonBOT
#

asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.

If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").

The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
short relic
#

uhh

#

maybe ill just try reinstalling the app 😒

slate swan
slate swan
#

? this just got real confusing real fast

#

Does anyone know bots like restcord or letoa

#

Would it be hard to make one

short relic
short relic
#

i executed my script then i go to the error output

#

i hover to the directory and found it

slate swan
slate swan
#

just re-install discord.py with pip or whatever package manager you use

gaunt mortar
#

Hello, is it possible to modify the amount of time you have to interact with a button ?

short relic
#

Maybe ill have to uninstall all

#

@slate swan btw can you guide me how to make buttons in discord python

slate swan
slate swan
slate swan
short relic
#

Thanks for the help though

#

Appreciate it

slate swan
#

πŸ‘

slate swan
slate swan
slate swan
#

you can always interact with a button unless its disabled

#

Is there role:discord.Role parameter in v2?

slate swan
slate swan
#

desc = f'{role.mention}\n\n**Users:** **({len(role.members)})**\n'

#

on role.mention and len(role.members)

#

can you show more code? we don't know what role is being defined as or whether its value is changing

#

why to show more code since i have errors only on that line?

#

what are the errors then?

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'mention'

slate swan
#

it's likely you're doing something like this:

@commands.command(...)
async def foo(role: discord.Role):
    ...

This is wrong, ctx needs to be the first element. You may also be missing self as a parameter.

#

man i can't help you if you don't let me.

#

dude

#

i just forgot to add self parameter

#

im smart πŸ‘

#

ok cool

#

your issue is resolved then?

#

yes

slate swan
#

In v2 , how can i put the buttons one below the other?

silk fulcrum
#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.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.
silk fulcrum
#

there is a row argument

#

so you put row=0 for one button and row=1 for the second

#

and the second will be below

#

@slate swan

slate swan
#

thanks

#

@silk fulcrum can i put a button inline with the button which is row=1?

silk fulcrum
slate swan
#

like this

slate swan
silk fulcrum
#

rows are rows

#

0th row is above 1st row

#

2nd row is below 1st row

silk fulcrum
# slate swan

@button(..., row=0)
@button(..., row=0)
@button(..., row=0)

@button(..., row=1)
@button(..., row=1)
@button(..., row=1)

slate swan
#

multiple => 5 to be a exact

silk fulcrum
#

not more than 5 x 5

#

that is sed cus I wanted a nice minesweeper

slate swan
#

yes, 5 rows with 5 components
a selectmenu is considered to be a complete row itself

silk fulcrum
slate swan
silk fulcrum
slate swan
#

Um whjy not

silk fulcrum
#

cus I wrote this when I was complete noob, I dont remember but I think it can be about 5000000 lines

slate swan
#

bro what

silk fulcrum
#

that's why im rewriting that bot

slate swan
#

what's the logic

#

not more than 100 lines ( without autoformat )

silk fulcrum
#
  • 211 for other games - 14 for imports - 26 for cog stuff
#

!e print(468-211-14-26)

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

217
silk fulcrum
slate swan
#

well idk, can wrap it up into that + depends on library

silk fulcrum
#

oh wait I forgot one game

#

it's - 284

dull terrace
#

is there any way i could get python to do something any time an exception happens in any part of my code?

silk fulcrum
#

217 - 73 = 144

dull terrace
#

i want to make the bot dm me when an exception happens

slate swan
slate swan
#

that

#

flushed_orange my bot.py is more than 400 lines for some reason

dull terrace
slate swan
#

!d discord.Client.on_error

unkempt canyonBOT
#

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

The default error handler provided by the client.

By default this logs to the library logger however it could be overridden to have a different implementation. Check [`on_error()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_error "discord.on_error") for more details.

Changed in version 2.0: `event_method` parameter is now positional-only and instead of writing to `sys.stderr` it logs instead.
sick panther
#

Hi, how can I get the message object of an interaction?

slate swan
#

an interaction is not a message?

slate swan
#

it just wraps the default bot class

silk fulcrum
#

yes

dull terrace
sick birch
#

I don't think there's a central place to catch all errors

dull terrace
#

wouldn't there be some way with logging or something

silk fulcrum
silk fulcrum
slate swan
dull terrace
#

hmmm

slate swan
#

did you guys know that you can attach an else statement in a for loop?😳

silk fulcrum
#

@vale wing did u give nerd bot to anyone?

sick birch
#

You can also attach it to a try/except

slate swan
dull terrace
#

yeah works for while as well

slate swan
unkempt canyonBOT
silk fulcrum
slate swan
#

😳

sick birch
#

Not necessarily cursed, it's pretty handy

slate swan
#

you can do that even with try - except

#

i never knew it until like 4 days ago lol

dull terrace
#

i've only ever needed to use for else once in like 15k lines of code

silk fulcrum
slate swan
#

same, for the for loop

#

shhhhhhh

#

πŸ™‚

#

okimii in chat 😳

silk fulcrum
#

gahh, PEP8

slate swan
#

what about it

slate swan
slate swan
silk fulcrum
slate swan
#

i only follow pep9001😳

vale wing
vale wing
#

Especially inverted indents

slate swan
#

yup

silk fulcrum
vale wing
#

Um, actually, "um, actually" is better than "uh, but"

silk fulcrum
vale wing
#

Ok

silk fulcrum
#

well maybe he just wanted to be a nerd πŸ€“

crystal glen
#

is there a way to send commands thru the console?

vale wing
#

Why the hell does this occur even though I have dm messages intent disabled

vale wing
crystal glen
#

I just wanna use the console to use commands

vale wing
#

Like commands your bot already has or what

crystal glen
#

yes

#

the commands my bot have

vale wing
#

How are you going to parse context to there

crystal glen
#

idk thats why im asking

#

can I make me and my bot's DMs a console?

vale wing
#

That's for sure

crystal glen
#

How?

vale wing
#

Just make some DM commands or listen to on_message for messages in your DMs idk how you want to implement it

crystal glen
#

Alright I will try

dull terrace
silk fulcrum
dull terrace
silk fulcrum
#

ookay

#

im stupid

crystal glen
#
@client.command()
async def dm(ctx, member: discord.Member, *, message):
    if isinstance(discord.channel.DMChannel):
        await member.send(message)
        await ctx.send(f"{ctx.author.mention} I have sent a message to {member.mention}")
#

discord.errors.Forbidden: 403 Forbidden (error code: 50003): Cannot execute action on a DM channel

#

I want to use commands in DMs

silk fulcrum
#
  • what is if isinstance(discord.channel.DMChannel), that is not even a thing, look at docs
  • The member u are trying to dm has closed DMs or blocked the bot
crystal glen
slate swan
#

well that's a thing but that's not how you use instance

#

*isinstance

crystal glen
#

and no the member hasn't blocked the bot

crystal glen
silk fulcrum
#

there is no discord.channel how didn't it give an error though

crystal glen
#

idk

slate swan
silk fulcrum
#

but you use discord.channel

slate swan
#

I.e. discord.channel.DMChannel

silk fulcrum
#

that is not correct even like that

#

it would be channels.DMChannel then

crystal glen
#

What do I do now?

slate swan
#

!d discord.channel.DMChannel

unkempt canyonBOT
#

class discord.DMChannel```
Represents a Discord direct message channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns a string representation of the channel
silk fulcrum
#

WOAHT?

slate swan
#

so ig its channel, not channels

silk fulcrum
#

ohmygosh im so dumb

crystal glen
#

WHAT DO I DO

slate swan
#

rewrite the code yourself

crystal glen
#

I can't...

slate swan
#

instead of googling it

crystal glen
#

just tell me what to do..

silk fulcrum
#

he just did

crystal glen
#

discord.errors.Forbidden: 403 Forbidden (error code: 50003): Cannot execute action on a DM channel wtf is this error?

silk fulcrum
#

access denied

crystal glen
#

WHAT DO I DO THEN

silk fulcrum
#

pray that the member you are trying to send message to will unblock the bot if he blocked it or open his DM's if they're closed

tough lance
#

Like not allowing DMs from server members

silk fulcrum
#

Bruh, I want to use a buttons paginator, I was thinking for design and remembered RoboDanny's one, now I can't imagine any other way of this paginator

winter cairn
#

So you know how with webhooks you can send messages with any name or profile picture? Is it possible to recreate that functionality without manually creating and calling a webhook?

silk fulcrum
#

but if you want a profile that is not similar to your bot's, then webhook is pretty much the only way

#

ohh it's already 0 AM

winter cairn
#

Alr bet thx

silk fulcrum
#

@slate swan, gn

winter cairn
#

And how could I create a webhook in code?

silk fulcrum
unkempt canyonBOT
#

class discord.Webhook```
Represents an asynchronous Discord webhook.

Webhooks are a form to send messages to channels in Discord without a bot user or authentication.

There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.webhooks "discord.Guild.webhooks"), [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks") and [`VoiceChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel.webhooks "discord.VoiceChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.

The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.

For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.8)"):
winter cairn
#

Oh gn sweet dreams

silk fulcrum
slate swan
#

get it cuz dont let the bed bugs biteshipit

winter cairn
#

Pov commands using prefixes and reaction buttons rehehehhe

silk fulcrum
slate swan
winter cairn
#

Don’t let the dogs bite in the night without the light

silk fulcrum
silk fulcrum
winter cairn
#

Ur in Russia?

slate swan
#

hes with me

#

πŸ˜‰

silk fulcrum
#

goes checking where's my cat

slate swan
silk fulcrum
#

looking in the window

#

maybe he's missing you lol

slate swan
#

πŸ˜”

silk fulcrum
#

ohhh my gosh, I just figured out that tomorrow, or today I have to spend like 2-3 hours in the morning, and then my WHOLE day is free, hehehe im gonna go crazy (switch between accounts)

#

bye guys, solve problems (not with my cat)

calm ridge
#

so im starting off with this new code

#

and im trying to figure this out

#
import discord
import os

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.attachement:
        await message.channel.send(content=message.attachments[0].url)
        return
      
        await message.channel.send(content)

client.run(os.getenv('TOKEN'))
#

i want it to grab the image and also print out the same image

#

is that possible

slate swan
#

print the image??

calm ridge
#

like for the bot to reprint the same image the user did

slate swan
#

Why not use f strings on line 8? they're faster

calm ridge
#

but im not sure how to do the rest

slate swan
#

Just print the url?

calm ridge
#

do i need to store the url into a var

sick birch
sick birch
#

This guy on YT that makes pretty bad tutorials, as you can see

slate swan
slate swan
#

d.py==1.7.0 ?

sick birch
#

Yes, but even so they don't use things like f strings

calm ridge
slate swan
#

Try it

sick birch
#

@calm ridge call .to_file() on the discord.Attachment instance, and pass it into the file= kwarg into ctx.send()

#

Don't have to mess with URLs or anything

slate swan
#

does someone know how can i get the account length of someone and display his days since his creation?

slate swan
#

E.g if i created my account yesterday, the bot to display 1 day

calm ridge
#

to display elsewhere

slate swan
#

Don't use to file then

calm ridge
sick birch
#

Thought you wanted to send it on discord?

slate swan
slate swan
#

I don't think you can print actual images in console

calm ridge
#

that is correct

slate swan
#

Wait so what's your issue?

calm ridge
slate swan
#

!d discord.User.created_at

unkempt canyonBOT
#

property created_at```
Returns the user’s creation time in UTC.

This is when the user’s Discord account was created.
slate swan
calm ridge
#

and the image for some reason is not stored in content?

slate swan
calm ridge
#

or do i use ctx.send

slate swan
#

print content

slate swan
slate swan
sick birch
slate swan
#

damn I'm behind sadJoegbh

#

me too

#

@calm ridge just print message.attachments[0].url and see if it matches the image your bot sends

calm ridge
slate swan
#

remove that line

#

you are already passing the argument content in your previous message

#

!d discord.TextChannel.send

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

Sends a message to the destination with the content given.

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

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

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

@calm ridge

sick birch
#

@slate swan for example, your account was created <t:1542564916:R>

frozen patio
#

πŸ‘€

dull terrace
#

i made my database cursor global like an idiot and didn't think about the consequences slump_bear

slate swan
#

Is there a way to make a slash command global cause i have my bot in 3 guilds?

sick birch
slate swan
sick birch
#

Does add_cog sync that cog automatically?

#

!d discord.ext.commands.Bot.add_cog

unkempt canyonBOT
#

await add_cog(cog, /, *, override=False, guild=..., guilds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a β€œcog” to the bot.

A cog is a class that has its own event listeners and commands.

If the cog is a [`app_commands.Group`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Group "discord.app_commands.Group") then it is added to the bot’s [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") as well.

Note

Exceptions raised inside a [`Cog`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog "discord.ext.commands.Cog")’s [`cog_load()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog.cog_load "discord.ext.commands.Cog.cog_load") method will be propagated to the caller...
slate swan
#

Another question

#

I have command which takes from db some values. These values can be random as quantity. Now I have 20 values. However are these values are, I add them to embed but as you understand, this embed is too big. So , is there a way to make every page to has 10 values, if they exist?

#

I know that can be done with discord-ext-menus but i dont really understand these menus

regal jacinth
#

Did anyone work with sellix api before. Like automize purchases and connect them to discord bot?

crystal glen
#

Give me an idea for one of my bot's commands.

#

if yes, give me an example

cloud dawn
#

Yes you can record audio.

#

But we won't help with that here.

crystal glen
#

why not?

#

Don't tell me it's rule 5

cloud dawn
#

Because you can record people without their consent.

crystal glen
#

πŸ€¦β€β™‚οΈ

cloud dawn
#

Still don't think discord.py supports audio recording you'd need to make something custom.

cloud dawn
crystal glen
vale cape
#

Any idea why my discord bot wouldn’t be updating/syncing it’s commands with my guild?


async def on_ready(self):
    await tree.sync(guild = discord.Object(id = guild_id))
    log(f'Logged in as Name: {client.user.name} - ID:{client.user.id}', folder = "logs")

log is a custom function that simply prints to console and saves the log to a folder

#

After I add a command and restart the bot, it won’t show as a slash command in the Discord server. Also when I require new parameters/remove parameters it doesn’t update, but running the command will show the new response from the bot.

crystal glen
#

How do I add break lines between the datas?

vale cape
#

indent not indend

crystal glen
quartz nacelle
#

ImportError: cannot import name 'commands' from 'discord.ext' (unknown location) How do I fix this import error?

crystal glen
#

When I spam to level up, And then I level up while I'm spamming, The bot sends the level up 2 times, What's the best fix for this?

quartz nacelle
#

My code used to work before

quartz nacelle
#

ok

vale cape
crystal glen
# crystal glen thanks

When I spam to level up, And then I level up while I'm spamming, The bot sends the level up 2 times, What's the best fix for this?

crystal glen
vale cape
vale cape
quartz nacelle
#

pip install discord

#

thats what i did

vale cape
quartz nacelle
#

i did

#

I did pip uninstall discord and then pip install discord

vale cape
#

The directory you’re running the script from, is there a file/folder named discord

quartz nacelle
#

no

#

foldername is meteorbot and filename is main.py

vale cape
#

What about in the same folder as your bot?

quartz nacelle
#

nothing is named discord in the files or folders

#

of my bot

fading marlin
#

rate limited perhaps? you shouldn't be syncing in on_ready either way

vale cape
#

The issue had to do with me using run instead of start

#

I just figured it out and came back to say solved

slate swan
#

hey

#

i cant run my discord bot and i got errors

#

for my GUILDS

#

const Discord = require(Discord.js);

const { token } = require('./config.json');

console.log(token);

const prefix = !;

const client = new Discord.Client({
allowedMentions: {
parse: [users, roles],
repliedUser: true,

},
intents: [
    "GUILDS",
    "GUILD_MESSAGES",
    "GUILD_PRESENCES",
    "GUILD_MEMBERS",
    "GUILD_MESSAGE_REACTIONS",
    
  ]

});

client.on("ready", () => {
console.log("NitroNet Services botten Γ€r nu uppe!")

})

client.login("")

#

is these guilds right? Discords documentaion doesnt explain so good

shrewd apex
#

this is a python server πŸ’€

slate swan
#

omg im so stupid

#

I completely forgot about it lmaooo

slate swan
#

i cant find js official dc server

#

does anyone it?

fading marlin
#

you're reassigning the value of ids

#

name it something else?

#

your variables...

#

show updated code

#

you're not changing your json info when you first load it

#

also ^

#

what you're basically doing is:
loading your json file
setting id as the guild id
dumping the guild id to your json

you're not editing the object (assuming it's a dictionary) that gets returned once you load your json file. Put simply, you're not "adding" the guild ID to your "database which isn't a databse"

cold tide
#
@bot.command()
async def purchase(ctx: commands.Context) -> None:
  try:
    await ctx.send(f"{ctx.author} How would you like to pay? (b) boost (btc)")
    message = await bot.wait_for("message", timeout=60, check= lambda d: d.author == ctx.author and d.channel == ctx.channel)
  except TimeoutError:
    return await ctx.send("Error !")
  if message.content == "b":
      await ctx.author.send(f"{ctx.author} Please boost the server to recieve your purchase !")
  if message.context=="btc":
       await ctx.send(f"{ctx.author} please send the equivalant of $2 to this address: bc1qtcdmjhqzzsfv2xc8efvd7gat4e4uvtze2ahr9q")
bot.run(token)
#
if message.context=="btc":
#

2nd statment isnt working ^

silk fulcrum
cold tide
#

oh yeah.

#

😭😭

#

lol

silk fulcrum
#

typo πŸ’€

cold tide
#

Simple misstakes lol

slate swan
#

@cold tide your PfP has got to racist πŸ’€

karmic horizon
#

Ive got this (tokens on the bottem) and when running the command $version, its not doing anything

#

Ideas?

silk fulcrum
#

Indents

karmic horizon
silk fulcrum
#

your if message.content.startswith is inside previous if

karmic horizon
cold tide
#

Someone tell me how you can make a event that sends "error this command doesnt exsist"

#

Would be appreciated.

#

Not sure how to.

silk fulcrum
#

!d discord.ext.commands.Bot.on_error

unkempt canyonBOT
#

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

The default error handler provided by the client.

By default this logs to the library logger however it could be overridden to have a different implementation. Check [`on_error()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_error "discord.on_error") for more details.

Changed in version 2.0: `event_method` parameter is now positional-only and instead of writing to `sys.stderr` it logs instead.
cold tide
#

can you show me a example??

silk fulcrum
#

well, there is no example for this in docs

cold tide
#

So just that??

#

Idk how to.

#

Thats why im asking for a example.

silk fulcrum
#

well you just do usual event

@bot.event
async def on_command_error(ctx, error):
    ``` and then check if error is CommandNotFound and send that it is not found
```py
    if isinstance(error, commands.CommandNotFound):
        await ctx.send(f"Command {ctx.command} not found")```
#

but im not sure about ctx arg in on_error

slate swan
#

no, that wont; work

#

on_error just takes an event and the args

silk fulcrum
#

on_command_error?

slate swan
#

should use on_command_error instead, ye

silk fulcrum
#

yeah of course...

slate swan
#

discord added some stupid vc feature

cold tide
#

So what should it be like?

silk fulcrum
#

text in voice?

silk fulcrum
slate swan
silk fulcrum
#

lmao wth

#

@Danny go ahead code the dpy so bots will spam those emojis

silk fulcrum
#

who did it ping

#

some random danny

cold tide
#

Whats the hex color for red?

slate swan
#

some random, danny doesnt join public servers usually

cold tide
#

anyone know?

slate swan
unkempt canyonBOT
#

classmethod red()```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") with a value of `0xe74c3c`.
cold tide
#

the id.

slate swan
#

0xe74c3c

cold tide
#

sorry.

vale wing
#

E74C3C isn't natural red 😩

#

FF0000 better

cold tide
#

How to send a message if command is used in the wrong channel??

silk fulcrum
cold tide
#

What does that mean.

#

😭

silk fulcrum
#

@decorator

#

e.g @bot.command()

robust fulcrum
#

Hmmm

#

You should learn about decorators first?

silk fulcrum
#

Well if you don't have a decorator for a specific channel, then you can just add if ctx.channel.id != channel_id: and send that it's wrong channel

#

in the beggining of command

vale wing
#

Shortly decorator turns the function into something that decorator function returns

slate swan
#

Eyo can someone help me because my bot is uncontrollably online

silk fulcrum
#

uncontrollably online?

slate swan
#

Yes

silk fulcrum
#

what does that mean

slate swan
#

I cant make it offline

silk fulcrum
#

waht?

slate swan
#

My bot is not getting offline

#

it will, have patience

silk fulcrum
#

Can't you just go to terminal and turn it off?

slate swan
#

No its not in terminal

#

on discord yes, it will go offline, have patience

silk fulcrum
#

ohkay

slate swan
#

Ohh its offline now

#

😳

silk fulcrum
#

lemao cooldown

#

delay*

slate swan
#

My bot is not changing appearance too

silk fulcrum
#

This is app

#

And you need bot

slate swan
#

Yes

silk fulcrum
slate swan
#

Ohh

#

Im such is dum person

grizzled otter
#

Hello, Do you have any sample about a discord boot that makes speadchtotext from audio channel?

silk fulcrum
slate swan
slate swan
west veldt
#

um i was trying to make a purge command but it is kindaf giving me a error im coding in replit.com ```py
@bot.command()
@has_permissions(administrator=True, manage_messages=True)
async def purge(ctx, amount=5):
await ctx. channel. purge(limit=amount + 1)
await ctx.send(((embed=discord.Embed(description=f":tick: successfully deleted {amount} messages in {ctx.channel}", color=0x2E08CB))

#

please help me get thru this

silk fulcrum
#

what are these brackets?

#

for what?

#

you need to remove them, leave only 1, cus they're not even closed

west veldt
slate swan
#

!e

print(((((((((((("uwu"))))))))))))
unkempt canyonBOT
#

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

uwu
slate swan
west veldt
#

im using that flask thing to make bot alive

silk fulcrum
silk fulcrum
slate swan
west veldt
silk fulcrum
slate swan
unkempt canyonBOT
#

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

2
slate swan
#

they still don't dogepray

#

yeah the whole part is considered to be the content arg

tough lance
#

Hi

silk fulcrum
#

hi

glad cradle
silk fulcrum
#

to show me that they do not matter

glad cradle
#

oh

#

ok

slate swan
#

thi what seems like a good abstraction for Intent builder py intents = Intents( Intents.X | Intents.Y | Intents.Z , ...) or ```py
intents = Intents()
intents.add_intent(Intents.X)

#

the first one ofc, the second one looks too wordy

silk fulcrum
#

first

slate swan
#

yeah so ill go with that :p

slate swan
#

ah well, not my thing

#

understandable, still working on dawn?

slate swan
#

slash commands are done with extensions ( cog like stuff ) and the bot base

#

i'll make the user and message commands when im bored

#

mhm cool

#

good luck 02love

#

the autocomplete looks so uwu pepeShy

silk fulcrum
#

will it be hard or omega hard to switch to hybrid commands from usual commands?

paper sluice
#

no?

paper sluice
#

the format is pretty much same

silk fulcrum
#

I hope so

slate swan
#

I think I have them in my slash commands gist, i forgot

#

oh yeah I do

slate swan
silk fulcrum
#

ephemeral send

slate swan
#
@Command.autocomplete("argument name")
async def name_it_anything(**some_args) -> list/Choice:
  ...``` is basically what each library does
#

but i wont be shocked if dpy came up with some weird shit

#

**args πŸ˜”

silk fulcrum
#

wait, @slate swan so even if I do usual it can send ephemeral message?

silk fulcrum
#

I mean not slash

slate swan
#

please define usual

slate swan
silk fulcrum
#

then how will this work

slate swan
#

ctx.defer and ephemeral=True only run when trigger is from a slash command

#

i think it will just not send the ephemeral response

#

without any error

robust fulcrum
#

Guys what's this error?

slate swan
#

time to dig in the source code

slate swan
silk fulcrum
#

okay, then I'll try em and see

robust fulcrum
silk fulcrum
#

no

slate swan
#

when command is invoked as slash command -> ephemeral = True works
when command is invoked as message command -> ephemeral = True is ignored

silk fulcrum
#

that all looks sus but ok

slate swan
#

πŸšΆβ€β™‚οΈ thats what i said

slate swan
slate swan
#

i mean lightbulb does the same

slate swan
west veldt
#

um can anyone help me a bit i was trying to make a kick command but it not working its not even giving an error ```py
@bot.command(pass_context = True)
@has_permissions(administrator=True, ban_members=True)
async def kick(ctx, userName: discord.member):
await userName.kick()

@kick.error
async def kick_error(error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send(f"Sorry you don't have permission to do that")```

slate swan
#

The capitals always get you πŸ˜₯

#

πŸ˜”

silk fulcrum
#

me?

slate swan
#

Definitely

#

it's a convention so no

west veldt
silk fulcrum
#

ok

slate swan
#

It's all good

slate swan
short relic
#
import discord 
from discord.ext import commands
from discord.ui import Button

bot = commands.Bot(command_prefix="=")
@bot.command()
async def hello(ctx):
    button = Button(label = "Hi", style = discord.ButtonStyle.success)
    view = View()
    view.add_item(button)
    await ctx.send("Hi", view = view)
#

can someone help me the command doenst work for me

#

and also in the error its the View() not defined

silk fulcrum
#

because it's not defined

#

you have no class View

#

and no class View imported

#

from discord.ui import Button, View ?

short relic
#
import discord 
from discord.ext import commands
from discord.ui import Button, View

bot = commands.Bot(command_prefix="=")
@bot.command()
async def hello(ctx):
    button = Button(label = "Hi", style = discord.ButtonStyle.success)
    view = View()
    view.add_item(button)
    await ctx.send("Hi", view = view)

added import view but when i use the command =hello nothing responded

silk fulcrum
#

no errors?

short relic
#

the command just doesnt wrok

west veldt
silk fulcrum
west veldt
paper sluice
short relic
#

but the discord doesnt allow me to send it here

#

the bot is online tho

cold tide
#

What are cogs?

west veldt
cold tide
#

what is it.

short relic
#

but not for me i used bot.run()

#

but it doenst work even tho

silk fulcrum
paper sluice
# short relic yea i did

its weird that it doesn't show any error, but you need to have intents in your code and portal
the important one here is Intents.message_content

short relic
#

so how do i fix like where do i add it

paper sluice
#

like:

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(..., intents=intents)
slate swan
# slate swan What?

I mean, class names as pascal case is just a convention of writing code in any language ASakashrug

#

I don't know what pascal case is

paper sluice
slate swan
#

Oh

silk fulcrum
#

ThenWhatIsUpperCamelCaseFor?

slate swan
#

I'm not too smart

#

My fault

slate swan
slate swan
slate swan
slate swan
silk fulcrum
slate swan
west veldt
#
@bot.command(pass_context = True)
@has_permissions(administrator=True, ban_members=True)
async def kick(ctx, userName: discord.Member):
  await userName.kick() 
  await ctx.send(embed=discord.Embed(description =f"**:tick: {member.display_name} has been kicked **", color=0x2E08CB))``` um this my code it was supposed to send an embed after the member is kicked but it isnt somehow
slate swan
#

Why do people send embeds like that

silk fulcrum
#

why not

slate swan
#

I like making an embed variable instead

silk fulcrum
west veldt
silk fulcrum
#

and name it e

slate swan
#

Master32 real

west veldt
#

just doesnt send embed after kicking

short relic
#

and it worked for him but not for me

silk fulcrum
#

maybe embed requires title

#

but it doesnt iirc

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
west veldt
silk fulcrum
#

oh yes

west veldt
#

member is not defined

silk fulcrum
#

it's userName, not member

west veldt
#

o

slate swan
#

userName.display_name

slate swan
#

Edited

short relic
#
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="~")
@bot.command()
async def hello(ctx):
    await ctx.send("hi")

when i use ~hello nothing happened and no error output whats the problem (the bot is online)

rich haven
#

try @client.command()

silk fulcrum
#

why

silk fulcrum
rich haven
silk fulcrum
short relic
#

in vsc its full blue

silk fulcrum
#

this is discord, not vsc

rich haven
#

Oh my bad

#

sorry

slate swan
vocal snow
#

that looks like dpy 1.7.3 so it shouldnt matter

vocal snow
short relic
vocal snow
slate swan
#

Or is that wrong I can't even remember rn

silk fulcrum
#

pip show πŸ†—

slate swan
#

That

#

My fault it's 3 am

silk fulcrum
short relic
silk fulcrum
#

in terminal

vocal snow
short relic
silk fulcrum
#

2.0 hehe

slate swan
silk fulcrum
#

intents

vocal snow
#

you need to enable them in your code

short relic
#

how do i do that

slate swan
#

Zeffo was wrong wtf

vocal snow
#

and the dev portal but I think you've done that

vocal snow
short relic
#

and also

silk fulcrum
short relic
#

the weird thing is it works for my friend

silk fulcrum
#

and that

short relic
#

but not for me

slate swan
#

intents = discord.Intents.all()

silk fulcrum
vocal snow
slate swan
#

!d discord.Intents.all

unkempt canyonBOT
#

classmethod all()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents "discord.Intents") with everything enabled.
short relic
#

how do i install the 1.7.3

#

😩

silk fulcrum
#

why not 2.0

slate swan
#

Why do you want to downgrade

short relic
#

because its pretty complicated

vocal snow
#

just enable intents and it'll work

short relic
#

and im just a newbie

#
import discord 
from discord.ext import commands
from discord.ui import Button, View
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="=", intents = intents)
@bot.command()
async def hello(ctx):
    button = Button(label = "Hi", style = discord.ButtonStyle.success)
    view = View()
    view.add_item(button)
    await ctx.send("Hi", view = view)

heres the code i sent in to my friend after fixing and it worked for him but not for me

slate swan
#

Or listen to Zeffo & Master

short relic
#

it worked, the capital letters got me πŸ˜“

silk fulcrum
#

bruh

slate swan
#

Okay

#

!d discord.Intents.default

unkempt canyonBOT
#

classmethod default()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents "discord.Intents") with everything enabled except [`presences`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.presences "discord.Intents.presences"), [`members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members"), and [`message_content`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.message_content "discord.Intents.message_content").
slate swan
#

You need to set the message content intent

#

Defualt does not include it

silk fulcrum
#

that's what he did

slate swan
#

Okay I'm actually blind

#

My fault do not listen to me

silk fulcrum
#

go sleep it's 3 am are u kidding

slate swan
#

It's too late for this

#

I think I'm losing brain signals staying awake

cerulean solstice
#
import discord
from discord.ext import commands

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

@bot.event
async def on_ready():
  print("Bot is online")


bot.run("Token")

this is the error:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    bot = commands.bot(command_prefix="!", intents = discord.Intents.all())
TypeError: 'module' object is not callable
#

could someone help?

vocal snow
#

Bot

#

not bot

silk fulcrum
#

capitals

cerulean solstice
#

ok

silk fulcrum
#

of great britain

cerulean solstice
#

thanks

#

im so dumb
i check it and could not find it

pearl shoal
#
import random
from discord.ext import commands

TOKEN = 'tokem'
client = commands.Bot(comands_prefix='Poke!, poke!')

@client.event
async def on_ready():
    print('{client.user} is on')
    

@client.command
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
    if reason==None:
      reason="no reason provided"
    await ctx.guild.kick(member)
    kick_messages = ["Pichu used charm to kick {member.mention}", "Pikachu used thunder shock to kick {member.mention}", "Raichu used walt switch to kick {member.mention}", "Squirtle used water gun to kick {member.mention}", "Wartorle used rapid spin to kick {member.mention}", "Blastoise used skull bash to kick {member.mention}", "Bulbasaur used leaf blow to kick {member.mention}", 
"Venusaur used solar beam to kick {member.mention}", "Charmander used Flame thrower to kick {member.mention}", "Charmeleon used metal claw to kick {member.mention}", "Charizard used inferno to kick {member.mention}"]
    await ctx.send(f'{random.choice(kick_messages) + " " + (member.mention)}')


client.run(TOKEN)
silk fulcrum
#

why not just await member.kick()

pearl shoal
#

ok

unkempt canyonBOT
#

Hey @pearl shoal! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

silk fulcrum
#

go reset token

pearl shoal
#
import random
from discord.ext import commands

TOKEN = 'token'
client = commands.Bot(comands_prefix='Poke!, poke!')

@client.event
async def on_ready():
    print('{client.user} is on')
    

@client.command
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
    if reason==None:
      reason="no reason provided"
    await ctx.member.kick()
    kick_messages = ["Pichu used charm to kick ", "Pikachu used thunder shock to kick ", "Raichu used walt switch to kick {member.mention}", "Squirtle used water gun to kick {member.mention}", "Wartorle used rapid spin to kick {member.mention}", "Blastoise used skull bash to kick {member.mention}", "Bulbasaur used leaf blow to kick {member.mention}", 
"Venusaur used solar beam to kick {member.mention}", "Charmander used Flame thrower to kick {member.mention}", "Charmeleon used metal claw to kick {member.mention}", "Charizard used inferno to kick {member.mention}"]
    await ctx.send(f'{random.choice(kick_messages) + " " + (member.mention)}')


client.run(TOKEN)
#

still not working

silk fulcrum
#

not ctx member

#

just member, you have an argument member

#

why would you need ctx

pearl shoal
#

ok

glad cradle
paper sluice
short relic
#
import discord 
from discord.ext import commands
from discord.ui import Button, View
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="=", intents = intents)
@bot.command()
async def hello(ctx):
    button = Button(label = "1", style = discord.ButtonStyle.success)
    
    async def button_callback(interaction):
        await interaction.response.send_message("one")
    button.callback = button_callback
    view = View()
    view.add_item(button)
    await ctx.send("Hi", view = view)

i want to make it so that it will response base on what button is clicked. i think i have to use 'if' if yes how do i make it if no whats the way to do it

vocal snow
#

you could subclass Button and make the response a parameter

silk fulcrum
#

or subclass a view

short relic
paper sluice
short relic
paper sluice
short relic
#
@bot.command()
async def hello(ctx):
    button = Button(label = "son", style = discord.ButtonStyle.success)    
    async def button_callback(interaction):
        await interaction.response.send_message("one", view = View1(), View3())
    button.callback = button_callback
    view = View()
    view.add_item(button)
    await ctx.send(view = view)

can i make it so that it will send multiple buttons not only one

scarlet aurora
#

how can I read my sqlite db file?

scarlet aurora
dusky pine
# short relic ```python @bot.command() async def hello(ctx): button = Button(label = "son"...
# Create button 1
button = Button(label = "son", style = discord.ButtonStyle.success)    
async def button_callback(interaction):
    await interaction.response.send_message("one", view = View1(), View3())
button.callback = button_callback

# Create button 2
button2 = Button(label = "son 2", style = discord.ButtonStyle.success)    
async def button2_callback(interaction):
    await interaction.response.send_message("two", view = View1(), View3())
button2.callback = button2_callback

# Create view
view = View()
view.add_item(button)
view.add_item(button2)

# Send view
await ctx.send(view = view)

here is explanation in comment

scarlet aurora
#

without the use of code

silk fulcrum
#

programm?

dusky pine
#

if you have it installed, that is

silk fulcrum
#

yeah

scarlet aurora
#

sqlite3 CLI

dusky pine
#

sqlite3 your_file.db

scarlet aurora
#
sqlite3 : The term 'sqlite3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try again.
At line:1 char:1
+ sqlite3 data.db
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (sqlite3:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
short relic
#

maybe ill subclass button and view because i want to make it so that when a button is clicked another gui with buttons will pop up

scarlet aurora
#

which one @dusky pine

dusky pine
#

tools

#

the sqlite-tools one

mild zephyr
#

i use SQliteStudio

#

to manage databases in sqlute3

silk fulcrum
#

I use MySQL Workbench

dusky pine
#

or yeah that, if you want a GUI

dusky pine
silk fulcrum
#

but I use it to open my db

mild zephyr
dusky pine
#

ok

mild zephyr
#

super usefull

pulsar solstice
#

very simple question
how to make a on_message that only works if the message in in a specific channel

#

if a user messages "hi" in channel "chat" the bot should reply "hi" but if the user messages "hi" in the channel "chat2", the bot should not reply.
pls help

scarlet aurora
#

I'm using sqlstudio now, it works

#

thanks

short relic
#
@bot.command()
async def hello(ctx):
    button = Button(label = "Robux", style = discord.ButtonStyle.success)    
    async def button_callback(interaction):
        await interaction.response.send_message(view = View3())
    
    button1 = Button(label = "VPS", style = discord.ButtonStyle.success)
    async def button_callback(interaction):
        await interaction.response.send_message(view = View1())
    button.callback = button_callback
    
    view = View()
    view.add_item(button)
    view.add_item(button1)
    await ctx.send(view = view)

when i click button it says that this interaction is unsuccessful but when i click button1 it leads me to view3() any way to fix?

cold tide
#

What does this mean?

silk fulcrum
cold tide
paper sluice
silk fulcrum
paper sluice
#

is the cog loaded?

silk fulcrum
#

oh, cogs should have some stuff like tree.enable or idk in them yes?

silk fulcrum
whole sparrow
#

can you send an ephemeral message in a different channel from the place it was interacted?

#
        if isinstance(ctx, commands.Context):
            await ctx.send(embed=embed)
        elif isinstance(ctx, Interaction):
            await ctx.followup.send(embed=embed, ephemeral=True)
        return False

I want to send the ctx.followup.send in a different channel within the same server

#

whilst keeping ephemeral=True

short relic
#
@bot.command()
async def hello(ctx):
    button = Button(label = "Robux", style = discord.ButtonStyle.success)    
    async def button_callback(interaction):
        await interaction.response.send_message(view = View2())
    
    button1 = Button(label = "VPS", style = discord.ButtonStyle.success)
    async def button_callback(interaction):
        await interaction.response.send_message(view = View1())
    button.callback = button_callback
    
    view = View()
    view.add_item(button)
    view.add_item(button1)
    await ctx.send(view = view)

this is my code. when i clicked the first button everything is ok but when i clicked the second button it failed

paper sluice
paper sluice
silk fulcrum
#

oh wait im stupid

#

i have error

#

application_id set? waht

slate swan
pulsar solstice
#
import discord
from discord.ext import commands


bot = discord.Client()

@bot.event
async def on_ready():
    print("I am Ready")


@bot.event
async def on_message(message):
    if message.author.bot:
        return
    channels=['counting']
    id=bot.get_guild(server id)
    number=1
    username=str(message.author).split("#")[0]

    if str(message.channel) in channels:
        if message.content == number:
            number=number+1
        elif message.content != number:
            await message.channel.send(f"{username} messed up at {number}")
            number=1 





bot.run(token)

#

i made it counting bot

#

and the problem is that it always shows "{username} messed up at {number}"

#

even if the message.content == number

#

PLEASE HELP

slate swan
#
currentTime = currentDateAndTime
print(currentTime)


class Status(commands.Cog, name="Status"):
    def __init__(self, bot: commands.Bot):
        self.__bot = bot
        self.status_list = (
            nextcord.Activity(type=nextcord.ActivityType.watching, name=(currentTime.strftime("%H:%M"))),
        )
        self.current_status = random.randint(0, len(self.status_list) - 1)

    @commands.Cog.listener()
    async def on_ready(self):
        print("Status cog is ready!")
        self.status_loop.start()

    @loop(seconds=600)
    async def status_loop(self):
        """Loop to update status"""
        self.current_status = (self.current_status + 1) % len(self.status_list)
        await self.__bot.change_presence(activity=self.status_list[self.current_status])


def setup(bot):
    bot.add_cog(Status(bot))```

How do i make it so it updates the time continuously?
slate swan
#

use a botvar to set the number var 'cause scope issues

pulsar solstice
slate swan
#

how to make an uptime command.
If the bot is online rn,
And I run the command after 1h 12 minutes 32 seconds it should say
I’ve been up for 1h 12minutes 32 seconds

slate swan
slate swan
cold tide
#

When i use {ctx.command} it sends None

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

cold tide
slate swan
cold tide
#

How to make it so it sends the cmd?

pulsar solstice
# slate swan nice

I am getting this error:

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\8ster\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\8ster\Desktop\projects\Discord Bots\Counter\main.py", line 22, in on_message
    if message.content == number:
UnboundLocalError: local variable 'number' referenced before assignment```
slate swan
slate swan
cold tide
#

but its just sending the word None

pulsar solstice
#

i didn't

slate swan
#

Something like this

x + 1
x = 0 ```
cold tide
#

How do i make it send the command that was used?

slate swan
cold tide
#

it doesnt work though

cold tide
#

It just sends "None"

#

@slate swan

slate swan
#

It will send the content the user sent

cold tide
slate swan
cold tide
#

Nvm

pulsar solstice
slate swan
pulsar solstice
slate swan
cold tide
#

Thankyou πŸ™ƒ

slate swan
#

Till then lemme get my laptop

#

ping?

slate swan
#

So you want to get what the user sent when the messed up?

pulsar solstice
#

oups it's the old code sorry

#
import discord
from discord.ext import commands


bot = discord.Client()

@bot.event
async def on_ready():
    print("I am Ready")

number=1

@bot.event
async def on_message(message):
    if message.author.bot:
        return
    channels=['counting']
    id=bot.get_guild(_myserverid_...)
    username=message.author.name

    if str(message.channel) in channels:
        if message.content == number:
            number=number+1
        elif message.content != number:
            await message.channel.send(f"{username} messed up at {number}")
            number=1 





bot.run(token)
#

check this code

#

I defined number

#

then if the message is equal to the number

pulsar solstice
#

yes?

slate swan
#

And you are defining number after it

pulsar solstice
#

no I updating number after it

silk fulcrum
#

you are comparing str (message.content) and int (number)

pulsar solstice
#

check the line after print("I am Ready")

pulsar solstice
silk fulcrum
#

you need to do int(message.content) or str(number)

pulsar solstice
silk fulcrum
#

to compare them

pulsar solstice
#

let*

silk fulcrum
#

and also there are a lot of weird thing in your code

#

for example this line, you don't even use that id

#

also why do you do if str(message.channel) in channels, why not just if message.channel.name == 'counting'

pulsar solstice
#

lol

silk fulcrum
slate swan
#

How to fix?

slate swan
#

hey

#

i need some help how do i check a users status every 3 mins?

#

in a event btw ^

robust fulcrum
#

Guys i have db connection in my setup hook for my bot . I want to use that connection in my cogs. How can I use that?

slate swan
#

How to use asyncio.TimeoutError():?

#

Idrk if it requires await

paper sluice
#

wdym by use, what are you trying to do with it?

robust fulcrum
#

Me?

slate swan
#

can u help me?

vocal snow
#

assuming your cogs have access to the bot instance

robust fulcrum
slate swan
#

i need some help how do i check users in a server status every 3 mins?

slate swan
robust fulcrum
paper sluice
paper sluice
slate swan
#

so cbot.event

paper sluice
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

slate swan
#
  msg = await client.wait_for('message', check=check, timeout=15)
  await open_account(ctx.author,ctx)

  users = await get_bank_data()
  earn = random.randrange(500)

  if msg.content == random.choice(keys):
        await ctx.send(f"Great {ctx.author}! \nYou responded with the key in 15 seconds. You got {earn}")

        users[str(ctx.author.id)]["wallet"] += earn
        with open("mainbank.json", 'w') as f:
          json.dump(users,f)

  asyncio.TimeoutError():
    await ctx.send("You failed to send the key in 15 seconds, you get nothing")
```** **