#General Help

1 messages · Page 17 of 1

leaden mesa
#

missing brackets

#

thank you

#

I am dumb

clever lava
#

yo

#

how do i make bot generate timestamp codes

#

like this <t:1654916400:d>

#

an then i just replace like this

#
await ctx.respond(f"<t:{tmstp}:d>")
#

but how do i generate these codes

#

theres an api for this?

sudden path
#

Use the time module

slender lintel
#

?tag lp

hearty rainBOT
#
smoky path
#

Is there a way after reading a embed to send the same exact embed as an embed in a other Chat?

desert dagger
ornate fog
#

yea

smoky path
#

Yes

ornate fog
#

just grab the embed from message.embeds and send it into other channel

desert dagger
#

^

smoky path
#

I get this (if i read the embed)

desert dagger
#

would it be for every embed sent in that channel/server?

smoky path
#

Nah just for 1 Channel but i know how to filter out Channels

#

Is there a way to recreate the "to_dict()" to the orginal?

ornate fog
#

i think emebed has from dict

#

from_dict(data)

#

@smoky path

smoky path
#

Actually it is:
embed=discord.Embed.from_dict(THE_DICT))

#

@ornate fog Thanks mate, i have everything i need to work with now :)

desert dagger
#

I got a slash command that im using @commands.guild_only() on to make it only work in guild.
When someone tries to use the command in dms it'll throw:
discord.ext.commands.errors.NoPrivateMessage: This command cannot be used in private messages.

I want the slash command respond with something like "use command in a server please". This is in a cogs

#
@commands.Cog.listener('on_command_error')
@commands.Cog.listener('on_error')
async def on_command_error(ctx, error):

    if isinstance(error,discord.ext.commands.NoPrivateMessage):
        await ctx.respond('Command only works in server',ephemeral=True)

I tried this but this doesnt execute

sudden path
#

Slash commands throw on_application_command_error

#

@desert dagger

desert dagger
#

gotcha

slender lintel
#

top_role

#

?

#

d!help

#

d!help

#

d!rtfm top_role

#

wtf is it

#

?tag top_role

hearty rainBOT
#

dynoError No tag top_role found.

slender lintel
#

?rtfm top_role

desert dagger
#

b!rtfm pyc top_role

open bearBOT
desert dagger
#

@slender lintel

slender lintel
#

Hey, is it possible to remove the cooldown of a command for certain players?

analog elk
#

Is it possible to make the slash command name in of itself a slash command?

#

ie, if i have a slash command group where all the commands are /date XYZ, is it possible to make a command that is just /date?

#

that is part of that slash command group?

slender lintel
errant verge
#

is there a way to have more than 25 option choices?

slender lintel
errant verge
slender lintel
errant verge
#

can i also not have optionchoices defined inside of my command?

slender lintel
#

``

#
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 = 900
        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=embed)

def setup(client):
    client.add_cog(auto_mod(client)) 

so i have this right but uhh how can i check for multiple words

#

in sted of 1

#

i mean by this whats the best way?

pearl maple
#

././.,/.,/

red tendon
slender lintel
slender lintel
#
from discord.ext.commands import Cog

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

  @slash_command(name="verifyhelp", description="Sends bot ping")
  async def verifyhelp(self, ctx):
    await ctx.respond('If you are needing some help verifying with skykings, Heres some help! \n Use /verify hypixel then your username \n make sure to connect your discord account to hypixel ')
def setup(bot):
    bot.add_cog(tags(bot))``` Why do i get interaction slash command or smth
#

interaction failed slash command

#

nvm

wild jackal
#

Hi, I am trying to use the @tasks.loop decorator but the function never runs, and I'm not sure why

#
@tasks.loop(minutes=2)
    async def _gather_guilds_for_weekly_leaderboards(self):
        print("task loops yay")
        self.logger.info("Gathering guilds for weekly leaderboards")

This is my current setup and the print never prints (i have confirmed that my logger works)

ornate fog
#

Did you start it?

lilac jewel
#

default_member_permissions does not work with SlashCommandGroup.command

#

it does not hide the slash command

wild jackal
ornate fog
#

Nah

#

Task.start()

wild jackal
#

Thank you

slender lintel
#

ConnectionResetError: Cannot write to closing transport Why am i getting this error?

wild jackal
#

Are you able to provide any traceback?

slender lintel
slender lintel
# wild jackal Are you able to provide any traceback?
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 21, in on_ready
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name='Over The Felbcord'))
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 1179, in change_presence
    await self.ws.change_presence(activity=activity, status=status_str)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\gateway.py", line 667, in change_presence
    await self.send(sent)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\gateway.py", line 627, in send
    await self.socket.send_str(data)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\client_ws.py", line 150, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\http_websocket.py", line 687, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\http_websocket.py", line 598, in _send_frame      
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport```
ornate fog
#

dont do shit in on ready

slender lintel
ornate fog
#

Its only a chance to be getting disconnected

#

Set your status on construction tto send it with identify payload.

humble talon
slender lintel
#

alr, i moved it to the bot = part

humble talon
#

Should work now

half marsh
#

ok so my memory keep raising up, is that what memory leak mean? kek

humble talon
#

It might just be the cache and therefor not a memory leak

#

E.g. with each message, the client might store the message object and thus the memory rises

lucid cove
#

yo how do i add arguements / options in slash commands

#

i seen a video and they do from discord import Option

#

but that isnt a thing is it?

supple ravineBOT
#

Here's the slash options example.

worthy basin
#

@lucid cove look at this example and if you have more questions ask them here again :)

lucid cove
#

or can arguements be str only?

worthy basin
#

That is either a typo or the option takes an int and converts it to a string. I think it should be int tho

#

yeah it should be int

slender lintel
#

hey guys

#

how can i give a button a time limit to be clickeed

#

and to be clicked only by the command OP

cedar eagle
#

is the members property of a guild meant to return the entire list of members in a server? it seems like when I use it, it only returns the members that are relevant for the interaction, so the bot and the user that called it.

#

nevermind, found my issue. need the members intent

keen hamlet
#

how many maximum embeds can i send in a paginator's single message ?

craggy rapids
#

how to make a button unclickable?

snow citrus
#

disable it

craggy rapids
#

um how?

#

i know i can disable it but i forgot

#

@discord.ui.button(label="Grey", style=discord.ButtonStyle.grey, custom_id="persistent_view:grey",disable=True)?

snow citrus
#

yes

craggy rapids
#

okie

snow citrus
#

oh wait

#

actually disabled=True

craggy rapids
#

okie

fallen birch
#

Guys

#

I need a little help

#

Who knows NSFW libraries or api?

clever lava
#

we cant add more than 5 fields in modals

#

how do i solve that problem

#

i want more questions

crimson gale
#

api limitation. you cant do that

clever lava
#

hm

#

i tryed to add more options by doing a command option then send the modal but i cant link them

#

like for example

#

then it send's the modal with more options

#

my modal have the following options:

#

title, description, footer, color and thumbnail

#

for embed generator

slender lintel
#

how can i check the hierarchy to check if a user can ban another?

desert dagger
desert dagger
#

b!rtfm pyc highestRole

open bearBOT
desert dagger
#

b!rtfm roles.highest

open bearBOT
# desert dagger b!rtfm roles.highest

I couldn't find a documentation with the name roles.highest! 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 roles.highest

open bearBOT
desert dagger
#

hmm

#

gimme a sec

#

Basically:

  • grab author's roles

  • grab members role

  • You're grabbing the highest role. I believe this is the "first" thing in the list

  • However i think theres a rop role position
    Compare with guild.roles which returns a list of roles but instead the list is lowest to highest
    https://docs.pycord.dev/en/master/api.html#discord.Guild.roles

slender lintel
#

ah

#

okay lemme try.

ancient gazelle
#

Okay, needed some help. How do I reply to a slash command?

slender lintel
#

b!rtm pyc slash commands

#

Bru

#

@desert dagger will this work?

desert dagger
#

do you mean like. Run command, it waits for a response?

ancient gazelle
#

yes.

#

How do i respond?

desert dagger
#

In theory it should work

#

@ancient gazelle which one? i asked two questions XD

ancient gazelle
desert dagger
slender lintel
supple ravineBOT
#

Here's the slash basic example.

desert dagger
ancient gazelle
#

Yeah, just switched from discord.py @desert dagger So a bit to take on.

#

@slender lintel

slender lintel
#

Oh sorry

#

Hi I just wanna ask how do I make / commands public and global because my command rn ```py
servers = [977632897840349204, 981237860734742539]

@client.slash_command(guild_ids=servers, name='ping', description='Macht pong und zeigt die Verzögerung an!')
async def ping(ctx):
embed = discord.Embed(
title="Pong!",
description=
f"{round(client.latency * 1000)} ms Verzögerung :slight_smile:",
color=0xA020F0)
await ctx.respond(embed=embed)```

#

only work in 1 server

#

even tho i set to 2

desert dagger
#

well

#

dont use debug guild or guilds thingy in your bot = discord.Bot

slender lintel
#

^

desert dagger
#

debug_guilds in your Bot() means all commands you make are going to be ran only in that guild and that your slash command will "refresh" quicker since you're using it for debug purposes not production

#

guild_ids=[] is what you use to restrict command to guild.. I think the command works in dms?

slender lintel
#

Think so yeah

#

How would I make a hyperlink

slender lintel
#

So I should just remove this line

desert dagger
#

oh wait

slender lintel
#

Preferably a normal message

#

But if that's not possible I can use embed

desert dagger
#

[text](url here)

slender lintel
desert dagger
#

Normal messages are impossible sadly

slender lintel
#

ok lemme try

#

Okay

#

Thank you

desert dagger
#

its a Embed thing and must be done by a bot for obvious reasons

desert dagger
# slender lintel

basically remove all of your guild_ids or debug_guilds unless you want the command to be restricted to that guild

slender lintel
#

ok

desert dagger
#

That'd make your command a GLOBAL one

slender lintel
#

Just remove it all as 5heu said then if you want a certain command to be guild only add the guild I'd part to it

desert dagger
#

^^

slender lintel
#

btw sorry for bad spelling, was on phone and it was rly annoying auto correct

desert dagger
#

it happens

slender lintel
slender lintel
# desert dagger [text](url here)

Hey, ```import discord
from discord.commands import slash_command
from discord.ext.commands import Cog

class tags(Cog):
def init(self, bot):
self.bot = bot

@slash_command(name="tagverify", description="Sends bot ping")
async def tagverify(self, ctx):
embed=discord.Embed=(title='Verification Skykings', Description='You can use this Tutoiral to verify',color=discord.Color.blue())
await ctx.respond(embed=embed)
def setup(bot):
bot.add_cog(tags(bot))``` Why am i getting error, ( was not closed

#

btw the yt link is an unlisted video lol

slender lintel
slender lintel
slender lintel
#

💀

#

fixed

#

nice

desert dagger
#

also @commands.slash_command was gonna say you'd use it like this except you got the import

slender lintel
#

and the error is
( was not closed

desert dagger
#

i realised

#

ah i see

#

actually

#

embed=discord.Embed**=**(title='Verification Skykings', Description='You can use this Tutoiral to verify',color=discord.Color.blue())

slender lintel
#

yeah?

desert dagger
#

the = after Embed

#

doesnt rly seem needed

slender lintel
#

me reliasing ive broke this

#

1 sec

#

why tf did i type that same thing so many times lmao

desert dagger
#

lul

slender lintel
# desert dagger lul

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

Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event 
    await coro(*args, **kwargs)
  File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 31, in on_application_command_error
    raise error
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Embed.__init__() got an unexpected keyword argument 'Description'``` Why do i get this error? (same code but removed the bit i typed too much)
#

@slash_command(name="tagverify", description="Sends tutoiral")

#

thats right isnt it?

desert dagger
#

one sec

#
em= discord.Embed(title='Verification Skykings', 
description='You can use [this](https://youtu.be/ahUXZT5VyDY) Tutorial to verify',
color=discord.Color.blue())
ctx.respond(embed=em)

desert dagger
#

embed=embed doesnt workw ell

#

plus u dont do/need to discord.Embed = ()

slender lintel
#

Ive got it in another command tho

#

and its fine

#

(ive now changed the D to d)

slender lintel
smoky path
#

Hello, i wanted to create Options in my Slash command but for some reasons i'm getting this error at the start of the bot:
discord.errors.ExtensionFailed: Extension 'cogs.tests' raised an error: TypeError: object of type 'type' has no len()
CODE:

    @slash_command(description="check")
    async def checking(self, ctx, user:Option(discord.User, "User")):
        await ctx.respond(f'{user}',ephemeral=True)```
sudden path
desert dagger
#

as Dark said. A lot of this stuff is case sensitive

#

I usually avoid making my embeds be named embed but if you want to then fair. I prefer variables to mean something

desert dagger
# slender lintel Okay thanks

if your code gets bigger and you go "hey i want to find my embed for verification" you'd need to Ctrl F "embed" and scroll thru a ton of lines that use the word embed

#

whereas if you did "verificationEmbed" or "verify_embed" then you can find it quicker

midnight cedar
#

ctrl+f the command name smh

desert dagger
smoky path
desert dagger
smoky path
#

Traceback (most recent call last):
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 711, in _load_from_module_spec
spec.loader.exec_module(lib) # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "a:\dc bot\cogs\tests.py", line 6, in <module>
class TEST(commands.Cog):
File "a:\dc bot\cogs\tests.py", line 11, in TEST
async def checking(self, ctx, user:Option(discord.User, "User")):
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\optparse.py", line 570, in init
self._set_opt_strings(opts)
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\optparse.py", line 594, in _set_opt_strings
if len(opt) < 2:
TypeError: object of type 'type' has no len()

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

Traceback (most recent call last):
File "a:\dc bot\main.py", line 143, in <module>
bot.load_extension(f"cogs.{file[:-3]}")
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 783, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 714, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.tests' raised an error: TypeError: object of type 'type' has no len()

desert dagger
#

hm

smoky path
#

i'm using py- 2.0.0b7 btw

desert dagger
smoky path
#

rc1?

#

is this a differnt verison of pycord?

#

@desert dagger

desert dagger
#

pip install py-cord==2.0.0rc1

smoky path
#

lemme do that

desert dagger
#

also heres my example

#
import discord
from discord.ext import commands


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


    @commands.slash_command(description="check")
    async def checking(self,ctx, user: discord.Option(discord.User, "User")):
        await ctx.respond(f'{user}',ephemeral=True)

def setup(bot):
    bot.add_cog(Testing(bot))
#

i dont seem to get your len error from it

smoky path
desert dagger
#

well it looks liked you helped yourself out when u mentioned the version o7

smoky path
desert dagger
#

he just wanted to print out the user when checking

frigid lark
desert dagger
#

He was using one Version below rc1

smoky path
desert dagger
#

Mk

slender lintel
#

isnt it the same

#

is it used for user id or?

desert dagger
#

Member is User in guild

#

A Member is a User

slender lintel
#

Ohh alright

#

so for example if ur banning someone, you can use member to ban members outside of the server and member inside

desert dagger
#

discord.Member is probably the one you'd want to be ideally using

slender lintel
#

yeah

slender lintel
desert dagger
#

what client are you using

#

b!rtfm pyc fetch_message

open bearBOT
desert dagger
#

b!rtfm pyc channel

snow citrus
slender lintel
#

Hey, why he give me not the role? He send only the text..

class Info_start(discord.ui.View):
    @discord.ui.select(placeholder="🚢» Wähle eine Kategorie aus.", max_values=1, options=[
        discord.SelectOption(label=f"» Meine Pings", emoji="📌", description="Wähle deine Pings aus, die Du erhalten möchtest.",
                             value="<@&938419719671783424>")
    ])

    async def select_callback(self, select, interaction):
        if "» Meine Pings" in interaction.data["values"]:
            role = discord.utils.get(interaction.guild.roles, id=938419719671783424)
            await interaction.user.add_roles(role)

        a = interaction.data['values']
        await interaction.response.send_message(f"{', '.join(a)}")
smoky path
#

Is it possible to get every message a user send in a channel?

slender lintel
desert dagger
smoky path
slender lintel
#

so 1. ```@bot.event
async def on_message(message):
if bot.user.mentioned_in(message):
await message.channel.send('Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @tardy rune - my creator \n Join Felbcord here!')

@felbcord utils hi
@felbcord utils (this is what i want)
2. ```@slash_command(name = "nick", description = "Change nickname of a user")
  async def nick(self,ctx, member: discord.Member,*, name):
    if ctx.author.guild_permissions.administrator:
      await member.edit(nick= name)
      await ctx.respond(f"{member} has been nicked to {name}  :white_check_mark:", ephemeral=False)
    else:
        await ctx.respond("You do not have the correct permissions to do this", ephemeral=True)``` How would i allow this to change to 1  name every time?
#

@desert dagger

desert dagger
slender lintel
#

it still works fine, i just dont have it perfected to how i rly need it

smoky path
desert dagger
slender lintel
smoky path
desert dagger
#

i dont know ontop of my head but i think you need to loop fetch

smoky path
#

i want to make the bot do this

desert dagger
#

sorry. my brains not wanting to work rn xd

tidal beacon
#

hey does pycord have a listener for when people join a vc? I've been looking through the docs and can't find anything for it

snow citrus
#

yes, its event on_voice_state_update(member, before, after)

slender lintel
slender lintel
slender lintel
#

okay thanks

#

Can anyone help me pls? #985274218272935937

smoky path
#

How do i edit this? I used:
await msg.edit_orginal_message(content="Test")
and:
await msg.edit("Test")

sudden path
#

message = await ctx.interaction.original_message()

smoky path
sudden path
#

Edit

slender lintel
#

so i have this right but i wanna have it check all of the messgaes in bad_words

#

sorry for the bad words

#

them self

smoky path
# sudden path Edit

message = await ctx.respond('Loading...',ephemeral=True)
message = await ctx.interaction.original_message()
This does not work, am i doing something wrong?

slender lintel
#

i would remove if i could

smoky path
slender lintel
#

show code?

smoky path
slender lintel
#

oh

#

whats your problem exactly?

smoky path
#

not editing

#

I send error code wait

slender lintel
#

message = await ctx.interaction.original_message(message)

smoky path
#

Traceback (most recent call last):
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Interaction.original_message() takes 1 positional argument but 2 were given

slender lintel
#

that should work

#

try this

#

message = await ctx.interaction.original_message(message)

smoky path
#

ok

slender lintel
#

why do u have message = await ctx.interaction.original_message()

#

why is it in a varible

#

@smoky path

slender lintel
#

message = await ctx.respond('Loading...',ephemeral=True)
await ctx.interaction.original_message(message)

i think

#

1 sec

#

no

#

oh idk

#

then

#
interaction = await ctx.respond('Loading...',ephemeral=True)
message = await interaction.original_message()
await message.edit()
#

oh

smoky path
#

Lemme try

slender lintel
#

anyone know how i can check all the words in bad_word

#

excuse my words

#

lmao

slender lintel
slender lintel
#

i still dont understand

slender lintel
#

k

slender lintel
#

no

#

i wanna check all those messgaes

#

seperatly

#

sorta like and

#

thats what the for loop is for tho

#

no?

#

idk

#

lmao

slender lintel
# slender lintel k

So instead of giving it a nickname to change to, in the name part, I want it to just have the member section and it will change the nickname to a variable basicly

#

does that help?

#

so you want the nick name to be preset

slender lintel
#

@slender lintel do u know how i can do that tho

#

like have a name already set

#

yes

slender lintel
#

i alrdy have a for loops

#

how do i check all them

slender lintel
# slender lintel yes

so

@slash_command(name = "nick", description = "Change nickname of a user")
async def nick(self,ctx, member: discord.Member):
    name = "put name here?"
    if ctx.author.guild_permissions.administrator:
      await member.edit(nick= name)
      await ctx.respond(f"{member} has been nicked to {name}  :white_check_mark:", ephemeral=False)
    else:
        await ctx.respond("You do not have the correct permissions to do this", ephemeral=True)```
#

oh cant i juts use or

slender lintel
#

i get tho

#

its like it dont see it

slender lintel
# slender lintel

why need that when you are already looping through the entire list?

#

it checks every single word in the list

#

no it dont

#

just Shit

#

it dont check any other ones

#

uh...

#

S### it the element in the array

#

ik that

#

so S### == the first element then the 2nd element then the 3rd and so on

gilded widget
#

iterate through all elements in the list, if you find one in the message content, timeout and break the loop

#

shouldn't be too difficult?

slender lintel
#

idk

#

lol

#

i dont understand

#

@gilded widget

#

lol @slender lintel

#

wait

#

nvm

icy sluice
#

u don’t understand do u

#

lmao

slender lintel
#

lmfao

slender lintel
#

Hello @icy sluice

icy sluice
#

wtf

#

i can do it too 😉 @slender lintel

slender lintel
#

its so cool

icy sluice
#

lol

slender lintel
#

very useful for trolling

#

anyways gn everyone, thanks xout for the help (confirmation*)

fickle spruce
slender lintel
#

lmao the reaction

#

L

#
    @commands.Cog.listener()
    async def on_message(self, message):
        for word in filtered_words:
            if word in message.content:
                await message.delete()
                embed=discord.Embed(title="Bad word detected ❌", color=discord.Color.dark_gold())
                await message.channel.send(embed=embed)

i just did this

#

then created a list

#

with my words in it

smoky path
#

I was trying to get the inputs from day, month, year but i'm getting errors because of "discord.context" when i take discord.context away the bot would crash also
Traceback (most recent call last): File "a:\dc bot\main.py", line 143, in <module> bot.load_extension(f"cogs.{file[:-3]}") File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 787, in load_extension self._load_from_module_spec(spec, name) File "C:\Users\Klaro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 718, in _load_from_module_spec raise errors.ExtensionFailed(key, e) from e discord.errors.ExtensionFailed: Extension 'cogs.tests' raised an error: TypeError: issubclass() arg 1 must be a class

@commands.slash_command(description="check")
    async def checking(self, ctx,
                    user: discord.Option(discord.User, "User",required=True),
                    day: discord.Option(discord.context,"Tag",required=True),
                    month: discord.Option(discord.context,"Monat",required=True),
                    year: discord.Option(discord.context,"Jahr",required=True)):```
smoky path
#

I got it nvm

wicked swallow
#

So, you know how Discord.js has an easy way to send embeds? (Through objects)

Does Pycord have a simple way of sending embeds instead of updating embed values in each line?

crimson gale
#

you can chain the methods like in discord.js though?

clever lava
#

how do i use ctx.defer() properly

crimson gale
#

by using it at the very first line of the command callback

clever lava
#

nice

crimson gale
#

when the command in total takes more than 3 seconds to get a first response

clever lava
#

wait

#

can i control the time of defer?

crimson gale
#

15 minutes flat

#

no more no less

clever lava
#

how

crimson gale
#

you always get 15 minutes when you defer

clever lava
#

oh

#
@bot.slash_command(guild_ids=bwc)
async def defer(ctx):
  await ctx.defer()
  await ctx.respond("Test defer")
#

i think i didnt understood

#

i got a couple millisecconds

crimson gale
#

ctx.defer is what makes that "Bot is thinking..." message appear

clever lava
#

yes

#

ik

#

but i want to set the time this thing goes on

crimson gale
#

you cant change that it gives you 15 minutes to respond afterwards

#

go yell at discord

clever lava
#

oh

#

gotchu

slender lintel
#

Anyone know why this doesnt work

"bot.py", line 131, in on_message
    embed.set_footer(text=f'{message.author.name}', icon_url=f'{message.avatar_url}')
AttributeError: 'Message' object has no attribute 'avatar_url'```
gilded widget
#

message.author.avatar.url

slender lintel
#

how do i put a custom emoji in a embed?

warm jungle
#

how can i check if the slash command was sent in either dms or not

slow dome
warm jungle
#

im currently using this

slow dome
warm jungle
#

but it doesnt seem to work

slow dome
#

I think there is a ctx.guild as a shorthand

warm jungle
#

hmm

#

so then i just do a simple
if ctx.guild is None:

slow dome
#

yes

warm jungle
#

coolio

#

also do you know how to make a shash command just disabled in dm channels but not in actual channels? @slow dome

slow dome
#

@discord.guild_only()

#

I think is the decorator

warm jungle
smoky path
#

When i do a slash command and while the command is still going using the same command i get this error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

#

is there a way to fix taht

warm jungle
#

yea idk

#

i tried the parameter and it doesnt disable it

#

so might try both rq LMAO

slow dome
smoky path
#
@commands.slash_command(description="check")
    async def checking(self, ctx,user: discord.Option(discord.User, "User",required=True),day,month,year):
        if Info.COOLDOWN is False:
            Info.COOLDOWN = True
            interaction = await ctx.respond("Loading...", ephemeral=True)
            message = await interaction.original_message()
            t = f"{day}/{month}/{year}"
            did=time(t)
            Info.DATE = TimestampToDiscordID(did)
            Info.ID = user.id
            loop = asyncio.get_event_loop()
            loop.create_task(fast_interact(message,t))
        else:
            await ctx.respond(f"Dieser Command ist gerade im Cooldown. Du kannst ihn in {Info.SECOUNDS} wieder benutzen!", ephemeral=True)```
#

my code

warm jungle
#

yea no both @discord.guild_only() and guild_only parameter still doesnt disable the command from dm channels

#

also that implementation of if ctx.guild is None: also doesnt work

smoky path
#

@slow dome any ideas?

analog elk
#

Can you put two channelgroup decorators on a command to make that command part of those two channelgroups?

#

I want to have a few commands that have the same structure but do slightly different things and are in different channelgroups without writing redundant code

slender lintel
slow dome
#

?tag missing-access

hearty rainBOT
#

dynoError No tag missing-access found.

slow dome
#

?tag missing_access

hearty rainBOT
hearty rainBOT
#

dynoError No tag tryitandsee found.

slow dome
#

?tags t

hearty rainBOT
#
Tags (38)

youtube, virtualembed, vacant, tokens, timer, tias, tcr, tca, tags, tagrules, requests, replit, python, paste, objects, notpycord, nothingLMFAO, mybot, message-content, localization, learnpython, intents, install_slash, install_git, install, importerror, getalpha, get_x, exception, discord.Bot, client, buttons2, buttonlimit, bitwise, asset, applicationcommands-registration-delay, aiohttp, Timestamps

slow dome
#

?tag tias

hearty rainBOT
surreal lagoon
#

when using Context.send() , can I delete the message that initialized the command and then display the content of that message in the reference argument? When I try it it says it replies to a deleted message, which makes sense, but can I circumvent that somehow?

#

Can I create a new message object and pass that in there?

#

basically I'm trying to get the same effect as when using the slash command feature, but with traditional commands

steep verge
#

just use slash commands

surreal lagoon
#

no

#

actual answers to my question would be appreciated

inland acorn
surreal lagoon
inland acorn
surreal lagoon
#

Making a new message object doesn't work, does it? It has to be a message in a channel?

inland acorn
#

ig you can reply in same channel only

surreal lagoon
analog elk
#
        view = CountryApprovalView(timeout=None)
        approval_channel = io.load_approve_queue_channel(interaction.guild_id)

        if approval_channel:
            channel = await interaction.guild.fetch_channel(approval_channel)
            await channel.send(embed=embed, view=view)
            await interaction.response.send_message(f"Claim successfully added! An admin will approve you in <#{approval_channel}>.")

        else:
            await interaction.response.send_message(embed=embed, view=view)

        await view.wait()

        if view.approved:
            view.children[0].label = "Approved"
            view.children[0].disabled = True
            view.remove_item(view.children[1])

            await interaction.edit_original_message(f"<@{interaction.user.id}> has approved this claim!", view=view)
            await self._user.send(f"{self.children[0].value} has been approved in {interaction.guild.name}!")

            io.register_country()
            return

        view.children[1].label = "Denied"
        view.children[1].disabled = True
        view.remove_item(view.children[0])

        msgs = {
            "deny_msg": f"<@{interaction.user.id}> has denied this claim",
            "deny_dm": f"{self.children[0].value} has been denied in {interaction.guild.name}"
        }

        for k in msgs.keys():
            if view.reason:
                msgs[k] += f" for the following reason: {view.reason}"
            msgs[k] += "."
        
        await self._user.send(msgs["deny_dm"])
        print(msgs["deny_dm"])
        print(view)
        await interaction.edit_original_message(msgs["deny_dm"], view=view)

WHY DO I KEEP GETTING TypeError: Interaction.edit_original_message() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given

#

this is driving me insane

#

i only have two arguments in the function how could i possibly be passing in 2 positional arguments and 1 keyword-only argument

inland acorn
#

@analog elk try content=msgs["deny_dm"] in last line

analog elk
#

I figured it out

analog elk
#

the issue was that edit_original_message was responding to the wrong interaction

pearl maple
#

lol

craggy rapids
#

how to make a button that can only pressed by author?

analog elk
#

i THINK

#
author_id = 1234
if interaction.user.id == author_id:
  interaction.response.send_message("You are the author!")
else:
   interaction.response.send_message("You are not the author!")
#

i think this might work but i dont know, you should test it

#

with that being in the button callback function

craggy rapids
#

okie

pearl maple
#

hey just a question

#

is there anyway to delete a message that the bot has sent in a specific channel that is like 30m old?

pearl maple
#

!install

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
steep bluff
#

I have a check for @commands.check(), (how) can I provide a reason to be processed in the on_command_error handler?
Currently I am just sending a response from the check before return False with a pass in the on_command_error.

def level(*level):
    async def predicate(ctx:commands.Context) -> bool:
        if not ctx.guild:  # Return False in a DM
            await ctx.send("This command is only available in a server!")
            return False
        # some other checks
        return False
    return commands.check(predicate) 
crude rampart
#

Commands are not working

import discord
from discord.ext import commands

with open('token.txt','r',encoding='utf8') as tokenfile:
    token = tokenfile.read().strip()

bot = commands.Bot(prefix='.',intents=discord.Intents.all())

@bot.event
async def on_ready():
    pass

@bot.command()
async def test(ctx):
    print('test')
    #await ctx.reply(file='maxresdefault.jpeg')
bot.run(token)

when I type .test it does nothing

#

no output to console

slow dome
#

?tag message-content

hearty rainBOT
#

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

craggy rapids
#

btw does background task can block main task?

#

idk why but i think it does

#

i think i need thread it myself then

half marsh
inner iris
#

I have a message_command like this:

@commands.message_command(name="Edit Message")
async def edit_message(
    self, 
    ctx: discord.ApplicationContext, 
    message: discord.Message
):
    print(message)
    # do other stuff
```But when I try to use the command I get this error: `AttributeError: 'TextChannel' object has no attribute 'news'`.
Why?
slender lintel
#

it was this

inner iris
crude rampart
brittle sundial
#
    @commands.command()
    async def serverinfo(self, ctx):
      total = len(ctx.guild.members)
      humans = len(list(filter(lambda m: not m.bot, ctx.guild.members)))
      bots = len(list(filter(lambda m: m.bot, ctx.guild.members)))
      embed=discord.Embed(title='Server Info ', colour = discord.Color.from_rgb(0, 129, 193))
      embed.add_field(name='Server Name:', value=f'`{ctx.guild.name}`', inline=False)
      embed.add_field(name='Server ID:', value=f'`{ctx.guild.id}`', inline=False)
      embed.add_field(name='Owner:', value=f'`{ctx.guild.owner}`', inline=False)
      
      embed.add_field(name='Server Region:', value=f'`{ctx.guild.region}`', inline=False)
      embed.add_field(name='Server Creation Date:', value=f'`{ctx.guild.created_at.strftime("%A, %B %d %Y @ %H:%M:%S %p")}`', inline=False)
      embed.add_field(name='Text Channels:', value=f'`{len(ctx.guild.text_channels)} Text Channels`', inline=False)
      embed.add_field(name='Voice Channels:', value=f'`{len(ctx.guild.voice_channels)} Voice Channels`', inline=False)
      embed.add_field(name='Roles:', value=f'`{len(ctx.guild.roles)} Roles`', inline=False)
      embed.add_field(name='Total Members:', value=f'`{total} Members`', inline=False)
      embed.add_field(name='Humans:', value=f'`{humans} Humans`', inline=False)
      embed.add_field(name='Bots:', value=f'`{bots} Bots`', inline=False)
      embed.add_field(name='Boost Count:', value=f'`{ctx.guild.premium_subscription_count} Boosts`', inline=False)
      embed.set_footer(text=f'{ctx.guild.name}')
      embed.set_thumbnail(url=ctx.guild.icon_url)
      embed.timestamp = datetime.datetime.utcnow()
      await ctx.send(embed=embed)```
#

anything wrong in this code? coz the embed is not sending

lucid cove
#

too many fields i think

#

also

#

perms arent working with slash commands

#

for example

#
@bot.slash_command(name = 'deafen', description="Deafens a user for a specific amount of time")
@commands.has_permissions(mute_members = True)
@option("time", description="The amount of time to deafen the user for")
#

currently i have the administrator role but it returns an error

discord.ext.commands.errors.MissingPermissions: You are missing Mute Members permission(s) to run this command.
#

tried not giving admin

#

and instead just giving the mute_members perm

#

but still doesnt work

#

thrwos same error

slender lintel
#

Anyone know how to delete all messenges in one channel via the channel ID this is what I have right now

@bot.slash_command(guild_ids=[guild], name='nukeshops', description='Nukes all shops.')
async def nukeshops(
    ctx,
):
    if checkifroles(ctx) is True:
        server = bot.get_guild(int(guild))
        await ctx.respond('Nuking channels...', ephemeral=True)
        for channel in config['channel']:
            channell = server.get_member(int(channel))

            #delete all messenges in the channel via purge command
            await channell.clean()

    else:
        await ctx.respond('You are not an admin.', ephemeral=True)```
pearl maple
#

Ahh

pearl maple
#

Might fix it idk

#

Maybe

slender lintel
#

hi I want to know how to replace if message.content.startswith with cleint.command

pearl maple
#

Docs

slender lintel
dreamy herald
#

Can i get example of how to use auto complete please ?

#

i am okay with a basic example, i ll figure rest of the things

#

nvm found it

pearl maple
robust nebulaBOT
steep verge
pearl maple
#

Use purge

#

Lol

steep verge
#

And why are you using get_member if you’re trying to get a channel

pearl maple
#

Oh yea hes confusing

#

U take over lol

slender lintel
#
greetings = bot.create_group("greetings", "Greet people")```
#

where exactly do I put this, when using cogs?

#

in the __init__? on_ready?

slender lintel
#

could someone help me with slash cmd groups within cogs

supple ravineBOT
#

Here's the slash cog groups example.

worthy basin
#

If you have further questions fell free to ask :)

#

@foggy flax No, Do NOT have discord.py or discord installed as they will break pycord. Also please ask questions in this channel next time

foggy flax
#

my bad, just getting this after installing py-cord

worthy basin
#

try restarting pycharm, it gets mad when you uninstall d.py than install pycord for some reason

foggy flax
#

still didnt work, py-cord is not in pip list either

#

should I just install and run from cmd?

worthy basin
#

make sure you are in your venv when installing

foggy flax
#

ig their "Python Packages" Manager fixed it??? I dont know why

#

yet every other pip command worked

worthy basin
#

¯_(ツ)_/¯

slender lintel
#

To upload my bot to github, Is there a faster way than putting every file in the 'drag file section' like can i do anything in console

icy sluice
#

how do you make a random string

#

that is 6 letters / words long

worthy basin
desert dagger
slender lintel
#

ty

worthy basin
desert dagger
#

For me if i was experienced i'd be doing

  • git add -a
  • git commit -m "message"
  • git push
    which uploads everything
slender lintel
worthy basin
desert dagger
#

except we sorta diverged and became a library thats different.

slender lintel
#

Oh, So its a seperate language now? or

desert dagger
desert dagger
worthy basin
slender lintel
#

alright

desert dagger
#

but theres a lot of similarities

worthy basin
desert dagger
#

A discord server im in wanted me to use a bot from github and it was in D.py and with a few changes it seemed to work smoothly

worthy basin
# icy sluice how do you make a random string

make a list with all of the letters for example
letters = "a b c".split(" ")
than use random

import random
random_letter = random.choice(letters)

that chooses a random letter from the list

worthy basin
desert dagger
#
import random
import string

x= string.ascii_letters
num = 15 # lenght of letters
print ( ''.join(random.choice(x) for i in range(num)) )
#

another way if you want @icy sluice
Ice's method will just do letters but this one will let you control length and so on

worthy basin
#

yours does upercase and !@#$%... right?

desert dagger
#

yeah

#

you can easily add use ascii_lowercase or ascii_uppercase

desert dagger
#

cause i know bridge doesnt work in cogs

#

If not would it just be better to call the "cog"/function into the bridge command and pass args

supple ravineBOT
#

Here's the slash basic example.

half marsh
desert dagger
slender lintel
desert dagger
#

mhm

desert dagger
#

venv is a virtual enviroment

#

instead of installing python packages globally i prefer creating virtual environments so only one project uses it

slender lintel
#

a;r

#

alr*

desert dagger
#

Really useful if you need specific versions of a python package but need other versions in other projects/globally

half marsh
desert dagger
#

oh so it does work?

half marsh
#

Ye

desert dagger
#

i swear a while ago people say they dont. Ig thats what happens when you dont keep up with all the new changes hahaha

#

thanks

foggy flax
#

anyone know why this is happening?

#

it is the right token is the issue

#

from discord dev portal

slender lintel
#

How do i update a github rep

slender lintel
foggy flax
#

Ive even reset it

slender lintel
foggy flax
#

oh

#

smart one

#

lets forget I ever did that ok?

#

ty!

slender lintel
#

xD

worthy basin
foggy flax
#

yea was just about to do that, ty for the tip!

#

got a few different vars that I cant show, wouldnt be too good for them to be leaked

worthy basin
#

Ye

slender lintel
#

does the normal subclassing help methord work for slash cmds?

slender lintel
worthy basin
worthy basin
slender lintel
slender lintel
#

but how to i update that to my git page

worthy basin
#

git commit
git push

slender lintel
worthy basin
# slender lintel ah, which edits?

I can't exactly remember :/
Personaly i think if you give a discription to all you your commands and option you don't need a help command becouse its all in the discord UI. Your choice tho

slender lintel
supple ravineBOT
#

Here's the slash basic example.

foggy flax
#

ignore

slender lintel
worthy basin
slender lintel
#

isnt it git commit -a?

worthy basin
foggy flax
#

Oh thats a thing

#

uh

#

uhhhh

worthy basin
slender lintel
#

alr

worthy basin
#

I dont sorry :/

slender lintel
#

oof

desert dagger
#

git add . adds everything in the directory

desert dagger
#

git commit -m "Message" is what you need to do

example:

  • git add -A
  • git commit -m "Created bot"
  • git push
slender lintel
desert dagger
#

git status?

slender lintel
desert dagger
#

do git status

#

also i dont see u pushing

#

git push

slender lintel
desert dagger
#

check ur github

slender lintel
#

I have, I refreshed my page and git ignore and git attrubites still there

#

@desert dagger

desert dagger
#

??

#

wdym by that

#

are you trying to change ur git ignore on github?

slender lintel
desert dagger
#

whats showing?

#

how about you try to explain the issue completley

slender lintel
#

The two .git files i dont want showing

#

and i am explaining it completly

desert dagger
#

you cant ignore your .gitignore

#

obvious reasons why

slender lintel
#

What about the other one?

slender lintel
desert dagger
#

i dont think you can ignore gitattributes either

slender lintel
#

alr

desert dagger
#

u can delete it if u want but its there for a reason

slender lintel
#

What about pycord folder

slender lintel
desert dagger
#

whats in the pycord folder??

slender lintel
desert dagger
slender lintel
#

i added it at the very start whilst having no idea what i was doing lol

desert dagger
#

you can remove the pycord folder

#

its just wasting space

slender lintel
#

alright

slender lintel
desert dagger
#

git add -a
git status
git commit -m "removed pycord folder"
git push

desert dagger
#

oops

slender lintel
#

I tried -A instead of -a

desert dagger
#

-A

slender lintel
#

yeah

#

i checked the msg it said

#

Thanks

desert dagger
#

congrats

#

b!rtfm pyc role

spiral laurel
#

Something that is unclear to me is what the allowed actions are with a Interaction.response object after .defer() has been called on it.

I have a modal interaction callback which does the following:

  1. Compute some stuff.
  2. Store stuff in a database.
  3. Use interaction.resp to send a message or update an existing post.

Step #2 is normally instantaneous, but I've seen it fail once due to IO load on the host and I'd like to avoid that. Here is an example of my callback (much simplified).


    async def callback(self, interaction: discord.Interaction):

        resp = interaction.response  # type: discord.InteractionResponse

        await resp.defer(ephemeral=True)
        
        await self.doStuff(ctx)  # normally this is sub millisecond but could take longer...

        await resp.send_message('Did stuff', ephemeral=True)
    return

Attempting to call the send_message method raises an exception discord.errors.InteractionResponded: This interaction has already been responded to before. Is there an pycord example that shows the use of defer() ?

slender lintel
# desert dagger congrats

Btw, Is it possible to prevent logging into the console? (Its logging a bunch of server info to console when the bnot is online) It logs it to both discord.log and console, I want just discord.log (or none of the spam messages of server info) in attached image

desert dagger
#

just remove them

slender lintel
# desert dagger logging.log or print()
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)
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)``` where
desert dagger
#

do you want logging?

#

if not just remove it all

slender lintel
#

ook

slender lintel
#

@desert dagger

#

it takes time sometimes

#

for it to update on github

#

it wont always instantly update

#

oh okay

clever lava
#

how to make the bot delete his last message instead of the whole channel

slender lintel
#

github slow lol get betr

clever lava
#

ty

#
Traceback (most recent call last):
  File "C:\Users\Davi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\Davi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\Davi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'purge'

@slender lintel

#

bruh

slender lintel
#
  async def ping(self, ctx):
   if ctx.author.guild_permissions.administrator:
    await channel.clone()``` How would i get the channel the user is sending the message in?
desert dagger
desert dagger
slender lintel
# desert dagger ctx.channel.id
  async def ping(self, ctx):
   if ctx.author.guild_permissions.administrator:
    await discord.TextChannel.id()
    await channel.clone()``` channel is not defined?
#

@desert dagger

desert dagger
#

sigh

#

You should be cloning channel before deleting

#

b!rtfm pyc clone

desert dagger
#

b!rtfm pyc clone channel

open bearBOT
icy sluice
#

why’s this happening?

slender lintel
desert dagger
#

you are

#

just making sure u realise that

#

i dont get why ur trying to grab the channel id?

#

letme explain it better:

  • your /deleteAll command needs to be ran in the channel u want to delete
  • if thats the case then ctx.channel is all you need
slender lintel
#

I want to clone a channel and delete the orginal channel

slender lintel
desert dagger
#

await ctx.channel.clone()

#

await ctx.channel.close()

#

simple

#

b!rtfm pyc cooldown

desert dagger
#

maybe one of these?

icy sluice
desert dagger
slender lintel
desert dagger
#

says right there why its not working. indentation error

icy sluice
#
@commands.command(name="presence")
async def presence(ctx):
await bot.change_presence(activity = discord.Game(name=f"testing stuff"))
slender lintel
# desert dagger await ctx.channel.clone()
  async def deleteall(self, ctx):
   if ctx.author.guild_permissions.administrator:
    await ctx.channel.clone()```
error:
Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 852, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\jackd\Documents\Felbcord Py\commandss\deleteall.py", line 12, in deleteall
    await ctx.channel.clone()
TypeError: 'int' object is not callable

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

Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event 
    await coro(*args, **kwargs)
  File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 25, in on_application_command_error
    raise error
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: 'int' object is not callable
desert dagger
#

is that all of ur code

#

jack

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

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

  @slash_command(name="deleteall", description="Deletes every message in a channel")
  async def deleteall(self, ctx):
   if ctx.author.guild_permissions.administrator:
    await ctx.channel.clone()
def setup(bot):
    bot.add_cog(ClearAll(bot))```
desert dagger
desert dagger
#

code seems right ¯_(ツ)_/¯

icy sluice
#
  • I get no err
desert dagger
#

You sure the commands being ran?

icy sluice
#

well I’m running !presence nd I’m not getting my usual “Command not found." err so I’m pretty sure, yes

desert dagger
#

add a ctx.send('Ran') to double check

#

b!rtfm pyc change_presence

clever lava
#

guys please help

#
texturas = [["Grounded 16x",
"https://www.mediafire.com/file/2klfun5y76nop7o/%2521_%25C2%25A7f%25C2%25A7LGrounded_%25C2%25A72%25C2%25A7L%255B16x%255D%25C2%25A70.zip/file",
discord.File("grounded.png", filename="grounded.png")],
["Pan Fancy Pack 16x",
"https://www.mediafire.com/file/5eftx6ctv3o9ak6/%2521_%25C2%25A7a%25C2%25A7lPan_Fancy_Pack%25C2%25A7r_%255Bx16%255D_%25C2%25A7eR%25C2%25A7ce%25C2%25A7da%25C2%25A7bl%25C2%25A79i%25C2%25A7as%25C2%25A76t.zip/file",
discord.File("panqueko.png", filename="panqueko.png")]]

@bot.slash_command(guild_ids=testbot)
async def txt(ctx):

    rdm = random.choice(texturas)

    embed=discord.Embed(title=rdm[][0], description=None, color=discord.Color.blurple())
    embed.set_image(url=rdm[][2])
    
    button = Button(label="Download", emoji=":download:", url=rdm[][1])

    view = View(timeout=None)
    view.add_item(button)

    await ctx.respond(embed=embed view=view)
#

look

desert dagger
#
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)

chaze

slender lintel
#
async def on_message(message):
    if f"<@{bot.user.id}>" == message.content:
        Welcome=discord.Embed(title="Felbcord Utils",url="https://github.com/VividBlue1/Felbcord-Py/tree/discord",description="Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @ignfoolish#0396 - my creator \n Join Felbcord here!",color=discord.Color.blue())
        embed.set_author(name="FoolishBlue", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="Felbcord Py/Images/felb.jpg")
        await message.channel.send(embed=Welcome)``` Why do i get embed was not defined
desert dagger
#

capital sensitive probably?

clever lava
#

i want to the bot choose a random variable, but it bring it's values too

slender lintel
slender lintel
desert dagger
# slender lintel ```@bot.event async def on_message(message): if f"<@{bot.user.id}>" == messa...
@bot.event
async def on_message(message):
    if f"<@{bot.user.id}>" == message.content:
        Welcome=discord.Embed(title="Felbcord Utils",url="https://github.com/VividBlue1/Felbcord-Py/tree/discord",description="Hello! I am a personal slave bot who helps around moderating and providing fun into the felbcord! \n If you have any questions about me feel free to ask @ignfoolish#0396 - my creator \n Join Felbcord here!",color=discord.Color.blue())
        Welcome.set_author(name="FoolishBlue", url="https://github.com/VividBlue1/Felbcord-Py/tree/discord", icon_url="Felbcord Py/Images/felb.jpg")
        await message.channel.send(embed=Welcome)
slender lintel
#

ty

clever lava
#

variable = [["nest1 value1", "nest1 value2"] , ["nest2 value1", "nest2 value2"]]

rdm = random.choice(variable[#random nest][#preset value])
desert dagger
clever lava
#

i want to it randomize the nest but also choose a value of that nest

clever lava
#

but forget about it

slender lintel
#

How can i fix that?

clever lava
#

i have more importand commands to work on

#

anyways ty for help

clever lava
desert dagger
#

what do you mean

clever lava
#

oh

ancient gazelle
#

how can i use ctx.respond() so that only the user can see it?

clever lava
#

of course

clever lava
#

will make an drawing

desert dagger
desert dagger
slender lintel
#

ty

desert dagger
#

smh

icy sluice
#

well it’s in a cog, could that be a reason why?

desert dagger
#

probably?

icy sluice
#

I’ll try put it in my main file

slender lintel
#

bot.load_extension()

icy sluice
#

yep

#

doesn’t work in my main file either

slender lintel
#

Intents?

icy sluice
#

all enabled

slender lintel
#

Why dosent the image load? (I am using imgbb)

clever lava
#

@desert dagger

desert dagger
slender lintel
desert dagger
#

use the direct url

slender lintel
#

wym?

desert dagger
clever lava
#

variable = [["nest1 value1", "nest1 value2"] , ["nest2 value1", "nest2 value2"]]

rdm = random.choice(variable)

embed=discord.Embed(title=rdm[][0], description=rdm[][1])

await ctx.respond(embed=embed
brazen siren
#

How can I make it so that when I react, with a minimum of n reactions, to a message from a channel, a role is assigned to it? I do not control the clients

clever lava
#

something like that

icy sluice
#

what should the activity parameter look like?

desert dagger
clever lava
#

yes

#

but i dont want that

#

i want to the code choose between nest 1 and nest 2

desert dagger
#
import random
variable = [["1", "2"] , ["3", "4"]]

rdm = random.choice(variable)
print(rdm)

shows your code in an easier way

clever lava
#

if its nest 1 send nest1 value

#

it should'nt print everything inside the variable

desert dagger
#

so you basically want 1 or 2 to be chosen but if 2 is chosen then 4 is chosen?

clever lava
#

hm

#

almost there

#

ok will give you more examples

#

i want to make a minecraft texture randomizer

#

holdon

half marsh
#

Ok why dont you dictionary

vapid forge
#

Is there an example that shows the usage for deferring an interaction and following up on it?

half marsh
desert dagger
#

hm

#

b!rtfm pyc defer

desert dagger
#

I can see he makes the embed have the first array give a random value but then he hardwires the 2nd array

slender lintel
clever lava
#

@bot.slash_command(guild_ids=testbot)
async def test(ctx):
    
    #resource packs
    resourcepack = [["Pack 1 name", "Pack 1 download link", "Pack 1 preview image"], ["Pack 2 name", "Pack 2 download link", "Pack 2 preview image"]]
    
    # the pack that will be randomized
    rdm = random.choice(resourcepack)

    #title should be the name of the randomized pack, image should be it's preview image 
    embed=discord.Embed(title=rdm[][0], description=None, color=discord.Color.blurple())
    embed.set_image(url=rdm[][2])
    
    # url should be it's download link
    button = Button(label="Download", emoji=":download:", url=rdm[][1])

    view = View(timeout=None)
    view.add_item(button)

    await ctx.respond(embed=embed view=view)
#

that is what i want to do

desert dagger
#

use a dictionary and array

clever lava
#

um

#

can you give me an example

#

oh yes you're typing

desert dagger
#
import random
pack1 = {'name': 'pack name1', 'url': 'download_link', 'preview_imge': 'link.png'}
pack2 = {'name': 'pack name2', 'url': 'download_link', 'preview_imge': 'link.png'}
pack3 = {'name': 'pack name3', 'url': 'download_link', 'preview_imge': 'link.png'}
resourcepacks = [pack1, pack2, pack3]
rdm = random.choice(resourcepacks)
print(rdm['name'])

clever lava
#

oh

#

HMMM

desert dagger
#

pack1 is a dictionary.
resourcepacks is an array containing your dictionaries

#

rdm chooses a dictionary from array at random and you can use rdm[] to retrieve the values

clever lava
#

yo

#

tysm

desert dagger
#

you should try to learn more python if you wasnt rly aware of what a dictionary is

clever lava
#

yes

#

i have many things to learn

desert dagger
#

whats not updating

slender lintel
desert dagger
desert dagger
#

and ss it

slender lintel
desert dagger
slender lintel
desert dagger
#

hm

#

whats the issue?

#

i dont see any pycord folders

slender lintel
#

The main file is suppoosed to update too

desert dagger
#

it is?

slender lintel
#

It hasnt on my end? Is the logs bit there for you

slender lintel
#

how isnt it here for me?

desert dagger
#

refresh the page lmao

#

try ctrl f5 too 😂

slender lintel
slender lintel
desert dagger
#

well its updated on everyones end but urs

slender lintel
#

shrug at least its updated ig

slender lintel
#

ty

vapid forge
#

oh am dumb with_traceback() is a python function

#

Ok but I am still kind of confused how to get a traceback with on_application_command_error... it provides the exception but I can't figure out how to get the traceback from the excerption. So all I get is a one line error with no other info

icy sluice
brazen siren
#

Hi guys! How can I make it so that when I react, with a minimum of n reactions, to a message from a channel, a role is assigned to it? I do not control the clients

manic mist
#

i installed pycord and copied one of the examples on the github but it's telling me AttributeError: module 'discord' has no attribute 'Bot'

slender lintel
#

pip show py-cord

manic mist
#

1.7.3

slender lintel
#

outdated version

#

install this one

manic mist
#

i did the command it said and it still installs 1.7.3

slender lintel
#

do you have multiple python versions?

manic mist
#

idk i dont think so

#

it does keep telling me about not finding the microsoft store version tho

#

is installing it from python3 -m pip install -U py-cord --pre bad because that worked

solar berry
#

Is there a way to use converters inside the code of the function (rather than in the args of the command)?

analog elk
#

Can I make a view persistent for a view defined in the scope of a function?

obsidian garnet
#

One message removed from a suspended account.

#

One message removed from a suspended account.

icy sluice
slow dome
open bearBOT
# slow dome b!rtfm discord.Activity

I couldn't find a documentation with the name discord.activity! 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

slow dome
#

b!rtfm pyc discord.Activity

slow dome
#

it should have a type and a name

obsidian garnet
#

One message removed from a suspended account.

#

One message removed from a suspended account.

gilded widget
#

error is self explanatory, don't pass it with id=, just pass the ID without keyword

languid hollow
#

is it possible to do disable the button upon interaction and at the same time send a modal?

slender lintel
#

uh

#

why do you want to disable the bot?

languid hollow
#

button typo sorry

slender lintel
#

o

languid hollow
#

we did go in this previously but this time i want to know if I can do it since I can't do the time_out

slender lintel
#

maybe callback?

languid hollow
#
        async def button_callback(self,button,interaction):
            for child in self.children:
                if child.label == Flight_Authorisation[0][0]: pass

                else: child.style = discord.ButtonStyle.gray

                child.disabled = True
            
            Reason = Reasoning(self.children,title="Reasoning")
            await interaction.send_modal(Reason)
            await interaction.response.edit_message(view=self)
#

don't mind the indents

slender lintel
#

do you get an error from this?

languid hollow
#

lemme get the error

#
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before
#

i don't think i can do followup since those are for webhooks i believe

slender lintel
#

no no

#

followups create a webhook

languid hollow
#

oh

slender lintel
#

you can do a followup tho

languid hollow
#

so

#
await interaction.followup.send(...)
slender lintel
#

one sec reading docs

slender lintel
#

cause normally you send modals as
.send_modal(modal)
but there is no attributes of this in a webhook

languid hollow
#

I believe you can send interactions via followup?

slender lintel
#

and you can add buttons like that

#

ig you can try it

slender lintel
#

Idk how else to do it then sorry

languid hollow
#

Gmmm

#

lemme try if it can edit the view itself

#

since the interaction for the view is

  await interaction.something.edit(view=self)
slender lintel
#

gl

languid hollow
#

F the error

#
    await interaction.followup.edit(view=self)
TypeError: edit() got an unexpected keyword argument 'view'
#

wait

#

nvm i got the error