#General Help

1 messages Β· Page 16 of 1

snow citrus
#

never used replit but i think yes

#

it should

ornate creek
#

just dont use replit

snow citrus
#

yea, use heroku instead

rapid kelp
#

okkkkk

#

multipeeps?

ornate creek
#

heruko is pretty decent

rapid kelp
ornate creek
#

what?

severe bear
#

it's not a game, wdym

craggy flame
#

so uhh, i got a slash command which is utilizing autocomplete, the next argument's option choices will be determined by the previous argument's selected option choice, the problem is the users can simply fill any argument first, which will then bring error since the previous argument's option choices havent been selected yet

is there any workaround? or do i have to implement it differently?

frigid lark
#

You can use
elif ...

slender lintel
celest moth
#

Is there a method to pass the parameter into the callback as shown below?

#

i'm doing something like await channel.send()

rose acorn
cold zephyr
#

any recommendations on how to present a user with a list that is >25 options but is not a slash command autocomplete option?

celest moth
#

however i end up with this error

sudden path
cold zephyr
#

😦 am considering paginating the options in a select, then, but it's such a faff

dark belfry
#

One simple question, are classes in python necessary? Can I code without using classes?

celest moth
#

It isn't necessary but it makes your code easier to understand? idk

#

I see most developers using object oriented programming these days

ornate spade
#

Everything is an object and belongs to a class

zealous brook
#

why cant i import discord.ui?

#

also in terminal it wont work..

slow dome
terse plinth
#

also if you have discord.py uninstall it

#

and then uninstall py-cord

#

then reinstall from here

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
slender lintel
#

What is the permission to timeout a member? I cant seem to find it on the permissions section on docs

slender lintel
late fjord
#

question about modals is there anyway to pass an option from a slash command into the callback of the modal?

errant verge
#
for role in ['Tokyo Fart Sniffers', 'Baltimore Bughas']:
    oldroles = discord.utils.get(ctx.guild.roles, name=role)
    await player.remove_roles(oldroles)

is this not a valid way to remove roles in a list?

#

i don't think its doing anything when i use my command

spring badger
#

hello?

#

I'm getting and error that says discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions when I use await ctx.author.timeout_for()

#

even the bot has all permissions and intents

keen root
spring badger
#

just the default ones

#

@here

humble talon
forest saffron
#

can i somehow set the ephemeral timeout?

forest saffron
#

did u invite him as admin

spring badger
#

it has admin permissions

spring badger
forest saffron
spring badger
#

and when I use timeout instead of timeout_for discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'datetime.timedelta' object has no attribute 'isoformat' is happens :)

slender lintel
#

has this changed?

slender lintel
#

not a user objecct

#

whats the difference?

#

well they have different attributes

#

and members are people in a guild

#

while the user is just user

#

ahh

#

what i need to change then?

slender lintel
#

thats what i am currently doing

slender lintel
#

message.author should work

#

but read the note that is underneath

#

i am confused to why its not working then

slender lintel
slender lintel
slender lintel
#

(think so at least)

slender lintel
slender lintel
slender lintel
spring badger
slender lintel
#

how do i grab all dms sent by the bot?

hoary moss
#

Hi, just want to ask -- is it possible to send a message to a specific channel in the on_message event? So let's say I wanted to send a message to channel with ID 881735375947722753, how would you do this?

slender lintel
hoary moss
mild hatch
hoary moss
#

Nice, sounds good. Thanks!

mild hatch
slender lintel
mild hatch
#

oh yeah if it returns None then the channel's not cached

#

in that case you can use await bot.fetch_channel(id)

#

just be weary this makes an API call

hoary moss
hoary moss
#

Guess there's no choice πŸ˜“

mild hatch
#

try using get_channel first

slender lintel
mild hatch
#

by grab you mean fetching them from an async iterator?

slender lintel
#

Yeah something like that.

#

a old dev mass dmed with my bot and i need to delete the DM's

tepid anvil
#

How to create a forum like this one guys

mild hatch
#

It might be wrong, im in class rn and i just did a simple thing

slender lintel
#

how many dms can i delete before getting rate limited u think?

mild hatch
#

you can set a limit or a date to check for in the user.dm_channel.history()s kwargs

slender lintel
#

ahh

mild hatch
#

you could use a non blocking timer on the iterator like await asyncio.sleep() so it does it in intervals and not all at the same time

slender lintel
#

ah

#

yeah

half marsh
#

Use #app-commands

slender lintel
#

people be getting wayy too pressed over this πŸ’€ its a help channel, that bots helping me quick scan pyc docs

#

technically its help shrug_pepe

vivid nacelle
#

@slender lintel Use #app-commands from now on

#

@honest moat whatever you did, stop it too

slender lintel
#

is there a way to assign roles via ID?

#

role id?

#

doesnt even throw me an error or nun just doesnt add the role

#

if yes then you can

role = ctx.guild.get_role(role_id)

await member.add_roles(role)```
#

i think i tried this, ill try again tho

#

yea doesnt work, no error either

#

show code please like full code

#
@client.event
async def on_member_join(member):
    gid = member.guild.id
    conn = sqlite3.connect('data.db')
    c = conn.cursor()
    c.execute("SELECT Guildid, Rolename FROM autorole WHERE Guildid=?",(gid,))
    send = c.fetchone()
    if send is None:
        return
    else:
        try:
            role = member.guild.get_role(send[1])
            await member.add_roles(role)
        except:
            return
#

using SQLITE3, the db isnt the issue as i can print the role id

#

is the role id a string or a int?

slender lintel
#

ill quickly test it with the actual role id instead of my db one

#

remove the try and except

#

so you can get an error

#

ah ok i see the error

#

its getting the role, failing to add it to the user

#

are you sure the role id is the actual role id?

slender lintel
#

k

#

it worked like that, but the id in my DB is identical to the role id

#

im gonna try drop my table and remake it

#

ayy works now

languid hollow
#
bot = commands.Bot(command_prefix = "?",intents=intents)
role = bot.get_role(893545812200677417)

AttributeError: 'Bot' object has no attribute 'get_role'

#

I'm confused

vivid nacelle
languid hollow
#

So I presume I would put it as

guild = bot.get_guild(12345)
role = guild.get_role(1235)
#

Thanks!

lucid cove
#

how do i send a dm to a user

#

message.author.dm_channel.send(embed=embedvar)

#

this doesnt work

snow citrus
#

message.author.send(embed=embedvar)

edgy cobalt
#

How do i get an argument from ctx without discord.Member in case using *

@commands.command()
async def said(self, ctx, target:discord.Member=None, *, args):
  if target is None:
    target = ctx.author
  await ctx.send(f"{target.name} said {args}")

like when ctx author doesn't mention user he becomes the target, but still get the args

ornate fog
pearl maple
#

How do u use slash cmds

#

For ur bot

sudden path
#

/slashcommand?

analog elk
#

How do I get a dropdown to be deleted after a modal is sent when an option from the modal is chosen?

analog elk
#

also is it possible to have bold text in a modal text field placeholder?

slender lintel
#
import discord
from discord.ext import commands
from discord.commands import slash_command, Option

import aiohttp
import aiosqlite
import logging
import os


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("discord")
handler = logging.FileHandler(filename="discord.log", encoding="utf-8", mode="w")
handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
logger.addHandler(handler)


async def get_prefix(client, message):
    db = await aiosqlite.connect('database/prefixes.db')
    async with db.execute("SELECT * FROM prefixes") as cursor:
        async for row in cursor:
            if row[0] == message.guild.id:
                return commands.when_mentioned_or(row[1])(client, message)
        return commands.when_mentioned_or("x!")(client, message)


class MyClient(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.session: aiohttp.ClientSession = None
        self.help_command = None
        self.case_insensitive = True
        self.command_prefix = get_prefix

    async def close(self):
        await super().close()
        await self.session.close()

    async def on_connect(self):
        self.session: aiohttp.ClientSession = aiohttp.ClientSession()

    async def on_ready(self):
        logging.info("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓")
        logging.info(f'Connected to bot: {self.user.name}'.center(55))
        logging.info(f'Bot ID: {self.user.id}'.center(55))
        logging.info("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")


client = MyClient(intents=discord.Intents.all())


@slash_command(name="ping", guild_ids=[965061411430600824])
async def ping(ctx: discord.ApplicationContext):
    await ctx.respond("pong")


@client.command(name="pong")
async def pong(ctx):
    await ctx.reply("ping")

client.run(os.environ["DISCORD_TOKEN"])```
#

Hi, can anyone take a look at my code to see why slash commands arent registering?

#

Idk why this time when I make a new bot no slash commands are registering and yes I do have applications.command scope on

#

it doesn't even register in dms too

desert dagger
#

Lets say user X uploads 4 attachments and a message.

Is it possible to remove attachment 2 from user X without deleting his message/losing other attachments

sudden path
slender lintel
#

I don’t think that’s the problem but I’ll try it when I wake up

sudden path
#

If you prefixed command works.

#

Then that's the issue. You're not registering the commands.

pearl maple
unborn silo
#

Anyone know why I get discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: edit() got an unexpected keyword argument 'nick' from a simple line await recruit.edit(nick=f"[19th] {oldNick}") I only get this nickname error when using it in this command:

@client.slash_command(guild_ids=[641329842058428416],description="Enlists recruit")
async def conscript(ctx,
regiment:Option(str,"Choose a regiment",choices=["19th Green Howards","King's German Legion","33rd Wellington's Own"]),
recruit:Option(discord.Member,"Recruit Discord username"),
recruiter:Option(discord.Member,"Recruiter Discord username")
):

    #ROLES
    oldNick=recruit.nick
    recruit=discord.utils.get(ctx.guild.roles, id=811623854426161184)
    nteenStaff = discord.utils.get(ctx.guild.roles, id=885856695853645864)
    britishArmy = discord.utils.get(ctx.guild.roles, id=863760593785323530)


    #19th Green Howards Custom
    nteenChannel=client.get_channel(862732931389849640)
    secondBrig=discord.utils.get(ctx.guild.roles, id=938845984274907216)
    nteenRole=discord.utils.get(ctx.guild.roles, id=862704039334641704)
    nteenDepot=discord.utils.get(ctx.guild.roles, id=862787244233588736)
    if regiment=='19th Green Howards':
        if nteenStaff in ctx.author.roles:

            await recruit.edit(nick=f"[19th] {oldNick}")
grizzled hare
#

not a member

#

recruit=discord.utils.get(ctx.guild.roles, id=811623854426161184)

#

You change it to a role in that line

unborn silo
#

ohhhhh

#

thanks for catching that for me

desert dagger
#

Slash commands seem to not like me making a button

  • version is V2 rc1
  • im using the template
class View(discord.ui.View): # Create a class called View that subclasses discord.ui.View
    @discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary, emoji="😎") # Create a button with the label "😎 Click me!" with color Blurple
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("You clicked the button!") # Send a message when the button is clicked

@bot.slash_command() # Create a slash command
async def button(ctx):
    await ctx.respond("This is a button!", view=View()) # Send a message with our View class that contains the button

#

"this application could not respond". When i made it into a prefix command it worked fine

errant verge
#

right now my command goes through and the button interaction works properly but it says the application did not respond?

await interaction.response.defer()
# bunch of stuff 
await interaction.message.edit(content = None, embed=embed , view=None)```

i tried `await interaction.followup.send(content = f'{ctx.author.mention}')` as well to ping the author and then embed but same thing
errant verge
#

respond not response?

acoustic rover
acoustic rover
desert dagger
#

debug_guilds=[serverid]

#

i'll probs try it out later incase my bots bugged

acoustic rover
#

Ok, I am wrong. This method is for ApplicationContext.

acoustic rover
errant verge
#

can't respond since it says the interaction has already been responded to

acoustic rover
#

Could you send your Code again? What did you change?

errant verge
#

rn i changed the last bit all to interaction.followup.send()

#

since i need it for interaction.defer()

#

no interaction.mesage.edit()

#

with that however, it says it didn't respond without clicking my button

acoustic rover
#

Sry, I do not understand your explanation.

errant verge
#

before it used to say it didn't respond after i clicked a button

#

that was with

await interaction.response.defer()
# bunch of stuff 
await interaction.message.edit(content = None, embed=embed , view=None)```
#

i tried ```py
await interaction.response.defer()

bunch of stuff

await interaction.followup.send(content = None, embed=embed , view=None)```

#

but now it gives me that message before

forest saffron
#

how do I
a) delete the ctx.respond message? I tried it with message = ctx.respond(...) and then await message.delete() but it doesnt work
b) can iset the timeout for ephemeral message

keen root
forest saffron
forest saffron
#

it’s just i didn’t find a timeout attribute for a respond in docs

#

nvm it’s done via view

unborn silo
#

anyone know how to solve this error for replit

#

trying to host my bot there

#

these are my packages

pearl maple
#

No soz i dont use repl

unborn silo
#

i also downloaded the pycord package on replit

red tendon
hearty rainBOT
unborn silo
#

because I can't create a .replit file

#

it says theres already one created

#

but its a fresh project

red tendon
unborn silo
red tendon
#

good

unborn silo
#

i just did python3 -m pip install -U py-cord --pre in shell

pearl maple
#

my code just wont work

slender lintel
#

is author.bot to check if the user is a bot or does it refrence the bot itself as in the bot thats running?

opal storm
#

author.bot returns a bool value

slender lintel
#

so if its true a bot sent the message?

opal storm
#

If the user is a bot, its True if the user isn't its False

slender lintel
#

Ah okay.

opal storm
#

It's true if a bot send the msg

slender lintel
#

wait is bot.user the bot itself then?

#

like the bot running?

opal storm
#

It's the bot user

keen root
#

yes

opal storm
#

so you could do message.author == bot.user:

slender lintel
#

ah okay.

opal storm
#

so the bot doesn't loop in an on_message event

slender lintel
#

why does this not work then?

opal storm
#

can you try printing the message.author.bot

slender lintel
#

ah

#

okay.

slender lintel
tepid anvil
#

interaction.followup.send_modal()

Not working , whats the alternative

red tendon
tepid anvil
red tendon
tepid anvil
#

since bot getting crashed when many are using the button

#

if the defer the button , modal will also be defered ?

red tendon
#

an interaction cannot response twice

tepid anvil
red tendon
tepid anvil
#

is my understanding right ?

edgy cobalt
#

I have issue
Happened after attempt of me to install py-cord, i uninstall it after
But now when i start new command in cog And run it, it gives me error that command not found

@commands.command(aliases=["p", "latency")
async def ping(self, ctx):
  ping = round(self.bot.latency * 1000)
  await ctx.send(f"{ping}ms!") 

Am using replit by the way

robust nebulaBOT
hearty rainBOT
#

Why NOT to use Repl as a hosting platform

You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.

  • The machines are super underpowered.
    • This means your bot will lag a lot as it gets bigger.
  • You'll need a web server alongside your bot to prevent it from being shut off.
    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.
    • This means any file you saved via your bot will be overwritten when you next launch.

IMPORTATNT

  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.

If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.

tepid anvil
# red tendon wdym

if i defer the button which is going to send a modal .. then the bot wont crash due to heavy surge right ?

red tendon
#

if your bot is crashing, get a better hosting service

tepid anvil
#

problem is bot is still online

#

but its saying failed interaction

red tendon
tepid anvil
craggy rapids
#

btw is that possible i can get the bot = discord.Bot(intents=intents) inside a cogs?

#

and i wanna use bot.get_channel(id) in db.py

worthy basin
#

bot is passed as an argument to cogs just do this

class Moderation(discord.Cog):
    def __init__(self, bot):
        self.bot = bot
tepid anvil
worthy basin
#

I dont think a modal has a timeout?

#

oh nvm i read your question wrong

craggy rapids
#

okie thx

worthy basin
#

ctx.bot also works withing a command iirc

craggy rapids
#

what?

worthy basin
#

if its in a command that you need it

@slash_command
async def hello():
    ctx.bot.XXX
worthy basin
plush lintel
#

code:

@bot.command()
async def testin(ctx, user: discord.Member = None):
    my_image = Image.open("wanted.jpeg")

    asset = user.avatar_url_as(size=128)
    data = BytesIO(await asset.read())
    pfp = Image.open(data)

    pfp = pfp.resize((125, 125))
    my_image.paste(pfp, (36, 80))

    my_image.save("profile.png")

    await ctx.send(file=discord.File("profile.png"))

error:

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

Traceback (most recent call last):
  File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 344, in invoke
    await ctx.command.invoke(ctx)
  File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url_as'
#

how can i fix?

#

thx

plush lintel
#

ok thx

paper harbor
#

So I want to say "if someone gets a score higher than fifty in this round, they double their points but if they get higher than 75, they triple their points"

so this but the also saying that the limit is until 75: if scores >= 50:

#

how would I do that?

plush lintel
#

thx

frigid lark
tepid anvil
#

its not working

#

await interaction.response.defer(modal) TypeError: defer() takes 1 positional argument but 2 were given

sudden path
tepid anvil
sudden path
#

Then send the modal on button click?

frigid lark
#

to send the modal use ```py
await interaction.response.send_modal(modal)

tepid anvil
#

await interaction.followup.send_modal(modal)

#

this too not working

#

@worthy basin

wintry python
#

Is it possible for a bot to use another bot's application commands?

craggy rapids
#

hmmm how to defer a ctx?

frigid lark
frigid lark
worthy basin
tepid anvil
tepid anvil
#

my button response is a modal

#

so how i can defer and follow up

worthy basin
#

And do you want the button to be deferred or the modal?

tepid anvil
worthy basin
#
await interaction.response.defer()
await interaction.followup.send_modal()
tepid anvil
#

error

worthy basin
languid hollow
#

for modal inputs, I'm guessing the maximum text thing you can have are 5?

tepid anvil
languid hollow
worthy basin
#

Your modal takes longer than 3 seconds to send?

tepid anvil
#

how can i fix that

tepid anvil
worthy basin
#

Can I see your code?

#

For the button callbacj

tepid anvil
#

sending in the thread

#

#984479774456033370 message

half marsh
#

whats the fastest way to edit mass message in a time?

crude pulsar
#

Is there a guide on how to migrate to permissions v2? I just updated pycord to the first release candidate and I'm getting this error

AttributeError: module 'discord.commands.permissions' has no attribute 'has_role'
slow dome
slow dome
slow dome
#

probably, yes

half marsh
#

What im doing rn is creating a loop for each message

slow dome
#

Why do you need to edit the message?

half marsh
#

Ah well, what i wanted to do is editing mass message quickly

heady lichen
#

hello! is mysql a good db for pycord?

half marsh
slow dome
slow dome
half marsh
#

Nope

heady lichen
slow dome
heady lichen
#

ahh, thanks!

slow dome
# half marsh Nope

well, I don't see any other way to not get ratelimited unless you add an asyncio.sleep between each execution

heady lichen
slow dome
#

"When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes."

heady lichen
#

ohh, i see

half marsh
slow dome
half marsh
heady lichen
#

is it possible to implement async on a synchronous library or should I just find another library that have async implemented? (sorry if I sound dumb, im new to this async thing)

slow dome
half marsh
heady lichen
humble sigil
#

how i can use music-cord

slow dome
slender lintel
#

Hey how i can use cooldown in button interaction?

tepid anvil
#

Can we get text input from buttons like slash commands ?

#

@slow dome

tepid anvil
slow dome
#

?tag ex

tepid anvil
#

since im done with defer modals

slow dome
#

Should be under bot examples

slow dome
short galleon
#

print(message.content) using this line to try and find the content off a message and in the console it is just showing an empty string (like there is nothing shown in console) any help?

tepid anvil
hearty rainBOT
slow dome
#

or smt

short galleon
#

wait i already had that, now im confused

tepid anvil
slow dome
tepid anvil
#

more like button press to receive a string from the users

crimson gale
slow dome
#

Well, there are slash command options that can take a string

#

which is probably the best if you want to defer a response

tepid anvil
short galleon
slow dome
slow dome
hearty rainBOT
#
import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
short galleon
#

nope

#

that would help

slow dome
#

?tag edit message-content
As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.

You will need to enable the intent on the developer portal, as well as in your code:

intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)

Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content

hearty rainBOT
#

dynoSuccess tag message-content edited.

slow dome
slender lintel
slow dome
slender lintel
slow dome
slender lintel
slow dome
slender lintel
#

?*

slow dome
#

I don't understand what you mean

slender lintel
#

I want that you can press the button only every 12 hours

slow dome
slender lintel
slender lintel
#

or?

slow dome
#

WDYM BY SEVERAL

slender lintel
#

No people should spam yk

slow dome
#

Ok? and?

slender lintel
#

and that's why I want a cooldown but only for individual players

slow dome
#

ok, then implement that

slender lintel
#

i am here to know how to do it.. oh never mind forget it thanks anyway

crimson gale
#

simplest way is to store the user id along with a timestamp of when the cooldown ends in a database somewhere

vivid nacelle
wintry python
#

Tyty tho

slender lintel
#

how could i purge every message the bot has sent within dms, is there a way to fetch all messages sent within dms?

slender lintel
#

Ah okay

#

Lemme take a look

honest moat
#

For normal

#

Commands

slender lintel
honest moat
#

Oh

little isle
#

What event catches interaction errors?

slow dome
#

except on_application_command_error

#

which is probably not what you are looking for

little isle
#

Unfortunately, it isn't catching this error

#

(Though I expected it to catch it, so I'm a little surprised atm)

slow dome
gilded widget
#

isn't on_error inside of a view a thing?

little isle
#

I'll check out on_error

#

Ah, I think I figured it out. I'm using a paginator, and that prints it out by default

gilded widget
#

yeah, since paginator is a subclassed view you can use on_error there as well

slow dome
gilded widget
#

no, as far as i remember its literally a subclass of view

slow dome
gilded widget
#

tbh i think it can be called either afaik

slow dome
#

I believe different places teach it differently. In my opinion, "subclass" sounds vague, but they mean the same thing, I guess.

little isle
#

Subclass is perfectly cromulent

gilded widget
clever lava
#

i cant invite robobruce help

clever lava
#

ty

slow dome
#

b!

nocturne delta
#

https://url.privatepastebin.com/ws

This is a project that we're doing! Here is what im trying to accomplish for this project.
A game similar to pokemon. I want the user to fight bosses, gain stats, and beat the game.
Here is the rubric for this;

south ermine
craggy rapids
#

do someone know what this error mean?

raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.url: Not a well formed URL.```
slow dome
#

it's self explanatory

sudden path
craggy rapids
#

no

#

it is not self explanatory and the url is not wrong

#

terrible

analog elk
#

How do i get a select menu message to be deleted when the user selects something?

sudden path
#

You're providing no context on that error. I can just assume.

#

Provide the full traceback then.

sudden path
#

Yes..

sudden path
craggy rapids
sudden path
craggy rapids
#

i sended...

sudden path
#

When is the error happening is what I mean

craggy rapids
#

every time

#

the embed maded

#

like almost 95% of it

gilded widget
#

can you just send the full traceback

craggy rapids
sudden path
#

Can you provide your code

craggy rapids
analog elk
#
      @countrygroup.command() # TODO: Add support for other entities (orgs, characters, etc)
    async def add(self, ctx: ApplicationContext): # maybe make an option for the message to not be ephemeral?
        """Send a modal to the user to add a country/entity"""

        class CountryAddView(discord.ui.View):
            @discord.ui.select(
                placeholder="Pick which entity to play as",
                min_values=1,
                max_values=1,
                options=[
                    SelectOption(label="Country", description="Play as a Country"),
                    SelectOption(label="Organization", description="Play as an Organization"),
                    SelectOption(label="Character", description="Play as a Character"),
                ],
            )
            async def select_callback(self, select, interaction: Interaction):
                modal = CountryAddModal(select.values[0], title="temp")
                modal.title = f"Add new {select.values[0]}"
                await interaction.response.send_modal(modal)

        view = CountryAddView()
        await ctx.respond("Select an entity below and click the button to create a new country/entity.", view=view, ephemeral=True)
#

this is the function in question

sudden path
#

Oh.

#

Not sure if you're able to send a modal and then edit the message

analog elk
#

Unfortunate

sudden path
#

You could try tho

gilded widget
#

as long as the modal is sent first you should be able to

sudden path
#

select.disabled = True
await interaction.response.edit_message(view=self)

smoky path
#

Hello, is it possible to get buttons to work after the bot restarted?

sudden path
#

You're looking for persistent views.

supple ravineBOT
#

Here's the persistent example.

celest moth
#

one of my application commands could not load

smoky path
#

I know how to make the buttons have no timeout but after i restart the bot he doesn't know how to react to the buttons

craggy rapids
#

how to add image form local into a embed

#

nbm

#

nvm

smoky path
#

Not working

#

just like my

#

@sudden path

half marsh
idle linden
#

Am I missing something?

#

discord.errors.ExtensionFailed: Extension 'jishaku' raised an error: AttributeError: module 'discord.ui' has no attribute 'TextInput'

idle linden
#

ah there must've been a change

finite cliff
#

PS C:\Users\Fammy\Desktop\Keni> & C:/Users/Fammy/AppData/Local/Programs/Python/Python310/python.exe c:/Users/Fammy/Desktop/Keni/bot.py
Traceback (most recent call last):
  File "c:\Users\Fammy\Desktop\Keni\bot.py", line 1, in <module>
    import discord
  File "C:\Users\Fammy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module>
    from .client import Client
  File "C:\Users\Fammy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module>  
    from .webhook import Webhook
  File "C:\Users\Fammy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module>
    from .async_ import *
  File "C:\Users\Fammy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\Fammy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)```
queen nacelle
#

How do I disable buttons after timeout?

#

the one thats in the docs doesnt seem to be working

plush lintel
#

hello i want to know what is BytesIO(await asset.read()) changed to

slender lintel
#

I'm trying to make a song selector using dropdown menus, and keep coming across this error from using the example:
AttributeError: 'SongSelect' object has no attribute '_underlying'

half marsh
#

ig you cant remove them unless you respond the interaction

smoky path
#

I want to make a Ticket system with buttons, but when i restart my bot the buttons doesn't work that where send before the restart

#

The code you send me doesn't work idk if i am doing something wrong or maybe it is outdated

half marsh
#

show your code

slender lintel
smoky path
# half marsh https://github.com/Pycord-Development/pycord/blob/master/examples/views/persiste...

I copyed this 1 by 1 (Just wrote my token inside the run function) and the command didn't even work.
My Ticket (only button) Code:

- Button function - 
class main(View):
    def __init__(self, ctx, time, bot):
        super().__init__(timeout=time)
        self.ctx = ctx
        self.bot = bot

    async def on_timeout(self):
        await self.ctx.send(f"Button Timeouted time was set to {self.timeout} Seconds")

    async def on_error(self, error: Exception, interaction: discord.Interaction) -> None:
        await interaction.response.send_message(Exception)

    @discord.ui.button(label="Ticket", style=discord.ButtonStyle.green, custom_id='TICKET')
    async def tick(self, button: discord.Button, interaction: discord.Interaction):
        - My Code -
- Command -
    @commands.command()
    @commands.guild_only()
    # @commands.cooldown(1,10,commands.BucketType.member)
    async def ticket(self, ctx):
        await ctx.message.delete()
        view = main(ctx, None, self.bot)
        await ctx.send('My Text',view=view)```
slender lintel
smoky path
slender lintel
crimson gale
#

view also has to have no timeout

slender lintel
half marsh
crimson gale
slender lintel
half marsh
smoky path
slender lintel
half marsh
smoky path
#

Np, i think i need a listener or something?

#

Because i just create the button but how is the bot actually reading it

crimson gale
smoky path
#

Hmmm lemme see

brazen siren
#

How can I get the id of the channel where the bot is invoked with a slash?

crimson gale
brazen siren
#

xd

#

ty broo

#

I thought it was more difficult

smoky path
rigid wave
#

What caused this problem and how can it be solved?
I use aiomysql in on_member_join

forest saffron
#

is it possible to fetch all messages in a channel and look for a specific content or do i have to iterate over every single message

plush lintel
#

my code```py
@bot.command()
async def testin(ctx, user: discord.Member = None):
my_image = Image.open("wanted.jpeg")

asset = user.avatar.with_size(128).url
data = BytesIO(await asset.read())
pfp = Image.open(data)

pfp = pfp.resize((125, 125))
my_image.paste(pfp, (36, 80))

my_image.save("profile.jpg")
await ctx.send(file=discord.File("profile.jpg"))
error
```py
Traceback (most recent call last):
  File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 344, in invoke
    await ctx.command.invoke(ctx)
  File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Users/luke/PycharmProjects/bot/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'read'
slender lintel
#

anyone know why my shards are not coming online?

keen blaze
#

Strange request but... is it possible to limit what commands are available based on the discord server?

slender lintel
#

Or regular commands?

keen blaze
#

either

#

im in the conceptual stages of the bot. Want it to perform similar tasks in 2 different servers but some of the commands should be exclusive to the one server or the other. Trying to work out if it would need 2 different bots.

slender lintel
#

You wanting to hind the slash command or show it but show a different message?

opal storm
#

uh

#

I want to move a channel at the end of a category, though the end kwarg in .move() does not do anything for some reason(I set it to True) neither does begging do anything(when set to False)

keen blaze
slender lintel
#

not too sure how though

slender lintel
#

For normal commands just include a check that sees if the guild is right or not and then return if it is the wrong guild

keen blaze
#

cool. thx

#

How about different join messages... (i might be pushing my luck πŸ˜‚ )

slender lintel
#

You can do that

#

So

#

use a database.

#

yes ^

#

And set what you want to send to the key which should be the guild id

#

And then you check the guild the member is in and send the message based off of that

keen blaze
#

Smart. Thanks for the help

slender lintel
#

Np

opal storm
#

Can anyone help in #984784278858645504

nocturne delta
#

My teacher literally said your allowed to google and research if you don’t know what to do

#

All good though

slender lintel
#

So im planning on adding auto modderation to my pycord discord bot but tbh i dont know where to start

#

could i just use like message.context and if its == "a bad word" do this

#

?

slender lintel
#

so create a list

#

and all my bad words into it

#

?

#

or a dict

#

what I would do is just create a list of bad words and just iterate through it. so like

bad_words = ["F###", "S###"]

for word in bad_words:
  if bad_words in message.content:
     do_something```
slender lintel
#

ok thx

#

i think there is a better way because these kind of things can easily be bypassed

#

ima customize so they cant byepass

#

like alterante

#

words

#

like shii

#

or shit like that

#

ill come back if i need help thx tho cya]

#

np

slender lintel
#

Here is something that you should prob use

#

?

slender lintel
#

wtf is fuzzywuzzy

#

its a library

#

used for text comparison

#

so you can compare if a word is close to another word

#

oh ok

#

fuzz.<a onclick="parent.postMessage({'referent':'.fuzzywuzzy.fuzz.ratio'}, '*')">ratio('London is a big city.', 'London is a very big city.')

#

ok but like

#

wtf is that lmao

#

name is weird :P

#

ya ill def look into it'

#

thx

#

np

#
  if bad_words in message.content:
     do_something```
#

so for this part

#

nvm

slender lintel
# slender lintel np
from email import message
from enum import auto
import discord
import datetime
from discord.ext import commands
from discord.commands import SlashCommand
from discord import default_permissions

client = commands.Bot()

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

    async def auto_mod(self, ctx, member: discord.Member, minutes: 1440):
        bad_words = []
        for Shit in bad_words:
            if bad_words in message.content:
                    duration = datetime.timedelta(minutes=minutes)
                    await member.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", description=f"@{member} That word has been filtered. Please refrain from using this kind of language, Thx. ", color=discord.Color.dark_gold())
                    await ctx.send(embed=embed)

def setup(client):
    client.add_cog(auto_mod(client))
``` SO i have  this but i cant get it to work?
#

uh you want a on_message event

#

@command.Cog.listener()

#

and it only takes the params
self, message

#

it gives me sytax error

#

discord.errors.ExtensionFailed: Extension 'cogs.auto_mod' raised an error: NameError: name 'command' is not defined

#

commands

#

oops

#

commands

#

yup

#
@commands.Cog.listener()
async def on_message(self, message):
  ``` is what you want
#
@commands.Cog.listener()
    async def on_message(self, ctx, member: discord.Member, minutes: 1440):
        bad_words = []
        for Shit in bad_words:
            if bad_words in message.content:
                    duration = datetime.timedelta(minutes=minutes)
                    await member.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", description=f"@{member} That word has been filtered. Please refrain from using this kind of language, Thx. ", color=discord.Color.dark_gold())
                    await ctx.send(embed=embed)
#

thats whats i have so far

#

but its still not working

strong totem
#

ok

slender lintel
strong totem
#
@commands.Cog.listener()
    async def on_message(self, ctx, member: discord.Member, minutes = 1440):
        bad_words = []
        for Shit in bad_words:
            if Shit in message.content:
                    duration = datetime.timedelta(minutes=minutes)
                    await member.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", description=f"@{member} That word has been filtered. Please refrain from using this kind of language, Thx. ", color=discord.Color.dark_gold())
                    await ctx.send(embed=embed)```
slender lintel
#

no

ornate fog
slender lintel
#
@commands.Cog.listener()
async def on_message(self, message):
        duration = 1440
        bad_words = []
        for Shit in bad_words:
            if Shit in message.content:
                    duration = datetime.timedelta(minutes=minutes)
                    await message.author.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", description=f"@{message.author} That word has been filtered. Please refrain from using this kind of language, Thx. ", color=discord.Color.dark_gold())
                    await message.channel.send(embed=embed)```
strong totem
#

oh it was on_message sorry i thought it was command

#

between is there any way to add bridge_command in Cogs

ornate fog
slender lintel
#

oh ye

slender lintel
#

AttributeError: module 'email.message' has no attribute 'content'

#

ya

#

im conffused

#

send code

slender lintel
#
from email import message
import discord
import datetime
from discord.ext import commands

client = commands.Bot()

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

    @commands.Cog.listener()
    async def on_message(self, ctx):
        duration = 1440
        bad_words =[]
        for Shit in bad_words:
            if Shit in message.content:
                    duration = datetime.timedelta(minutes=duration)
                    await message.author.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
                    await ctx.send(embed=embed)
def setup(client):
    client.add_cog(auto_mod(client))
slender lintel
#

in your code just change all the ones that have message to ctx

ornate fog
#

what

slender lintel
#

oops

ornate fog
#

you should name the message msg or something

#

ctx is misleading

slender lintel
#

ye

#

they dont have the exact same attributes i think

ornate fog
#

Not at all

slender lintel
#

also i dont think you can jsut do await msg.send

#

do await msg.channel.send

ornate fog
#

or rename your message import to email_message and change the attribute to message
Thats what i would do

#

jjea message is not messagable

slender lintel
#

ya so its still not working

#
from email import message
import discord
import datetime
from discord.ext import commands

client = commands.Bot()

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

    @commands.Cog.listener()
    async def on_message(self, message):
        duration = 1440
        bad_words = []
        for Shit in bad_words:
            if Shit in message.content:
                    duration = datetime.timedelta(minutes=duration)
                    await message.author.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
                    await message.channel.send(embed)
def setup(client):
    client.add_cog(auto_mod(client))
#

heres

#

all of my code

#

im loke just conffused cuz auto mod so much dif

#

then slash commands

#

heres all of it

strong totem
#

what is the error

slender lintel
#

nothing

#

there is not error

ornate fog
#

welll

#

u using the extensions completely wrong

strong totem
ornate fog
#

do you load the extension ?

#

whey do you defining client again ?

slender lintel
#

tbh

#

idk

strong totem
slender lintel
#

i just always have

strong totem
#

you have a main file

#

?

slender lintel
#

and it seems to work

#

yes

strong totem
#

send that

slender lintel
#

ik

ornate fog
#

du you use bot.load_extension() ?

slender lintel
#

yes

#

do you have message_content intent

#
import discord
import os
from discord.ext import commands
from discord.commands import SlashCommand

client = commands.Bot(activity=discord.Game(name='Watching for / commands'))

@client.event
async def on_ready():
    print(f"{client.user}Bot is loaded")

for file in os.listdir("./cogs"):
    if file.endswith(".py"):
        print("Loaded successfully")
        print(file[:-3])
        client.load_extension("cogs." + file[:-3])

client.run)

#

no intents

strong totem
slender lintel
strong totem
#
intents = discord.Intents.all()
intents.members = True
client = commands.Bot(activity=discord.Game(name='Watching for / commands'), intents = intents)```
ornate fog
slender lintel
#

:P

strong totem
vivid nacelle
#

@slender lintel it would be the best you don’t paste code snippets with bad language, because it’s forbidden here as well.

And tbh if the new Automod gets released, you don’t need a bot to check for it.

slender lintel
#

dude i needed to show them

#

but sure

slender lintel
#

ok

#

ya dude idk

ornate fog
strong totem
#
from discord.ext import bridge, commands


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

    @bridge.bridge_command()
    async def say(self, ctx, *, text):
        await ctx.send(text)


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

I think i am doing it right way?

strong totem
#

ok

slender lintel
#

its still not working for me

#

and i have no clie y

#

clue

strong totem
slender lintel
#

Ya true im still learning py

#

lmao

#

ik basics tho

#

and how to get arrount

#

arround

strong totem
#

ik basics of js

slender lintel
#

?tag lpp

hearty rainBOT
#

dynoError No tag lpp found.

slender lintel
#

?tag lp

hearty rainBOT
#
slender lintel
#

hmm

slender lintel
#

oh well i used code accademt

#

i like it

inner iris
#

When I pass the attachments argument to the message edit method, can I specify attachments from other messages or do they need to be from the message I edit?

slender lintel
#
from email import message
import discord
import datetime
from discord.ext import commands

client = commands.Bot()

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

    @commands.Cog.listener()
    async def on_message(self, message):
        duration = 1440
        bad_words = []
        for Shit in bad_words:
            if Shit in message.content:
                    duration = datetime.timedelta(minutes=duration)
                    await message.author.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
                    await message.channel.send()
def setup(client):
    client.add_cog(auto_mod(client))

ya i have so far but its not working for mr

strong totem
slender lintel
#

ig we do

strong totem
#

remove client declaration

slender lintel
#

im only 14 so

slender lintel
ornate fog
slender lintel
#

lol

#

i tryed to learn js and i said hell nah

strong totem
slender lintel
#

py easier

strong totem
#

i am good with web or better than node.js

slender lintel
#

my next is either lua or mysql

#

cuz im in the porcesse of a website

#

guys talk in #general please, or staff is prob going to warn us for getting off topic :P

#

k

ornate fog
slender lintel
#

Bro guys its still not working

slender lintel
#

wait 1 sec

#

imas try again

#

nope

#
import discord
import datetime
from discord.ext import commands

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

    @commands.Cog.listener()
    async def on_message(self, message):
        duration = 1440
        bad_words = []
        for Shit in bad_words:
            if Shit in message.content:
                    duration = datetime.timedelta(minutes=duration)
                    await message.author.timeout_for(duration)
                    embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
                    await message.channel.send(embed)
def setup(client):
    client.add_cog(auto_mod(client))
slender lintel
#

and enable them yet

#

in your developer portal

#

uhh yes in main

#

yes i did in dev

#

not main

#

...

#
import discord
import os
from discord.ext import commands

intents = discord.Intents.all()
intents.members = True
client = commands.Bot(activity=discord.Game(name='Watching for / commands'))

@client.event
async def on_ready():
    print(f"{client.user}Bot is loaded")

for file in os.listdir("./cogs"):
    if file.endswith(".py"):
        print("Loaded successfully")
        print(file[:-3])
        client.load_extension("cogs." + file[:-3])
#

oops

#

bruhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

im go reset

#

that real quick

#
client = commands.Bot(
  activity=discord.Game(name='Watching for / commands'),
  intents=intents
)```
#

you forgot to pass it in ._.

strong totem
slender lintel
#

uh 1 sec if i can get pycharm to start

strong totem
#

ok

slender lintel
#

do i have to pass intents for auto_mute cog?

#

no

#

it just cloes !!

#

LMAO

#

?

#

await self.start(*args, **kwargs)
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 658, in start
await self.connect(reconnect=reconnect)
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 599, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x000001D84A27CF70>
Traceback (most recent call last):
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
self._check_closed()
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x000001D84A27CF70>
Traceback (most recent call last):
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in del
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 750, in call_soon
File "C:\Users\GameScript\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 515, in _check_closed

Discord Developer Portal

Integrate your service with Discord β€” whether it's a bot or a game or whatever your wildest imagination can come up with.

#

oh shit

#

wtf

#

i did enable the,

strong totem
#

there is some below

#

Message Content Intent

slender lintel
#

Bruh :

supple ravineBOT
#

Here's the bridge commands example.

slender lintel
#

its

#

client.bridge_command()

#

:P

#

@strong totem

strong totem
#

ok

#

ok

#

so first if is checking for normal command

#

and seconds for slash commands

#

thanks

#

πŸ™‚

slender lintel
#

so when i try to Say Shit it gives

#

discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

#

so

#

ye

#

your bot

#

has no permission

#

to mute someone

#

it dose

#

give it admin or something

#

and amke sure the role

#

i did

#

is above the suer

#

Also you are probably the owner

#

it is

#

so it cant time out the owner

#

of the server

#

lol

#

yes

strong totem
#

so

slender lintel
#

thats why

strong totem
#

yeah

slender lintel
#

you are missing permissions

#

OH!!!

#

its cuz i said shit

#

lmao

#

mhm

#

my bot needs to be higher than my role

strong totem
#

this is the time when friends came to use

#

or alt account

slender lintel
#

and i cant cuz the main owner of our server has it on privte LMAO!!

#

im co owner

#

ah

#

lol

#

my bot name is Pankakers

#

lol

#

intersting

#

lol

strong totem
#

bot role should be on top if i am correct

slender lintel
#

ya i cant

#

tho

#

cuz its private

strong totem
#

make a new server

slender lintel
#

FUCK no

#

this server took so long

#

to make

#

its all about modding

#

gtav forza and shit like that

#

and all games

#

pretty much

slender lintel
#

Ok

slender lintel
#

into the server

#

to test

#

k'

strong totem
slender lintel
#

uh sure ig

#

accept mine

slender lintel
#

OMG

#

it worked

#

wow

#

thx guys

craggy rapids
#

btw how to check the text channel is nsfwf or not in code?

#

like if ctx.channel.is_nsfw :?

snow citrus
#

you can use @commands.is_nsfw()

#

the code will run only if channe is nsfw

craggy rapids
#

it can be nsfw or not nsfw

#

so if the content is nsfw i wanna block it

desert dagger
#

Well basically

craggy rapids
#

i think yes if.ctx.channel.is_nsfw should work

desert dagger
#

not really

#

how do you know if the content you give is nsfw?

snow citrus
#

then you can use if ctx.channel.nsfw:

#

or if not ctx.channel.nsfw:

craggy rapids
desert dagger
#
  1. You can use something to see if channel is marked nsfw or not which lets the command be used but not work if channel isnt nsfw
  2. The bot might throw an error in not being able to send since content is nsfw but you should still try the first bit
  3. Have an API/ai to scan content
craggy rapids
desert dagger
#

b!rtfm nsfw

open bearBOT
# desert dagger b!rtfm nsfw

I couldn't find a documentation with the name nsfw! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake

desert dagger
#

b!rtfm pyc nsfw

craggy rapids
desert dagger
#

mhm

#

just making sure that part is coered

craggy rapids
#

rtfm pycord is_nsfw

desert dagger
#

b!rtfm pyc is_nsfw

craggy rapids
#

b!rtfm pycord is_nsfw

craggy rapids
#

ye it is

desert dagger
#

lmao why did u rerun the command πŸ˜‚

slender lintel
craggy rapids
craggy rapids
craggy rapids
#

i think u dont need that if ur bot <500 server

slender lintel
craggy rapids
#

nice then , you should shard it

slender lintel
#

shards dont load

#

thats my problem

craggy rapids
#

mine? 1 year and 26 server

#

πŸ™‚

desert dagger
#

but why arent you using dotenv or enviroment secrets

slender lintel
desert dagger
#

why not?

slender lintel
#

in my eyes there is no major reason for me to do that.

desert dagger
#

I mean you might accidentally leak your token

#

Such as when you ask us for support or just when you publish source code and whatnot

#

If your bot is in 2.2k server that could be 2.2k servers that are nuked

frank wadi
#
    @slash_command()
    async def testt(self, ctx : ApplicationContext, category: Option(str, "select a category!", choices=["Moderation", "Miscellaneous"], required=True), Moderations: Option(str, choices=["ban", "clear"], required=True), Miscellaneouss: Option(str, choices=["owners", "clear"], required=True)):
        if category == "Moderation":
            await ctx.respond("Zrobiono szefie!")
            self.client.reload_extension(f"Commands.{category}.{Moderations}")
        elif category == "Miscellaneous":
            await ctx.respond("Zrobiono szefie!")
            self.client.reload_extension(f"Commands.{category}.{Miscellaneouss}")
#

i have a problem with this command

#

0 error

#

s

south ermine
slender lintel
#
import discord 
from discord.commands import slash_command
from discord.ext.commands import Cog

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

     @slash_command(name="ban", description="Bans a member")
     async def ban(self, ctx, member: discord.Member,*,reason):
      if ctx.author.guild_permissions.moderate_members:
       await member.ban()
       await member.send(reason)
       await ctx.respond(f'{member} has been banned from felbcord', ephemeral=True)
      else:
       await ctx.respond('You do not have the correct permissions for this',ephemeral=True)
    
def setup(bot):
    bot.add_cog(Ban(bot)) ```
I dont see why my command isnt showing up, It used to work fine?
#

nvm got it

#

I am now getting
This command is outdated, please try again in a few minutes
using this code

import discord
from discord.commands import slash_command
from discord.ext.commands import Cog

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

  @slash_command(name="dm", description="DM's someone")
  async def dm(self,ctx,member: discord.Member,*, message): 
     if ctx.author.guild_permissions.administrator:
       await member.send(message)
       await ctx.respond(f'{member} has been dmed', ephemeral=True)
     else:
       await ctx.respond('You do not have the correct permissions for this', ephemeral=True)
def setup(bot):
    bot.add_cog(dmCog(bot))```
slender lintel
slender lintel
#

ty

#

haha np

slender lintel
#

Why am i getting 2 errors saying commands is not defined? I have the correct imports, is this an indentation error

gilded widget
#

you havent actually imported discord.ext.commands, just a class from it

#

use from discord.ext import commands

slender lintel
#

thanks

forest saffron
#

hi i need help with a problem.
i have a button which should send a message to another guild channel.
but i dont know how to access the bot object (button is placed in a cog file) in the button class

half marsh
forest saffron
half marsh
#
class cogs(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

Then you can acces the bot within cog class

#

You can also do the same on button class

forest saffron
#

and it said that this class has no attribute bot which is

#

weird?!

half marsh
#

How do you define your button? Subclassing or instancing?

forest saffron
#

hmm but if im adding the bot in the button as attribute i need to pass it if im calling the class right

half marsh
#

Yep

forest saffron
#

well imma try ty

snow citrus
dire cobalt
#

sooo my bot just decided to unregister all of its commands... I was working on one of the commands but not in any way that it would've unregistered all the commands from every cog. Now whenever I start it, it connects just fine and is able to send messages but when I enter / the bot doesn't even show up as having any options. Just wondering if anyone else is seeing this.

#

only thing I can think of is I added:
guild_ids=[<my server id>]
to the new command I was working on. Would that force a complete refresh for all of the bots commands?

dire cobalt
#

They came back after I kicked and re-joined the bot. Not really sure what that was all about.

humble talon
#

Is there anyway to see who's talking in a VC with a bot?

inner iris
#

If I defer my interaction and then send a followup message, is it possible to delete that followup message?

frank wadi
#
Traceback (most recent call last):
  File "c:\Users\darkm\OneDrive\Desktop\Skyler v1\bot.py", line 75, in <module>
    async def languageEU(ctx, test=None):
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 914, in decorator
    result = command(**kwargs)(func)
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1551, in decorator
    return cls(func, **attrs)
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 604, in __init__
    validate_chat_input_name(self.name)
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 1633, in validate_chat_input_name
    raise ValidationError(
discord.errors.ValidationError```
#

help? XD

gilded widget
#

code?

frank wadi
#
@client.slash_command()
async def languageEU(ctx, test=None):
    if ctx.author.guild_permissions.manage_messages:
        if test is None:
            test = "EU"
        db = sqlite3.connect('main.db')
        cur = db.cursor()
        cur.execute(f"SELECT languag FROM Language WHERE guild_id = {ctx.guild.id}")
        res = cur.fetchone()
        if res is None:
            sql = ("INSERT INTO Language(languag, guild_id) VALUES(?,?)")
            val = (test, ctx.guild.id)
            cur.execute(sql, val)
            embed = discord.Embed(description=f"![967333765431050250](https://cdn.discordapp.com/emojis/980832161114513458.webp?size=128 "967333765431050250") You successfully updated Lang to **English**", color=0x23d953)
            embed.set_author(name=f"{ctx.author.name}#{ctx.author.discriminator}", icon_url=ctx.author.avatar)
            await ctx.respond(embed=embed)
        elif res is not None:
            embed = discord.Embed(description=f"![967333765431050250](https://cdn.discordapp.com/emojis/980832161114513458.webp?size=128 "967333765431050250") You successfully updated Lang to **English**", color=0x23d953)
            embed.set_author(name=f"{ctx.author.name}#{ctx.author.discriminator}", icon_url=ctx.author.avatar)
            await ctx.respond(embed=embed)
            db.commit()
            db.close()
            return
    else:
        embed=discord.Embed(description="![928580897559707658](https://cdn.discordapp.com/emojis/979846982984151100.webp?size=128 "928580897559707658") you have no Permissions for this Command", color=0xa3281a)
        await ctx.respond(embed=embed, delete_after=10)   ````
gilded widget
#

i dont think you can have capitals in your command names

#

yeah you cant

frank wadi
#

what/

#

aa

#

oke

#

thanks

glad saffron
#

how do i get an "Options" menu like this in Pycord?

slender lintel
#

And you can do

#

async def func_name(ctx: first: Option(str, choices=[])):

glad saffron
#

ah, okay, thank you!

#

how would i set descriptions for the options?

slender lintel
#

str, β€œdescription in these quotation marks”, choices=[]

glad saffron
#

oh, i meant like uhhh

#

the descriptions on the side here

slender lintel
glad saffron
#

it shows up there

#

"fart"

slender lintel
#

O

#

Hmm

#

I’m not sure then

#

Currently at work if you still need help then I’ll look for it in the docs

glad saffron
#

ah ,okay

#

it's fine

leaden mesa
#

Thoughts on this error?

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/commands/core.py", line 126, in wrapped
    ret = await coro(arg)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/commands/core.py", line 856, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/runner/TESTENV-NFTDiscordBot/cogs/raffle_admin.py", line 57, in quick_setup
    await ctx.send_response(embed=em, view=view, ephemeral = True)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/interactions.py", line 665, in send_message
    payload["components"] = view.to_components()
TypeError: to_components() missing 1 required positional argument: 'self'
midnight cedar
#

you didn't initialize the view class

leaden mesa
#

omg