#discord-bots

1 messages · Page 331 of 1

shrewd apex
#

u can yeah

halcyon magnet
#

Idk if we should use a different cursor for every transaction

shrewd apex
#

how is it different? it returns the relevant cursor u can always close it manually or ignore it it gets cleaned up by gc automatically

#

both approaches are fine

halcyon magnet
#

gc means garbage collector? Right?

shrewd apex
#

yeah

final iron
final iron
#

aiosqlite doesn't support connection pools and won't, so you'll need to switch to asqlite

final iron
shrewd apex
drifting arrow
#

aiosqlite is fun, and easy to use, but apparently not ideal if your bot is seeing lots of action

#

😢

#

Anyway. Hi @final iron

shrewd apex
#

asyncpg op

loud junco
#
class MyBot(commands.Bot):
    
    async def setup_hook(self):
        self.db = await aiosqlite.connect("sqlite3 ep.db")

    async def execute(self, query, *args) -> aiosqlite.Cursor:
        cursor = await self.db.execute(query, args)
        await self.db.commit()
        return cursor
```am i missing some important details why is it still not working 😭😭😭
final iron
final iron
vale wing
vale wing
#

You defined a class a never used it

#

Your bot needs to be

bot = MyBot(...)
vale wing
#

Yeah what do you think you created class for

loud junco
#

ok i just saw what ive been doing
too blind fr 😭😭😭

loud junco
vale wing
#

Seems so

loud junco
#

cuz its still not working :D

#

did i overlooked something here

vale wing
#

This seems correct but what error do you get

loud junco
#

nothing

#

no error and im not using error handler

vale wing
# loud junco

Move code from async with bot to setup_hook method

restive salmon
loud junco
loud junco
final iron
#

Average aiosqlite experience

#

Use asqlite

#

It’s on GitHub

#

Aiosqlite doesn’t support connection pools so id highly recommend switching anyway

loud junco
vale wing
#

It will be bot.run

shrewd apex
midnight oracle
#

How do I make the the variable "name" obligatory here?

@app_commands.command(name = "newproject", description = "Create a new project")
async def newproject(self, interaction: discord.Interaction, name: str, description: str) -> None:
vale wing
vale wing
#

Pay attention that default value args go after args without default value

midnight oracle
#

that will make it obligatory?

#

or just prevents the command from error?

vale wing
#

If by obligatory you mean optional yes

midnight oracle
vale wing
#

You can't not give the argument, discord requires you to

midnight oracle
#

oh xd

#

thanks for the correction!

final iron
loud junco
shrewd apex
#

use the command to create like

sqlite3 name.db

u need to run it in bash or cmd

tepid dagger
#

did hydro switch to sqlite3 from the aoi thing

shrewd apex
tepid dagger
#

oh lol

#

why doesnt he just use the sqlite3 package

#

does aoi have more functionality

shrewd apex
#

not sure haven't used aoi before

#

i prefer postgresql

dreamy dune
loud junco
#

why is it so complicated i dont even know what to do now ;-;

vale wing
vale wing
#

It's in disnake but the only difference is setup is done in start instead of setup_hook

vale wing
shrewd apex
#

i see

vale wing
hasty pike
#

how can i put bot.wait_for in always running while loop? Like a event

fiery girder
#

now why am i getting this error i suppose

shrewd apex
fiery girder
#

bruh

fiery girder
#

i fking hate my life

#

i for () these

#

if a bot is offline will the button go timeout even if the timeout is set to none?

#

if yes is there a way to reactivate the button

shrewd apex
shrewd apex
fiery girder
hushed galleon
fiery girder
hushed galleon
#

the last part is the hard part

#

its further explained in the gist

fiery girder
#

so basically i just add the view in the bot on setup hook?

#

umm

#

being honest i still dont get it

hushed galleon
#

yes, by adding the view you're telling discord.py which components it can handle interactions from

fiery girder
#

ok well i added two of my views so lets test it

#

got this

hushed galleon
#

yeah, you have to instantiate your BanAppeal view

fiery girder
#

wait what if i have requirements to put into my view

hushed galleon
#

that's where it gets complicated, you have a "stateful" view

fiery girder
#

a what view

hushed galleon
#

stateful means you have state, i.e. parameters/variables stored in your view that need to be restored after the bot restarts

fiery girder
#

ah

#

but how i restore it thats the problem

hushed galleon
#

you have a database already, so that's where you'd want to store it

fiery girder
#

well i have a ticket that have diffrent views for different buttons so how do i do that

#

it need to have the user of the tickets who opened it to let it close it

hushed galleon
#

with difficulty

fiery girder
#

to make this more complicated i have an entire function as an input for my view so yea

hushed galleon
#

a table for each type of view might be enough (containing the message ID and parameters for each ticket view), but you have to also delete the corresponding row in those tables once the view is no longer useful

fiery girder
#

what about the function how can i take that in a db

hushed galleon
#

it should be serialized in some other way that makes it obvious which function you should use

fiery girder
#

sounds awful yea ill skip that

hushed galleon
#

if your views are too complicated to re-create, you'll have to simplify them so its easier to make them persistent

fiery girder
#

well

#

i have an idea

#

basically i am using the BanAppeal thing for a button i can just make a command that clears the channel and adds a new view everytime someone is banned so i dont have to do all the things

left mantle
#

Can someone help me finish this code please?

import discord
import requests
import os
from discord.ext import commands, tasks

bot = commands.Bot(command_prefix='!')

@bot.event
async def on_ready():
        print(f'We have logged in as {bot.user.name}')

@tasks.loop(minutes=15)
async def update_channel():
        tiktok_account = "octo_tech"
        follower_count = get_tiktok_follower_count(tiktok_account)

        guild_id = 1094273879482060911
        channel_id = 1177524750533267487

        guild = bot.get_guild(guild_id)
        channel = guild.get_channel(channel_id)
        await channel.edit(name=f'TikTok Followers: {follower_count}')

def get_tiktok_follower_count(account)


@bot.command(name='start')
async def start_update(ctx):
        update_channel.start()
        await ctx.send('Updating voice channel name based on TikTok followers!')

@bot.command(name='stop')
async def stop_update(ctx):
        update_channel.stop()
        await ctx.send('Stopped updating voice channel name.')

token = os.environ['TOKEN']
bot.run(token)```
fiery girder
#

what do you wanna do with this

#

well you need to finish the tiktok follower count rest is good i think

left mantle
#

yeah i don't know how to do it lol

#

it's just the def that i'm stuck on

fiery girder
#

well you need to use a api

shrewd apex
#

tiktok dosent have an api does it?

fiery girder
#

nope

#

not official theere are a few unofficials

shrewd apex
fiery girder
#

oh lol same find

fiery girder
left mantle
#

and how would i implement it?

slate swan
#

Look at the various APIs, none will help you

left mantle
slate swan
#

There are examples..

left mantle
#

yeah but i'd like direct help

slate swan
#

The examples are exactly what you need and we can't be more precise than a code example you can literally copy paste. We don't code for you. Use them. They even have a Discord server linked, use it.

#

Know that Discord bots are also not made for people that only know the basics.

acoustic kernel
#
async def override_autocomplete(interaction: discord.Interaction,current: str,) -> List[app_commands.Choice[str]]:
    keys_list = ['Budget', 'Bob', 'Income']
    
    return [
        app_commands.Choice(name=stat, value=stat)
        for stat in keys_list if current in stat
    ]


@bot.tree.command(name="override", description="Overwrites a player's stats")
@app_commands.describe(player="Who do you want to override", stat="What do you want to override", override_value="What do you want to set the override to")
@app_commands.autocomplete(stat=override_autocomplete)
async def override(interaction: discord.Interaction, player: str, stat: str, override_value: str):
#

Can someone help, I dont know why this auto complete isnt working.

shrewd apex
#

it should work dont see anything wrong tbh did u enter something in the autocomplete option to test?

shrewd apex
shrewd apex
#

what did u enter?

acoustic kernel
#

B

#

Bud

shrewd apex
#

thats weird

#

can u add a print statement to check if autocomplete is being called

shrewd apex
#

so make sure u check for the correct param

acoustic kernel
#

Yes stat is what I assigned it to

acoustic kernel
shrewd apex
#

no when typing B wait for a sec or two does no options pop up?

acoustic kernel
#

Nothin shows up

shrewd apex
#

also add a print statement in the autocomplete function to see of its being triggered

acoustic kernel
#

omg i gotta be the dumbest guy alive

shrewd apex
#

if this format dosent work u can try registering the autocomplete in the following manner

@override.autocomplete("stat")
shrewd apex
acoustic kernel
#

I fixed it, I have two bots running with the same code, but one didnt have the autocomplete and I kept using that bots command instead of the other one

shrewd apex
#

bruh

acoustic kernel
#

yeah

#

🤦🏻‍♂️

#

thanks for the help though.

fiery girder
#

download it in thorght the vscode terminal

#

or just install it on the folder you are working on

shrewd apex
#

ur running the code using python 3.11 u installed requests in python 3.12

final iron
#

You should also download Python from the actual website instead of the Microsoft store version

acoustic kernel
#

How can I create a command that creates a private channel between to players?

Id like the input to be a mention and it creates a chat between the player who ran the command and the mentioned player.

#
@bot.tree.command(name="diplomatic",description="Allows players to create a private chat with someone.")
async def diplomatic(interaction: discord.Interaction, player: str):
    user_name = await id_to_username(player)  # Assuming id_to_username takes an ID
    user = interaction.guild.get_member(interaction.user.name)

    # Create category if it doesn't exist
    category_name = "Diplomatic"
    category = discord.utils.get(interaction.guild.categories, name=category_name)
    print(category)
    if category is None:
        category = await interaction.guild.create_category(category_name)

    # Create a private channel for the mentioned members
    overwrites = {
        interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
        user: discord.PermissionOverwrite(read_messages=True),
        user_name: discord.PermissionOverwrite(read_messages=True),
    }

    channel_name = f'{user}-{player}'
    await interaction.guild.create_text_channel(name=channel_name,category=category_name)

    await interaction.response.send_message(f"Created channel {channel_name}")

This is what I have so far

winter coral
#

If I have a discord modal, is there a way to provide custom validation, or is it just a "something was incorrect, report and send a new modal" kinda situation?

winged garden
#

nothing beyond min/max length and (un)required

#

you'll have to send new modal

final iron
#

This is kinda just reinventing the wheel

acoustic kernel
#

yeah but i need admins to see it to

final iron
#

What problem are you facing

slate swan
#

me when people want to create the most privacy invading bot

final iron
#

Creating a new channel every time is going to severely limit the server and bot anyway

slate swan
#

yeah that as well

final iron
#

Hence, direct messages

torn sail
#

If i didn't use a gateway connection and instead i used http interactions would i still be able to get vc events?

torn sail
#

and im wondering if vc events would come through there

final iron
torn sail
#

right but i could use vc's without the main gateway connection?

#

like the one that every other event comes through

slate swan
#

You will still connect to the normal gateway at least once

#

To send the voice state update event and its relevant payload

torn sail
#

oh ok

#

thanks

cinder tulip
#

guys i have noticed that bots that have been written with discord.js can now put their own status (not activity like watching, listening etc.). Did dpy got updated too or not? cause I can't find anything about it

final iron
hushed galleon
#

do you mean the "Set Custom Status" feature on your discord client? in dpy its known as CustomActivity

#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a custom activity from Discord.

x == y Checks if two activities are equal.

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

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
hushed galleon
final iron
#

Swear it's been supported for longer

slate swan
#

The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

#

is says i dont have python downloaded even though i do..?

final iron
slate swan
final iron
#

is says i dont have python downloaded
Doesn't say this anywhere

#

Prefix your command with py -m

slate swan
#

It says I don’t have it downloaded mb

final iron
slate swan
#

When I checked for python

#

It said that

final iron
#

Show that error

slate swan
final iron
#

Your original command

slate swan
final iron
#

try it and see

slate swan
#

yea that works

slate swan
#

Can anyone help me with my python?

#

my pip doesnt work and whenever i try to install something it says "python is not reconized"

#
'python' is not recognized as an internal or external command,
operable program or batch file.```
slate swan
#

just got a new pc and i cant install pip

final iron
slate swan
final iron
slate swan
#

ahh i see the issue

final iron
#

Use this to install it pip install -U --force-reinstall discord.py --extra-index-url https://abstractumbra.github.io/pip/

slate swan
cinder tulip
final iron
slate swan
halcyon magnet
#

I think if you get the latest Microsoft c++ build tools ,the error should go?

hardy geyser
#

anyone know this

halcyon magnet
#

Not a discord bot related question though

hardy geyser
halcyon magnet
#

Ye

hardy geyser
#

wahat

#

next

final iron
#

Also semi colons are bad practice

halcyon magnet
drifting arrow
#

Why does my bot not wait for the response?

        embed = await self.create_message_embed("Reason for the report?")
        await interaction.user.send(embed=embed)
        reason = (await self.client.wait_for('message')).content
        
        embed = await self.create_message_embed("Any evidence to provide? If so, provide it now, or type 'No'")
        await interaction.user.send(embed=embed)
        evidence = (await self.client.wait_for('message')).content
``` It sometimes does and sometimes doesnt
sick birch
midnight oracle
#

In this code (part of a Cog), I would like that when any of the buttons are pressed, they remove the original message sent by the NewProject class and send another one indicating whether the creation was accepted or denied. If possible, the interaction should be edited. Is that possible?

#
class ConfirmationButtonView(discord.ui.View):
    def __init__(self, timeout = None):
        super().__init__(timeout = timeout)
        self.value = None
        
    @discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
    async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction) -> None:
        self.value = True
        self.stop()
        
    @discord.ui.button(label = "Deny", style = discord.ButtonStyle.red)
    async def deny(self, button: discord.ui.Button, interaction: discord.Interaction) -> None:
        self.value = False
        self.stop()


class NewProject(commands.Cog):
    def __init__(self, bot: commands.Bot, config: dict) -> None:
        self.bot = bot
        self.category_id = config["categorys"][0]["id"]  
    

    @app_commands.command(name = "newproject", description = "Create a new project")
    @app_commands.describe(name = "Name of the project", description = "Description of the project")
    async def newproject(self, interaction: discord.Interaction, name: str, description: str, points: int) -> None:
        guild = interaction.guild
        
        questionEmbed = discord.Embed(title = "Alert ⚠", description = "A new project is about to be created with the following characteristics. Please check that everything is correct.", colour = discord.Colour.red())
        questionEmbed.add_field(name = "Name", value = name, inline = True)
        questionEmbed.add_field(name = 'Points', value = points, inline = True)
        questionEmbed.add_field(name = "Description", value = description, inline = False)
        questionEmbed.set_thumbnail(url = thumbail_url)
        questionEmbed.set_footer(text=f"Interaction time - {current_time}")
        
        #new_channel = await guild.create_text_channel(name = f"{name}", category = guild.get_channel(self.category_id))
        await interaction.response.send_message(embed = questionEmbed, view = ConfirmationButtonView(timeout = None))

hushed galleon
drifting arrow
#

man. I hate this. why did I decide i wanted to make a discordbot..

hushed galleon
#

btw (button, interaction) is the wrong order for the button callbacks, it should be (interaction, button)

midnight oracle
hushed galleon
hushed galleon
midnight oracle
#

I didn't knew that

#

Thanks!

hushed galleon
#

a generic confirm view is more useful if you find it really common to ask the user for confirmation in your commands

patent lark
#

Anyone know what could cause this?

sick birch
midnight oracle
#

ERROR - discord.ui.view : Ignoring exception in view <ConfirmationButtonView timeout=None children=2> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Confirm' emoji=None row=None> Traceback (most recent call last): File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/ui/view.py", line 427, in _scheduled_task await item.callback(interaction) File "/workspaces/AdeptusTeam-PyBot/cogs/newProject_Cog.py", line 15, in confirm await interaction.delete_original_response() File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/interactions.py", line 524, in delete_original_response await adapter.delete_original_interaction_response( File "/home/codespace/.python/current/lib/python3.10/site-packages/discord/webhook/async_.py", line 219, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook

hushed galleon
#

you didnt use it on the button's own interaction right?

midnight oracle
#
@discord.ui.button(label = "Confirm", style = discord.ButtonStyle.green)
    async def confirm(self,interaction: discord.Interaction, button: discord.ui.Button) -> None:
        await interaction.delete_original_response()
        #await interaction.response.send_message(f"Project is being created")
        self.value = True
        self.stop()
hushed galleon
#

once you respond to an interaction you can delete its response, so if you want to delete the command's response you need the command's interaction

#

in there you only have the button's interaction

midnight oracle
#

So, what if I use the self.value to check which button was pressed and then respond

hushed galleon
#

sure if you prefer that approach

midnight oracle
#

how would you do it?

#

0.o

hushed galleon
#

pass the command's interaction as an argument to the view's __init__, then reference it in the confirm/deny callback

#

normal object oriented programming stuff

midnight oracle
#

hm

#

let me try

midnight oracle
#

Thanks man!

drifting arrow
#

😄

dreamy dune
#

yep that is not how join works

#

!join

unkempt canyonBOT
#
Joining iterables

If you want to display a list (or some other iterable), you can write:

colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
    output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '

However, the separator is still added to the last element, and it is relatively slow.

A better solution is to use str.join.

colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'

An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.

integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
latent pier
#

Oh ok, thanks

opaque quarry
#

is there some problem with discord-py-slash-command library

#

always show this announcement although i tried to downgrade and upgrade

fiery girder
#

how to make discord menus where you can enter data

#

like this

blazing condor
#

i think this is what you're looking sure, but not 100% sure.

Modal

#

@fiery girder

hidden estuary
#

.

merry cliff
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

cloud dawn
#

Just post it here

#

If it takes 300 messages and it's Discord related you're allowed to post it here.

#

Large portion including myself don't want to take things to DM.

fiery girder
#

How to i make a Modal

#

and how can i call the Modal

hardy geyser
#
:/home/container$ if [[ -d .git ]] && [[ ${AUTO_UPDATE} == "1" ]]; then git pull; fi; if [[ ! -z ${PY_PACKAGES} ]]; then pip install -U --prefix .local ${PY_PACKAGES}; fi; if [[ -f /home/container/${REQUIREMENTS_FILE} ]]; then pip install -U --prefix .local -r ${REQUIREMENTS_FILE}; fi; /usr/local/bin/python ${PY_START_FLAGS} /home/container/${BOT_PY_FILE}
/usr/local/bin/python: can't open file '/home/container/bot.py': [Errno 2] No such file or directory
#

any one know to fix this

#

?

timber lotus
#

if i want a task to start when a cog is loaded, do i put the task in the class or above it?

hardy geyser
#

what

timber lotus
#

i have a task loop, right now in the cog class but for some reason its not getting starting, so im asknig if i have it in the wrong place

#

ohhhh i should probaly put this in the main......

shrewd apex
#

!d discord.ext.commands.Cog.cog_load

unkempt canyonBOT
#

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

A special method that is called when the cog gets loaded.

Subclasses must replace this if they want special asynchronous loading behaviour. Note that the `__init__` special method does not allow asynchronous code to run inside it, thus this is helpful for setting up code that needs to be asynchronous.

New in version 2.0.
shrewd apex
#

override it

timber lotus
#

ahhhh thank you!!!

fiery girder
fiery girder
timber lotus
#

hell yea thank you!! it worked!

fiery girder
#

np

#

My discord.ui.Select menu is not working can someone help it

final iron
fiery girder
#

wdym

#

it dont have a callback thing i have to enter

fiery girder
final iron
#

no

fiery girder
#

any docs or git?

final iron
#

You shouldn’t need an example for this

fiery girder
#

how do i set a callback

#

idk tbh

final iron
#

!d discord.ui.Select.callback

unkempt canyonBOT
#

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

The callback associated with this UI item.

This can be overridden by subclasses.
final iron
#

It’s an attribute. You set the value to your callback

fiery girder
final iron
#

no

#

on_select is your callback

fiery girder
#

ok got it

#

Select().callback

final iron
#

All these work arounds can just be avoided by using the select decorator

#

!d discord.ui.select

unkempt canyonBOT
#

@discord.ui.select(*, cls=discord.ui.select.Select[+ V], options=..., channel_types=..., placeholder=None, custom_id=..., min_values=1, max_values=1, disabled=False, default_values=..., row=None)```
A decorator that attaches a select menu to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction) you receive and the chosen select class.

To obtain the selected values inside the callback, you can use the `values` attribute of the chosen class in the callback. The list of values will depend on the type of select menu used. View the table below for more information.
fiery girder
#

i used the decorator but it didnt work for some reason

#

oh its small select

#

i used the big select as decorator

hardy geyser
#

dudw

fiery girder
final iron
unkempt canyonBOT
#

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

Responds to this interaction by sending a modal.
hardy geyser
#

how to fix pip erro 🙂

fiery girder
#

show error

fiery girder
# final iron !d discord.InteractionResponse.send_modal
iscord.ui.view Ignoring exception in view <EmbedBuilderView timeout=None children=3> for item <Select placeholder='Select to Edit The Embed' min_values=1 max_values=1 disabled=False options=[<SelectOption label='Title/Description' value='title/description' description='Change the title and description of the embed!' emoji=None default=False>, <SelectOption label='Footer' value='footer' description='Change the footer of the embed!' emoji=None default=False>, <SelectOption label='Author' value='author' description='Change the author of the embed!' emoji=None default=False>, <SelectOption label='Image' value='image' description='Change the image of the embed!' emoji=None default=False>, <SelectOption label='Thumbnail' value='thumbnail' description='Change the thumbnail of the embed!' emoji=None default=False>, <SelectOption label='Add Field' value='addfield' description='Add a field to the embed!' emoji=None default=False>, <SelectOption label='Remove Field' value='removefield' description='Remove a field from the embed!' emoji=None default=False>]>
Traceback (most recent call last):
  File "C:\Users\abbas\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task
    await item.callback(interaction)
  File "d:\Projects\Python\FeXoBot\handlers\views.py", line 548, in on_select
    await InteractionResponse.send_modal(interaction, TitleDescription)
  File "C:\Users\abbas\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\interactions.py", line 963, in send_modal
    if self._response_type:
       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Interaction' object has no attribute '_response_type'
``` Got this
final iron
fiery girder
hardy geyser
final iron
hardy geyser
#
Python 3.12.1
:/home/container$ if [[ -d .git ]] && [[ ${AUTO_UPDATE} == "1" ]]; then git pull; fi; if [[ ! -z ${PY_PACKAGES} ]]; then pip install -U --prefix .local ${PY_PACKAGES}; fi; if [[ -f /home/container/${REQUIREMENTS_FILE} ]]; then pip install -U --prefix .local -r ${REQUIREMENTS_FILE}; fi; /usr/local/bin/python ${PY_START_FLAGS} /home/container/${BOT_PY_FILE}
#

trying to start

#

but not starting

fiery girder
#

this aint the error

hardy geyser
final iron
#

Take a screenshot of your terminal

hardy geyser
fiery girder
fiery girder
fiery girder
hardy geyser
#

bot.run

final iron
hardy geyser
fiery girder
# hardy geyser

if this is solarhosting you need to go into the settings and select the file you want to run instead of bot.py

fiery girder
hardy geyser
#

ha'

fiery girder
hardy geyser
#

🙂

hushed galleon
#

normally you reference it from an existing interaction, i.e. interaction.response.send_modal(MyModal(...))

fiery girder
#

oh

fiery girder
winged garden
#

no

fiery girder
#

well

hushed galleon
shrewd vapor
#

Hello

#
@commands.hybrid_command(name = "mute", description = "Mute a member")
    @commands.has_permissions(mute_members=True)
    @commands.guild_only()
    async def mute_user(self, ctx: commands.Context, member: discord.Member, seconds: int = 0, minutes: int = 0, hours: int = 0, days: int = 0, reason: str = None):
        if member == ctx.author:
            await ctx.send("You can't mute yourself")
            return
        if member == ctx.guild.owner:
            await ctx.send("You can't mute the owner")
            return
        if member.guild_permissions.administrator:
            await ctx.send("You can't mute an administrator")
            return
        if member.top_role >= ctx.guild.me.top_role:
            await ctx.send("You can't mute a member with a role higher than me")
            return
        if member.top_role >= ctx.author.top_role:
            await ctx.send("You can't mute a member with a role higher than you")
            return
        if seconds == 0 and minutes == 0 and hours == 0 and days == 0:
            await ctx.send("Please specify a time to mute")
            return
        duration = datetime.timedelta(seconds = seconds, minutes = minutes, hours = hours, days = days)
        await member.timeout(duration = duration, reason = reason)
        embed = discord.Embed(description = f"{member.mention} has been muted for {duration}", color = discord.Color.dark_purple())
        embed.set_author(name=f"{member.name} has been muted", icon_url=member.avatar)
        await ctx.send(embed=embed)```

I got error "You are missing Mute Members permission(s) to run this command."
#

but the permission is ok

final iron
#

mute_members isn’t a valid permission

shrewd vapor
#

Oh

#

timeout_members is valid ?

#

mute_members is in the doc

fiery girder
#

just use like hours

shrewd vapor
#

Because you can mute only 30 secondes or mute 7 days

fiery girder
#

just use minutes than

shrewd vapor
#

I don't think you want to calculate everythimes how many hours for 30 days

shrewd apex
#

make a custom convertor

fiery girder
#

you can use a converter to convert them into days hour min and stuff

fiery girder
#

like !mute @kazimabbas 20d

#

and make a converter to convert it

shrewd vapor
#

yes i know i need to make that, but before i want to fix the error

#

This is the first version of this command

fiery girder
#

i dont think you need the =True thing

#

wait nvm you do

fiery girder
shrewd vapor
#
Traceback (most recent call last):
  File "/home/container/main.py", line 9, in <module>
    from cogs.moderation import ModerationCog
  File "/home/container/cogs/moderation.py", line 5, in <module>
    class ModerationCog(commands.Cog):
  File "/home/container/cogs/moderation.py", line 96, in ModerationCog
    @commands.has_permissions(manage_members=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/ext/commands/core.py", line 2200, in has_permissions
    raise TypeError(f"Invalid permission(s): {', '.join(invalid)}")
TypeError: Invalid permission(s): manage_members```
fiery girder
#

can yo show the cod

shrewd apex
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.

Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions) similar to [`update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.update).
shrewd vapor
#

its not manage_members but moderate_members

fiery girder
#

you can add an if statement like

if not ctx.author.guild_permission.mute_members:
  await  ctx.reply("YOU DONT HAVE PERMS")
  return
fiery girder
shrewd vapor
#

working ty

#

is good now ? lol

shrewd vapor
#

download link for what ?

slate swan
shrewd vapor
slate swan
#

I mean.. if you can't download Python in the first place, making a discord bot is probably not the best idea as a beginner project, it's made for people with advanced knowledge with the language itself

shrewd vapor
#

i have really start to learn python with discord bot 3 years ago

slate swan
#

It's literally in the middle of your screen after searching for "python" and clicking the first link..

#

Will likely be a fun experience when you will face errors :)

outer violet
#

i use mac and i dont see the Install Certificates when i double click

#

nvm i see it

queen pond
#

how to get started with discord bots?

#

ik the basics for python

ember nest
#

what is the best discord library so far?

severe sonnet
#

okay so, how do i get advertisement for my bot?

#

i want to start earning money with my RP-Utilities bot

vapid parcel
#

How to do thinking=True in hybrid?

#

dpy

golden portal
#

Just use ctx.typing

vapid parcel
#

nah i got it

#
        await ctx.defer()
golden portal
#

that's equivalent but sure

outer violet
snow coral
#

pretty sure nextcord is better for slash commands

ember nest
ember nest
outer violet
#

More faster and lightweight, has a lot more command handlers to choose from, and gives you more control over the bot imo

#

It’s powerful unlike dpy since that is extremely beginner friendly

final iron
outer violet
#

hikari-lightbulb, hikari-tanjun, hikari-crescent, (very new) hikari-arc

final iron
#

and how is that a benefit?

#

You have a variety to choose from, but how is that actually beneficial for the end user?

outer violet
#

depends on the user but they can choose based on their preferred coding style and which one they like more

#

imo, i use hikari-lightbulb and i found that to be the easiest to switch from dpy to hikari, but each user can have a different preference

ember nest
#

so you're saying that hikari is kinda more professional?

#

since as u r saying

#

u say that dpy is more beginner friendly

outer violet
#

yes

ember nest
#

so like what's more professional about hikari

#

like I do got pretty good experience in python

outer violet
#

both libs are hard to use if you're just starting out with python

ember nest
#

2 years of python so I don't care if it's beginner friendly or not but I want the thing that is more professional and will make better bot using it

outer violet
#

whether hikari is more "professional" than dpy depends on the specific needs and preferences of the developer

#

hikari is modern and asynchronous with high-performance. dpy is also async and might be considered more "pythonic" and follows the principles of the discord api closely, its also very easy to use and understand

#

hikari has a smaller community but the devs are active and respond. the docs might be hard to comprehend for a new user, but youll get the hang of it. obviously, dpy is way larger and has easier docs

#

hikari is more flexible, you get more control over your bot and you can again choose a command handler that you prefer. dpy is less modular than hikari and might be seen as simpler for other developers

ember nest
#

I'm mostly planning to make a public bot to be honest such as probot etc so like I want it to be professional with a big database it will be mostly for moderation plus things like (ticket system, level system, economy system) so yeah I want to make sure that what I'm going with will be able to give me a good results for a public bot

outer violet
#

a lot of people have big bots with hikari

halcyon magnet
#

Hi

outer violet
#

but it depends on your specific needs of your bot, but i would recommend hikari over anything else

queen pond
#

how execly do u get paid from discord bots(if you own them)

halcyon magnet
#

Discord doesn't pay you ,you have add some premium features and earn from it maybe?

ember nest
final iron
#

discord.py has had a 7 year lifespan, and covers the entirety of the API

final iron
timber lotus
#

to do a countdown timer, do i just update the message with the correct time left or is there is like a built timer function or anything

final iron
outer violet
final iron
#

There’s just no objective reason on why hikari is better than discord.py

#

phrasing it as such is misleading

timber lotus
outer violet
final iron
outer violet
#

I also never stated anything about hikari being better than dpy lol
I stated some pros about hikari and why one would switch from dpy to hikari

final iron
#

“It’s powerful unlike dpy since that is extremely beginner friendly”

outer violet
#

Yeah

#

And anyone who uses hikari from dpy should know

final iron
#

In what way is it more powerful?

#

Choosing your command handler isn’t a reason lol

outer violet
#

Never said it was

#

Idk what you’re so pressed about

final iron
outer violet
#

Not gonna argue with someone who’s chronically online

final iron
#

You made an objective statement and are refusing to back it up

timber lotus
outer violet
#

No I just don’t want to argue with someone who’s chronically online. I stated the pros about hikari and why one would switch over, suggesting to the person who wants a new lib to learn and see if they want to go with hikari and you can’t seem to handle that

final iron
final iron
#

You’ll have to show an example

final iron
#

Ion even use large bots like dyno

#

Hate em all

sick birch
#

based

timber lotus
#

yea of course, how can i show what a bot does? want me to invite you to my server to see dyno?

sick birch
#

send a screenshot

timber lotus
#

ahh gotcha

final iron
#

Also keep in mind basing your features on large bots implementations isn’t a good idea as they have access to more lenient rate limits

final iron
#

😹

timber lotus
#

it does it for the last minute. up until the it says like 57 minutes left, etc..

sick birch
#

yeah that's a discord timestamp

final iron
#

Yup, those are discord timestamps

timber lotus
#

oh ok... thanks, ill go learn about discord timestamps hahah

sick birch
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
final iron
#

I have a gist for you

sick birch
#

here's a utility method to make it

final iron
#

One moment

sick birch
#

make sure the style is "R"

drifting arrow
#

Is it possible to have a command be both slash and text?
for example:
/reply
!reply

sick birch
#

but they're a bit more complex and have limitations so just be wary of that

final iron
drifting arrow
timber lotus
#

oh ok, im already usong datetime to figure out the end time

final iron
drifting arrow
#

discordpy

#

the best one

sick birch
# drifting arrow What are the limitations?

text command parsing is a lot richer than slash commands, but like in many systems the chain is as weak as the weakest link, so your text commands are significantly nerfed so they're compatible with their slash command counterparts

final iron
#

Main one i can think of is autocomplete and choices

sick birch
#

ie no more greedy parsing or any sort of dynamic parsing. most of your converters are out too

final iron
#

They’ve severely limited with hybrid commands

timber lotus
drifting arrow
sick birch
golden portal
hushed galleon
timber lotus
drifting arrow
#

wait wait wait. nested group commands?!

drifting arrow
sick birch
timber lotus
final iron
drifting arrow
drifting arrow
#

and I've been straggling along here ignoring the advice of the pros for over 2 years now

#

Do as I don't and you'll be a pro in no time

#

Follow the pepp8 standards.

hushed galleon
final iron
#

ah

timber lotus
#

ok so ill just replace my current countdown stuff with epoch in the field and it will update according to the the format i choose? which would be relative time?

drifting arrow
#

So you dont need to worry about it being in the correct time format for everybody

#

it'll just translate it for you.

#

For example, if i convert my current machine time to epoch and use the discords time formatting, you might see it as 30/12/2023 whereas for me it's 31/12/2023 right now

#

#Australian

#

it might even put it as 12/30/2023

#

idk, i'm not american.

timber lotus
#

does that matter if its just countng down a duration? im already converting it to the um... i forget the name. the seconds since 1970 or something and thats how im saving in the database for end time or id have to change that to?

hushed galleon
drifting arrow
#

Are u posting the time to discord?

timber lotus
#

im not displaying the time, i want to display how much time until a specified duration is over. im doing a giveaway just dyno

#

and want to do a countown timer like dyno

final iron
#

<t:1703997900:R>

drifting arrow
final iron
timber lotus
final iron
#

Win some you lose some

drifting arrow
#

Yep

timber lotus
#

haha exactly

drifting arrow
#

If I was going to do a giveaway bot, I'd get a bit lazy.

I'd set up one of those looping thingies discordpy provides, have it check every minute once started (It starts off..)
When I do /giveaway X time, it will post an embed to the channel, turn loopy on, store time in database. if time.now() is equal to or greater than stored db time. the giveaway ends \o/

drifting arrow
#

I just want a hybrid command coz most support bots use !m to reply and I want to capitalize on that nonsense by also having !m 😄

timber lotus
#

yea i already have code for ending the giveaway, a check loop. it starts when the cogs loads but stops if returns no giveaways with current_time that hasnt passed the end time, has started and winner is null in teh database. the it gets called when the start button is pressed. i had the update countdown timer seperate, so i should put this in with the checks? im already saving the message_id, i assume i need that for it? or should i put this in my embed?

sick birch
#

no need to loop every minute, it's inaccurate

drifting arrow
#

O:

#

discordpy has sleep?! or were you thinking asyncio.sleep?

#

or are both the same?

hushed galleon
sick birch
#

discordpy has a sleep until until iirc

#

but you can also just use asyncio sleep

timber lotus
#

i was trying to use asyncio sleep to update the message

#

but kept getting rate limited and got me thinking i wasnt doing it efficiently

sick birch
#

subtract the target datetime from the current time, get seconds, pass into sleep

drifting arrow
# hushed galleon wait, bots need people to reply to a ticket with a command? seems a bit over com...

No. The ticket itself uses a command.

So to open a ticket, you DM a bot. answer all the fun questions.
A channel is made, you as the general user, cant see the ticket, but staff can. inside the ticket is private sensitive stuff the staff needs to address the ticket etc. but they can also discuss the issue.
The staff can then use a command to reply to the ticket (send a message to the user)
and if the user wants to reply, they dm the bot.

#

it's not my favorite way of doing a support ticket bot, but it's what the community likes/wants so it's what I'm catering to

sick birch
#

sounds a lot like @novel apex

drifting arrow
#

basically

timber lotus
#

so can i use any of this? or start over

drifting arrow
#

But i need modifications to it

sick birch
#

it's source code could serve as inspiration to you, perhaps

#

or you can modify it directly like we've done

drifting arrow
#

na it's fine. I've already made my own bot

#

it's not the greatest..

sick birch
#

Discord handles updating the time remaining on its own client side

hushed galleon
timber lotus
drifting arrow
hushed galleon
drifting arrow
timber lotus
sick birch
#

No worries

hushed galleon
# drifting arrow see 😄

how about using a message context menu to trigger a reply? they send their message as normal and then right click > apps > reply to ticket
imo it's still a worse experience than the prefix command, but better than a slash command

drifting arrow
#

I could just have the bot delete their original message, resend it, and attach buttons..

#

if the original author clicks the button it sends.

hushed galleon
#

alternatively pinging the bot as a prefix might be a reasonable solution, particularly if you were making a ticket bot that couldn't use the message content intent

drifting arrow
#

hhmm

hushed galleon
#

do all of them at once and see what your users prefer lemon_smirk

drifting arrow
#

OR

#

Alright. Hear me out.

#

Frick what they want. I do it my way 😄

sick birch
#

based

hardy geyser
#
 File "/home/container/main.py", line 567, in <module>
    bot.run(token, bot=False)
  File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 723, in run
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
                                 ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strip'
#

anyone know this server not starting

hushed galleon
hardy geyser
#

ohh

hushed galleon
#

!paste @slate swan you can paste your error message here

unkempt canyonBOT
#
Pasting large amounts of code

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

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

old vine
#
Ignoring exception in view <DropdownView timeout=None children=1> for item <Program placeholder='Choose a Program...' min_values=1 max_values=1 options=[<SelectOption label='IGCSE' value='IGCSE' description=None emoji=None default=False>, <SelectOption label='AS and A Level' value='AS and A Level' description=None emoji=None default=False>] disabled=False>:
Traceback (most recent call last):
  File "C:\Users\Kaushik\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 370, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\Kaushik\Documents\Programming\r-IGCSEBot Code\r-IGCSE-Beta\resources.py", line 136, in callback
    await interaction.response.edit_message(view = view)
  File "C:\Users\Kaushik\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 1063, in edit_message
    payload["components"] = view.to_components()
AttributeError: 'IGCSE' object has no attribute 'to_components'```
#

what is this error?

#

i am coding a dropdown list that works smth like this:
the user runs the /resources command
it shows the dropdown list with two options (IGCSE & ALEVEL)
when the user selects an option
it shows the subject group (Science, Mathematics , English and more)
when the user selects an option, it should edit the message to shows the subject links to a website

hushed galleon
#

the multidict dependency has no pre-built wheels for python 3.12 so pip is asking you to install c++ build tools in order to compile it

to fix it you can either downgrade to python 3.11 (easiest solution), or follow its recommendation to compile the package if you want to keep python 3.12

hushed galleon
old vine
#

this is my code, i have no previous knowledge on dropdowns.. can someone help me?

hushed galleon
#

in your case you can either put your ICGSE select class inside a view: py view = discord.ui.View(...) view.add_item(ICGSE()) or rewrite it as a view subclass using discord.py's decorator syntax, which you might find easier to read: ```py
class ICGSE(discord.ui.View):
@discord.ui.select(options=...)
async def subject_group(self, interaction: discord.Interaction, select: discord.ui.Select):
... # works the same as callback()

view = ICGSE()```

hushed galleon
#

so in discord.py, you can only send message components (buttons and select menus) by putting them inside a "view", an object that contains all the components for a message

hushed galleon
#

right now you've basically written await interaction.response.send_message(view=ICGSE()) which discord.py doesn't support because your ICGSE class inherits discord.ui.Select, not View

hushed galleon
#

so you need to either put your ICGSE select inside a view object which you can give to send_message(), or you can turn ICGSE into a view subclass where the select menu is already defined in the class, and then give that to send_message()

drifting arrow
#

Soo..

#

My pc crashed

#

Guess my stupidity caught up to me

#

But I’m back!

hushed galleon
#

fyi you've already been doing the first approach in your code, for example in the IGCSE callback you create a view and add your various buttons to it: py view = discord.ui.View(timeout=None) for subject in subreddits[group].keys(): view.add_item( discord.ui.Button(label=subject, ...)) await interaction.response.edit_message(view=view)

slate swan
#
import json
from discord import app_commands
from config import TOKEN
from discord.ext import commands

intents = discord.Intents.default()
intents.commands = True

bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
with open("config.json", "r+") as f:
    config = json.load(f)
    TOKEN = config["TOKEN"]

@bot.event
async def on_ready():
    print("bot is online")
    try:
        synced = await bot.tree.sync()
        print(f"Synced {len(synced)} commands")
    except Exception as e:
        print(e)


@bot.tree.command(name="test", description="just a test")
async def your_command(ctx):
    if discord.utils.get(ctx.author.roles, name="Whitelisted"):
        await ctx.send("Command executed successfully!")
    else:
        await ctx.send("You do not have the required role to execute this command.")

bot.run(TOKEN)```
#

why is this happening?

hardy geyser
#

helo

#

iam intsalled pip but no show anythink

#

anyone know this issue ?

#
:/home/container$ if [[ -d .git ]] && [[ ${AUTO_UPDATE} == "1" ]]; then git pull; fi; if [[ ! -z ${PY_PACKAGES} ]]; then pip install -U --prefix .local ${PY_PACKAGES}; fi; if [[ -f /home/container/${REQUIREMENTS_FILE} ]]; then pip install -U --prefix .local -r ${REQUIREMENTS_FILE}; fi; /usr/local/bin/python ${PY_START_FLAGS} /home/container/${BOT_PY_FILE}
Traceback (most recent call last):
  File "/home/container/main.py", line 1, in <module>
    import discord
ModuleNotFoundError: No module named 'discord'
drifting arrow
#

same for you @hardy geyser

hardy geyser
drifting arrow
#

whelp. idk man

#

Someone smarter than me will come along eventually

slate swan
golden portal
#

are you using python 3.12?

hushed galleon
slate swan
#

literally read one message above

slate swan
#

idk how to down grade python

naive briar
slate swan
slate swan
unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

slate swan
#

You'll have to search on your own

slate swan
karmic snow
#
from discord.ext import commands

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


@bot.event
async def on_ready():
  print('Ready')


@bot.command()
async def ping(ctx):
  latency = round(bot.latency * 1000)
  await ctx.send(f'Latency: {latency}ms')

bot.run('MTE5MD')```

No matter what i do i keep getting the same reponse:

```WARNING  discord.ext.commands.bot Privileged message content intent is missing, commands may not work as expected.```

Yes it logs in and stuff but it wont work the commands and i already have all the intents so i dont understand
slate swan
vale wing
#
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(..., intents=intents)
slate swan
#
from discord import app_commands
from discord.ext import commands

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

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

@bot.event
async def on_ready():
    print("bot is online")
    try:
        synced = await bot.tree.sync()
        print(f"Synced {len(synced)} commands")
    except Exception as e:
        print(e)



@bot.tree.command(name="whitelist", description="Whitelist a user!")
@app_commands.has_permissions(administrator=True)
async def whitelist(interaction: discord.Interaction, ctx: commands.Context, member: discord.Member):
    role_name = 'Whitelisted'

    role = discord.utils.get(ctx.guild.roles, name=role_name)
    if not role:
        await ctx.send(f"Error: The role '{role_name}' does not exist.")
        return
    
    await member.add_roles(role)
    await interaction.response.send_message(f"{member.mention} has been given the '{role_name}' role.")
#

line 22, in <module>
@app_commands.has_permissions(administrator=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'discord.app_commands' has no attribute 'has_permissions'. Did you mean: 'default_permissions'?

the error

dreamy dune
slate swan
# dreamy dune it's in app_commands.checks but you should use default_permissions as the error ...

@bot.tree.command(name="whitelist", description="Whitelist a user!")
@app_commands.default_permissions
async def whitelist(interaction: discord.Interaction, ctx: commands.Context, member: discord.Member):
role_name = 'Whitelisted'

role = discord.utils.get(ctx.guild.roles, name=role_name)
if not role:
    await ctx.send(f"Error: The role '{role_name}' does not exist.")
    return

await member.add_roles(role)
await interaction.response.send_message(f"{member.mention} has been given the '{role_name}' role.")
#

still get an error tho

dreamy dune
slate swan
dreamy dune
slate swan
#

So ()

#

Then permission

slate swan
# dreamy dune .

@bot.tree.command(name="whitelist", description="Whitelist a user!")
@app_commands.default_permissions(default_permission=True)
async def whitelist(interaction: discord.Interaction, ctx: commands.Context, member: discord.Member):
role_name = 'Whitelisted'

role = discord.utils.get(ctx.guild.roles, name=role_name)
if not role:
    await ctx.send(f"Error: The role '{role_name}' does not exist.")
    return

await member.add_roles(role)
await interaction.response.send_message(f"{member.mention} has been given the '{role_name}' role.")
#

says its not valid permission name what would i set it too

dreamy dune
#

same as before

slate swan
# dreamy dune .

line 887, in decorator
command = Command(
^^^^^^^^
File "C:\Users\RHG\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\app_commands\commands.py", line 666, in init
self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.globals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\RHG\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\app_commands\commands.py", line 374, in _extract_parameters_from_callback
param = annotation_to_parameter(resolved, parameter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\RHG\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\app_commands\transformers.py", line 834, in annotation_to_parameter
(inner, default, validate_default) = get_supported_annotation(annotation)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\RHG\AppData\Local\Programs\Python\Python312\Lib\site-packages\discord\app_commands\transformers.py", line 793, in get_supported_annotation
raise TypeError(f'unsupported type annotation {annotation!r}')
TypeError: unsupported type annotation <class 'discord.ext.commands.context.Context'>
PS C:\Users\RHG\Documents\Roblox Premium Scraper>

#

more errors /:

dreamy dune
#

you can't have command context in a slash command

molten tapir
#

hi

#

who have code for self bot join voice?

#

i want run 5 token or more

dreamy dune
blissful crane
#

can you priny event, birth and death and see what shows in the console

blissful crane
#

event not events, events is not defined

#

also, use the command then show me the console

fiery girder
#

i am in a big problem idk what to do

#
class RemoveFields(View):
    def __init__(self, message:Message):
        super().__init__(timeout=None)
        self.value = None
        self.message = message
        self.embed = message.embeds[0]
        self.fields = self.embed.fields
        self.options = []
        for i in range(len(self.fields)):
            self.options.append(SelectOption(label=self.fields[i].name, value=str(i)))

    @select(custom_id="remove_field", options=self.options, placeholder="Select a Field to Remove", min_values=1, max_values=1)
    async def on_select(self, interaction:Interaction, select:Select):
        selected = select.values[0]
        self.embed.remove_field(int(selected))
        await self.message.edit(embed=self.embed)
        await interaction.response.send_message(
            embed=Embed(
                title="Field Removed!",
                description="The field has been removed!",
                color=Color.green(),
            ),
            ephemeral=True,
        )```
#

i cant use self in here

#

how do i get the options

abstract imp
#

hello any help, the bot doesnt send the "hello" ```import discord
from discord.ext import commands
import json
import logging

logging.basicConfig(level=logging.INFO)

with open('config.json', 'r') as config_file:
config = json.load(config_file)

intents = discord.Intents.default()
intents.typing = False
intents.presences = False
bot = commands.Bot(command_prefix=config['prefix'], intents=intents, debug_log=True)

@bot.event
async def on_ready():
logging.info(f'{bot.user} has connected to discord')

@bot.event
async def on_message(ctx):
logging.info(f'Received message: {ctx.content} from {ctx.author} in {ctx.channel}.')
await bot.process_commands(ctx)

@bot.command(name='hello')
async def hello(ctx):
await ctx.send('Hello!')

bot.run(config['token'])```

slate swan
unkempt canyonBOT
#
Discord Message Content Intent

The Discord gateway only dispatches events you subscribe to, which you can configure by using "intents."

The message content intent is what determines if an app will receive the actual content of newly created messages. Without this intent, discord.py won't be able to detect prefix commands, so prefix commands won't respond.

Privileged intents, such as message content, have to be explicitly enabled from the Discord Developer Portal in addition to being enabled in the code:

intents = discord.Intents.default() # create a default Intents instance
intents.message_content = True # enable message content intents

bot = commands.Bot(command_prefix="!", intents=intents) # actually pass it into the constructor

For more information on intents, see /tag intents. If prefix commands are still not working, see /tag on-message-event.

timber lotus
#

how do i set sizes for buttons under an embed? i only have 2 so i want them to sit side by side and equal size. right now more letters = bigger button and not always side by side

vale wing
vale wing
slate swan
vale wing
#

Okay the last line is

#

Didn't actually read that first one was typing 💀

hardy geyser
#

how to use cmd without prefix

slate swan
#

set prefix to empty string

#

or if you want to use either with or without prefix

#

set prefix to tuple like this ("!", "") also i belive you have to put empty string last

#

other wise every prefix after it wouldnt work

#

or maybe not actually

#

doesnt matter rn

#

!d discord.ext.commands.Bot.command_prefix

unkempt canyonBOT
#

The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.

An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.

slate swan
#

its explained in the note

hardy geyser
#

thankz @slate swan 🙂

fiery girder
acoustic kernel
#
@app_commands.guild_only()
class Alliance(app_commands.Group):
    alliance_group = app_commands.Group(name="alliance", description="Allows you to manage your alliance")


    @alliance_group.command(name="create", description="Creates a new alliance.")

@alliance_group.command(name="add_player", description="Adds a player to the alliance.")


bot.tree.add_command(Alliance(name="Alliance"))

Can someone please assist, I want to make a group called alliances that has commands add_player and create. But right now the command comes up as /alliance alliance add_player

fiery girder
#

it should be

@app_command.Group(name="")
async def alliances(self, interaction)
acoustic kernel
#

ok how do I make the subcommands then?

fiery girder
#

i dont really know about the app_command if its diffrent but for hybrid commands it just

class Commands(Cog):
  @commands.hybridcommand_group(name="")
  async def afk
  @afk.command()
  async def list
severe sonnet
#

can anyone help? I have no idea how i will do this:
my plan is to allow people to create macros that are string commands created to the bot, for exaple:
##attack
it will roll 1d20 since inside ##attack there is the command:
!roll 1d20
being the ! the thing that will decide the command, if you want math it would be like
!math 2+2
and that would be inside a command with double # at the beggining, for example i can call it ##simplemath
my sintax to create the command is, having an input for command name and an input for the command string, for example:
/macro create ##attack "!roll (1d20+5)"
and i'm also planning to add if and else case, example:
/macro create ##attack "!echo (sucess) !if (!roll 1d20 > 10) !else (!echo (failure))"
so the bot will first make the roll to confirm if the randomizer got higher than 10 in roll 1d20, in failure it will output "failure", on sucess it will output "sucess"

#

like, it probably need some complex coding that i don't know

#

so i need someone experient to help me out on this

fiery girder
#
@commands.Cog.listener()
    async def on_message(self, message):
        checker = message.content
        if not checker.startswith("##"):
            return
``` this is useless this doesnt havea purpose if you dontplan on adding any
#

being honest i dont get what you are tring to do

severe sonnet
#

where are you missing?

fiery girder
#

but you are justing returning anyway to whats the point of check

severe sonnet
fiery girder
#

ok then its k

severe sonnet
#

like, if i already created ##attack for example

#

when i execute ##attack

#

it will roll 1d20 and return the result

fiery girder
#

the think i am understandign you are trying to do is you have user enter a string then you convert that string into there corresponding commands?

#

and run them accordingly

severe sonnet
#

yes

fiery girder
#

you can prob use a dictionary to do so

severe sonnet
#

uhmm, any examples?

fiery girder
#

wait a sec

severe sonnet
#

so i can copy the model?

#

oh, oki doki

fiery girder
#

!e


def attack():
    print("I am attacking!")    
def roll():
    print("I am rolling!")
def jump():
    print("I am jumping!")
def defend():
    print("I am defending!")

methods = {
    "attack": attack,
    "roll": roll,
    "jump": jump,
    "defend": defend
}

message = "attack jump defend roll"
for word in message.split():
    if word in methods:
        methods[word]()
#

you can link the word to a function

#

and rolle them in order

#

@severe sonnet

#

you can make 1000s of commands and just use this

severe sonnet
#

uhmm i see

#

method

fiery girder
#

!e


def attack():
    print("I am attacking!")    
def roll():
    print("I am rolling!")
def jump():
    print("I am jumping!")
def defend():
    print("I am defending!")

methods = {
    "attack": attack,
    "roll": roll,
    "jump": jump,
    "defend": defend
}

message = "attack defend roll jump"
for word in message.split():
    if word in methods:
        methods[word]()
unkempt canyonBOT
#

@fiery girder :white_check_mark: Your 3.12 eval job has completed with return code 0.

001 | I am attacking!
002 | I am defending!
003 | I am rolling!
004 | I am jumping!
fiery girder
#

you can even change the order and it will execute according ly @severe sonnet

earnest zephyr
#

can anyone help me?

#

any one???

severe sonnet
#

oh yeah, time ti implement

fiery girder
earnest zephyr
#

i’ll tell you in dms

fiery girder
severe sonnet
#

okay uhmm, how do i separate the contents of my string command?

#

i'm planning to either with !if and !else and without them

#

for example

#

!math (25+5) !if (!roll (1d20+5) > 15) !else (!math (-5+0))

#

so i want it to be separated like

#

["!if", ["!roll", "1d20+5", "> 5"],["!math", "25+5"], "!else", ["!math", "-5+0"]]

#

so the program will first make a check, then if true execute the 2 index, else it will return to else to execute the 4 index

#

or, to make it more organized

#

[["!if", ["!roll", "1d20+5", "> 5"],["!math", "25+5"]], ["!else", ["!math", "-5+0"]]]

#

now without if and else

#

!math 25+5

#

would be

#

["!math", "25+5"]

acoustic kernel
#

category = discord.utils.get(guild.categories, name=category_name)

``` How do I check to see is a category already exists?
fiery girder
fiery girder
fiery girder
#

if its like !math 2+2 !attack 5
you can just check which one of them returns a function and use the rest as the inputs

fiery girder
severe sonnet
severe sonnet
fiery girder
# severe sonnet uhmm, example?

!e

def math(a):
    print(a + a)
def attack(int):
    print(f"I am attacking {int}!")    
def roll(str):
    print(f"I am rolling {str}")
def jump(obj):
    print(f"I am jumping to {obj}!")
def defend(opponent):
    print(f"I am defending! against {opponent}")

methods = {
    "attack": attack,
    "roll": roll,
    "jump": jump,
    "defend": defend,
    "math": math
}

message = "math 2 attack 5 defend mike jump wall"
method = None
for word in message.split():
    if word in methods:
        method = methods[word]
    else:
        method(word)```
severe sonnet
#

cus using .split() gonna make it confuse to manage it

acoustic kernel
severe sonnet
fiery girder
fiery girder
#

!d discord.CategoryChannel

unkempt canyonBOT
#

class discord.CategoryChannel```
Represents a Discord channel category.

These are useful to group channels to logical compartments.

x == y Checks if two channels are equal.

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

hash(x) Returns the category’s hash.

str(x) Returns the category’s name.
severe sonnet
#

let me see a thing

fiery girder
severe sonnet
#

!e

cmdstr = "!math (2+5**2) !f (!roll (1d20) > 5) !else !math (5+2)"
cmdstr.split()
print(cmdstr)

unkempt canyonBOT
#

@severe sonnet :white_check_mark: Your 3.12 eval job has completed with return code 0.

!math (2+5**2) !f (!roll (1d20) > 5) !else !math (5+2)
fiery girder
#

now you can take !math for one comand and the brackets as a input

severe sonnet
#

!e

cmdstr = "!math (2+5**2) !f (!roll (1d20) > 5) !else !math (5+2)"
result = cmdstr.split()
print(result)
unkempt canyonBOT
#

@severe sonnet :white_check_mark: Your 3.12 eval job has completed with return code 0.

['!math', '(2+5**2)', '!f', '(!roll', '(1d20)', '>', '5)', '!else', '!math', '(5+2)']
severe sonnet
#

okay i'm starting to realize

fiery girder
#

you can easily remove ! from !math

severe sonnet
#

yeah though i'm planning to use ! as a command definitor

#

it's to make it easier for macro programmers create their macros

#

like a signalizer

fiery girder
#

yea you can do that

brazen geyser
#

hey guys, im making my suggestion system and its my first time working with Modals. can someone help me with this error please

#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

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

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

fiery girder
#

sure i have worked with models befor

final iron
#

Modals shouldn’t be added to views

brazen geyser
fiery girder
#

no like how you can sending them like in code

#

show code

brazen geyser
brazen geyser
final iron
#

You never called super().init on the Modal subclass

brazen geyser
#

i need to call it?

fiery girder
#

super().__init__()

#
class Footer(Modal):
    def __init__(self, message:Message):
        super().__init__(timeout=None, title="Footer Embed Builder", custom_id="footer")
        self.message = message
        self.value = None
    text = TextInput(label="Text",placeholder="Enter Your Text", min_length=1, max_length=25, row=0, required=False)
    icon_url = TextInput(placeholder="Enter The Icon URL", min_length=1, row=1, required=False, label="Icon URL")
    
    async def on_submit(self, interaction: Interaction):
        embed = self.message.embeds[0]
        embed.set_footer(text=self.text.value, icon_url=self.icon_url.value)
        await self.message.edit(embed=embed)
        await interaction.response.send_message(
            embed=Embed(
                title="Footer Set!",
                description="The footer has been set!",
                color=Color.green(),
            ),
            ephemeral=True,
        )``` EXAMPLE
brazen geyser
#

like this, right?

fiery girder
#

yes

brazen geyser
#

im still getting this

final iron
#

Does this error occur when submitting it

brazen geyser
#

yes

slate swan
#

I want to code a discord command that uses roblox api to find users with premium does anyone know how i could do this

final iron
brazen geyser
final iron
#

pip show discord

brazen geyser
slate swan
#

@final iron so i have a key system and i have the keys that are generated sent to a .txt in my files, I would want to create a command that can remove keys. Do you know how I could do this?

brazen geyser
slate swan
#
import uuid
from discord.ext import commands

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

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

yourrole = 'Whitelisted'
file_path = 'keys.txt'

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

@bot.command()
@commands.has_permissions(administrator=True)
async def gen(ctx, amount):
    key_amt = range(int(amount))
    f = open("keys.txt", "a")
    show_key = ''
    for x in key_amt:
        key = str(uuid.uuid4())
        show_key += "\n" + key
        f.write(key)
        f.write("\n")

    if len(str(show_key)) == 37:
        show_key = show_key.replace('\n', '')
        await ctx.send(f"Key: {show_key}")
        return 0
    if len(str(show_key)) > 37:
        await ctx.send(f"Keys: {show_key}")
    else:
        await ctx.send("Somthings wrong")

@gen.error
async def gen_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send(f"{ctx.author.mention}, you don't have the necessary permissions to run this command")

@bot.command()
async def redeem(ctx, key):
    if len(key) == 36:
        with open("used keys.txt") as f:
            if key in f.read():
                em = discord.Embed(color=0xff0000)
                em.add_field(name="Invalid Key", value="Inputed key has already been used!")
                await ctx.send(embed=em)
                return 0
        with open("keys.txt") as f:
            if key in f.read():
                role = discord.utils.get(ctx.guild.roles, name=yourrole)
                await ctx.author.add_roles(role)
                em = discord.Embed(color=0x008525)
                em.add_field(name="Key Redeemed", value="Key has now been redeemed")
                await ctx.send(embed=em)
                f = open("used keys.txt", "w")
                f.write(key)
                f.write('\n')
            else:
                em = discord.Embed(color=0xff0000)
                em.add_field(name="Invalid Key", value="Inputed key has already been used!")
                await ctx.send(embed=em)
    else:
        em = discord.Embed(color=0xff0000)
        em.add_field(name="Invalid Key", value="Inputed key has already been used!")
        await ctx.send(embed=em)

@bot.command()
@commands.has_permissions(administrator=True)
async def clear(ctx):
    try:
        with open(file_path, 'w') as file:
            file.write('')
        
        await ctx.send(f"The content of {file_path} has been cleared.")
    
    except Exception as e:
        await ctx.send(f"An error occurred: {e}")

@clear.error
async def clear_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send(f"{ctx.author.mention}, you don't have the necessary permissions to run this command")

@bot.event
async def on_message(message):
    if "http://" in message.content or "discord.gg" in message.content:
        if message.author.guild_permissions.manage_messages:
            await bot.process_commands(message)
        else:
            await message.delete()
            await message.channel.send(f"{message.author.mention}, you don't have permission to send HTTP links")```

commands wont work getting 0 errors
slate swan
#

outside of the if statements

finite salmon
#

You could instead use with open (...) as f: if you don't want to handle the closing of the file

slate swan
fiery girder
#

does while loops interfere with async def functions

slate swan
finite salmon
slate swan
vale wing
vale wing
slate swan
#

You probably want to check if the user doesn't have the manage messages permission and then delete the message and send your informational message.
And process_commands all the time, so outside of your if statement checking if http:// or discord.gg is in the message

vale wing
slate swan
#

с новым годом из России!!

languid sequoia
#

How can I make my bot speak with Text to Speech in a discord message?

vale wing
floral void
#

Hey ho

#

we have 2023 11:02 PM

#

Hey, is anyone familiar with Application commands

floral void
#

@slate swan yay, do you know how to translate messages sent into the channel?

slate swan
#

never made something like that unfortunately

#

but you would have to create a custom translator by
subclassing app_commands.Translator I guess

timber lotus
#

is there a way to make it so if a bot goes offline buttons still work when it comes back on?

#

buttons posted in an embed, for say, a giveaway haha

#

ahh i have to make the view persistant....

weary copper
#

I'm trying to make a discord bot by subclassing from commands.Bot, but maaaaan I'm getting every error under the sun

#

initial version example:

from discord.ext import commands
from discord import Intents
from dotenv import load_dotenv
import os


class MyBot(commands.Bot):
    def __init__(self, command_prefix, description, intents):
        super().__init__(
            command_prefix=command_prefix,
            description=description,
            intents=intents
        )
    
    async def on_ready(self):
        print(f"Logged in as {self.user}!")

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


load_dotenv()
TOKEN = os.environ["BOT_TEST_TOKEN"]

bot = MyBot(
    command_prefix="test/",
    description="Test Bot",
    intents=Intents.all()
)
bot.run(TOKEN)```
it runs, but as soon as I try to call the hello command (with `test/hello`) I can told hello doesn't exist as a command (`discord.ext.commands.errors.CommandNotFound: Command "hello" is not found`)
#

I then tried to manually register the command in __init__:

    def __init__(self, command_prefix, description, intents):
        super().__init__(
            command_prefix=command_prefix,
            description=description,
            intents=intents
        )
        self.add_command(self.hello)```
I then get `discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: MyBot.hello() missing 1 required positional argument: 'ctx` when trying to use the command. but ctx is literally in the function definition?!
timber lotus
#

im new to python and discord but pretty sure you need intents bro

#

intents = discord.Intents.all()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix="/", intents=intents)

weary copper
#

I have intents

timber lotus
#

ahh yea i dont recognize that. i copied mine from the docs

weary copper
#

Intents.all() is towards the bottom of the first block

#

it's weird because I never had issues with making bots by just defining functions

#

but I have had nothing but issues since trying to making a bot class

#

which makes me think I'm doing something wrong

timber lotus
#

and i had to use app_commands and then set the command up like this to get it into the slash command come up

#
@app_commands.command(name='channel-info',
                        description='Displays information about the channel or category'
                       )
  async def channel_info(self,
                         interaction: discord.Interaction):```
weary copper
#

hmm i'll try

timber lotus
#

from discord import app_commands

#

need that for app commands

#

or so i think. im new bro, im just saying what i had to do get the bot im working on to start getting the commands in the slash pop up

weary copper
#

ah yeah I'm just getting an argument error

#

and no worries, I appreciate you trying to help tho

barren gyro
#

Hello everyone! How are yall?

Quick question:

Does any body know how to work with cogs and stuff? I've been trying to work with it all day long and no matter what I do I can't get it working. :/

timber lotus
#

😆
i can tell you what i had to do haha

#

but read above, im new and this is my first bot

barren gyro
#

🥲 Okay.

timber lotus
#

i have 8 cogs in my bot

weary copper
# weary copper initial version example: ```py from discord.ext import commands from discord im...
from discord.ext import commands
from discord import Intents
from dotenv import load_dotenv
import os


load_dotenv()
TOKEN = os.environ["BOT_TEST_TOKEN"]


bot = commands.Bot(
    command_prefix="test/",
    description="Test Bot",
    intents=Intents.all()
)


async def on_ready(self):
    print(f"Logged in as {self.user}!")


@bot.command()
async def hello(ctx):
    await ctx.send("hello")


bot.run(TOKEN)```
this works perfectly fine for me ![PepeHands](https://cdn.discordapp.com/emojis/763301238615048202.webp?size=128 "PepeHands") but subclassing doesn't
weary copper
#

I kept getting async errors

timber lotus
#

haha i feel somewhat confident and createing and getting them to load

weary copper
#

i told myself I would come back to this tomorrow instead, but it's just been bugging me so much lol

#

i swear my bot was working last week when I last worked on it

barren gyro
weary copper
#

although my issue crops up even without cogs

weary copper
#

my code is literally exactly the same as everyone else's online, but my commands won't get added

weary copper
barren gyro
#

oh lol "doesn't exist as a command (discord.ext.commands.errors.CommandNotFound: Command "hello" is not found)" Thats exactly what it said to me.

weary copper
#

yep lmao

#

shrugFreg wish I could help

barren gyro
#

Its alr. Ima keep trying 🥲

timber lotus
timber lotus
weary copper
timber lotus
#

ohhh ok so i do that when i make a cog and then use stuff from that cog other places

barren gyro
#

Can't get it

#

To import, I was using:

async def load_extensions(bot): for filename in os.listdir('./cogs'): if filename.endswith(".py"): bot.load_extension(f"cogs.{filename[:-3]}")

and others wich I removed.

timber lotus
barren gyro
#

uh this one for example:

@bot.command(name="memes") async def memes(ctx: commands.Context): embed = discord.Embed( title="Error", description="This feature has been temporally removed by the bot Administrators.", color=discord.Color.red() ) await ctx.send(embed=embed)

barren gyro
timber lotus
#

!pastebin

unkempt canyonBOT
#
Pasting large amounts of code

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

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

timber lotus
timber lotus
barren gyro
#

Oh

#

It work- let me delete the cmds from the main file.

#

It doesn't for me. I must be doing something wrong.

timber lotus
#

use !pastebin and just share you whole code bro, 400 isnt alot haha

barren gyro
#

;-; k

timber lotus
# barren gyro Oh

did you see i messed and used the wrong interaction to send the embed?

barren gyro
#

YEa

barren gyro
#

!pastebin

unkempt canyonBOT
#
Pasting large amounts of code

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

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

barren gyro
#

Uh

#

It got removed.

timber lotus
#

the link did?

barren gyro
barren gyro
timber lotus
#

im not used to bot commands haha ive only used the app_commands

barren gyro
#

Oh

timber lotus
#

when you tried my way, was the cog file in a folder named cogs?

barren gyro
#

Yes.

timber lotus
#

dont know why, but it has to be haha

#

is there a reason why your using ! as your command prefix?

barren gyro
timber lotus
#

i thought / was standard

barren gyro
timber lotus
#

ah gotcha

barren gyro
timber lotus
#

i was just curious.

barren gyro
#

No worries. 😄

timber lotus
#

and dont want slash commands? thats what i used lol

#

didnt know there were different ones hahah

barren gyro
#

I think yea

timber lotus
#

ahhh oh yea i remember now

#

i wanted mine to show up in the discord pop up

#

let me see if i still have this webpage saved. it talked bot.load_extensions

barren gyro
barren gyro
#

`@bot.event
async def on_ready():
print('Bot is ready')
bot.activity = discord.activity.Game(name="! help")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} command(s)!")
except Exception as e:
print(e)
await bot.load_extension("cogs.Commands.py")

`

timber lotus
#

and dont think you have to "load" it if im understanding that page correctly... its news year eve,... been drinking and smoking haha

#

ahhh thats for the file not the main

timber lotus
#

so yea probably have to load in the main a way..

barren gyro
timber lotus
#

usually this group is popping hahaha kinda sad im your only resource jajaja

#

on the main should bot.add_command under on_ready

#

add_command is whatever the command name is

#

so it would me add_command(meme) for the one example you gabe

#

bot.add_command(meme)

barren gyro
#

ohh Makes kinda sence

timber lotus
#

that will be the same as whatever you have under async def setup(bot) in the file. now this isnt cog, so dont think it needs to be in a folder

#

dont forget to import it the file into the main

barren gyro
#

btw, the code you provided is giving 13 errors is that ok?

barren gyro
timber lotus
#

13 errors? haha um... probably not haha

barren gyro
#

Fixed it 😅

timber lotus
#

lol how???

barren gyro
#

It was not ordered correctly lol smh when I pasted it it din't paste the right way if that makes sence.

timber lotus
#

ahh the indents...

#

i dont know the different coding softwares but i use replit and their ai catches all of that

barren gyro
#

I feel I will give up, will have 1k+ lines of code 🥹

timber lotus
#

yea. its pretty great for simple stuff like that and it also generates code. great for beginers like myself because even if it dont work, it gives me a starting point or tells me which stuff to use, etc. and it hosts my bot. its cost money per month tho but not that much

timber lotus
barren gyro