#discord-bots

1 messages · Page 349 of 1

viscid hornet
#

hows your day been tho

vapid parcel
#

just woke up 😭

#

So chilling ig, hbu?

viscid hornet
#

🇬🇧

#

HIS MESSAGE GOT DELETED 😭

vapid parcel
midnight oracle
#

pto internet

vapid parcel
#

nah thats wild

vapid parcel
midnight oracle
vapid parcel
#

But nah

#

isn't that regular Sqlite?

viscid hornet
#

what the fuck is ctx.respond

midnight oracle
#

This is a GitHub Codespace and I want to use that ffmpeg.exe I uploaded to manipulate the music/url I get from the yt-dlp for the bot but I don't know how to execute the ffmpeg file with the configs I already defined in a var from inside of the codespace

sick birch
unkempt canyonBOT
#

aiosqlite/core.py lines 102 to 109

while True:
    # Continues running until all queue items are processed,
    # even after connection is closed (so we can finalize all
    # futures)

    tx_item = self._tx.get()
    if tx_item is _STOP_RUNNING_SENTINEL:
        break```
vapid parcel
#

Who tf knows

vapid parcel
#

But he is using sqlite, a regular version of sqlite3, he should switch to asqlite or aiosqlite either works, but he should switch GoofySkull

viscid hornet
midnight oracle
#

subprocess?

vapid parcel
viscid hornet
vapid parcel
#

I think

viscid hornet
#

might be losing it

sick birch
#

you can't await stuff that are not awaitable

vapid parcel
#

Bro I am so confused rn, so tired. Maybe I am tripping 😭

viscid hornet
vapid parcel
#

I haven't used sqlite in ages so I think im just tripping atp

#

mb PIMP

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
midnight oracle
#

it is not violeting anyone's tos bc it's private not public, point 9...

slate swan
#

Its streaming music from YouTube. It is breaking point 9

midnight oracle
#

okay

dusk ermine
#

What do I do if "interaction" does not have attribute select?

slate swan
#

what you want to achieve?

sick birch
dusk ermine
#

I'm looking at and making a ticket system and it tells me that the interaction doesn't have a select attribute

mighty terrace
#

can i get the an emoji inside my code as a variable like a string or something ? as im trying it now it gets printed out like this

#

i need it as an id, string or something wich i can compare it with inside an if statement

shrewd apex
#

!pithink prefix the emoji with a \ to get its id if its a discord emoji if not u can just compare its unicode values

#

or as simple as emoji == '🙂'

chrome ivy
#

So, I'm trying to make a command only accessible by me to show all the servers that the bot is in. I've been trying to get it to work for a while, but it just doesn't want to work. Help is appreciated :)

My Code for this command:

@bot.command()
async def activeservers(ctx):
  if ctx.author.id == 770484893657333761:
    servers = bot.guilds(limit=None)
    embed = discord.Embed(title="Active Servers", description=f"There are currently **{len(servers)}** active! Here is a list of them:\n\n{servers}", colour=discord.Colour.random(seed=None))
    await ctx.reply(embed=embed)
  else:
    embed = discord.Embed(title="Error", description="You don't have permission to use this command!", colour=discord.Colour.red())
    await ctx.reply(embed=embed)
#

nvm, i got it to work :)

#

uhm

#

new problem, so im trying to add buttons to it that would allow me (and only me) to remove it from certain servers, along with it displaying the server ids (and in the buttom promt it would ask for the server id)

#

im using these, but im getting an error that its not a thing

from discord_components import Button
from discord_components import ActionRow
from discord_components import wait_for_button_click
merry cliff
#

have you tried discord.ui

viscid hornet
# vapid parcel I haven't used sqlite in ages so I think im just tripping atp

you’re the best person to tell for this bc i finally figured out how to make a “daily” command that rewards you with coins every day and even can even measure your streak, all with three columns:

  • a user_id column
  • a last_run column with the timestamp of when the user last ran that command
  • a streak column to see how many times they’ve run the command

here’s how it works:

  1. get the timestamp of last run
  2. calculate the time difference from when it was last run to when you can’t run it before
  3. if its negative, tell them they lost their streak and give a timestamp since they last run the command
  4. if the date of last run and the date they are running the command is the same, they’ve already run it today
  5. if the date of last turn and of the time running the command is different, its a new day and they can be rewarded with their coins
chrome ivy
vapid parcel
#

Thats easy to make, I have one in my bot lol

#

starts with 0, then continues from there lol

#

But thats cool, congrats on that!

viscid hornet
vapid parcel
#

cuz im better

vapid parcel
#

learning game hacking

viscid hornet
vapid parcel
#

😭

viscid hornet
#

😭😭

vapid parcel
#

OHHHHH

#

im slow GoofySkull

#

So I kinda do what you do. This is my table.

user_id
is_registered
bank_balance
wallaet_balance
last_daily_claim
daily_streak

So inside of the last daily claim, I use timestamps, which if they have claimed within the last 24 hours, it will make your daily streak go up, but if not, then it will reset back to 0

#

But I use a lot of functions so I don't have to repeat the crap over n over in each command.

vapid parcel
#
[2024-04-05 02:37:47,242] [ERROR] Ignoring exception in command 'purge'
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/discord/app_commands/tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.11/site-packages/discord/app_commands/commands.py", line 849, in _invoke_with_namespace
    if not await self._check_can_run(interaction):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/discord/app_commands/commands.py", line 987, in _check_can_run
    return await async_all(f(interaction) for f in predicates)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/discord/utils.py", line 703, in async_all
    for elem in gen:
  File "/usr/local/lib/python3.11/site-packages/discord/app_commands/commands.py", line 987, in <genexpr>
    return await async_all(f(interaction) for f in predicates)
                           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/discord/app_commands/checks.py", line 339, in predicate
    raise MissingPermissions(missing)
discord.app_commands.errors.MissingPermissions: You are missing Manage Messages permission(s) to run this command.
#

How to add error handling for appcommands/tree commands?

#

Im used to hybrid commands, so I don't really know tree error handling?

pale zenith
#

!d discord.app_commands.CommandTree.error

unkempt canyonBOT
#

@error(coro)```
A decorator that registers a coroutine as a local error handler.

This must match the signature of the [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree.on_error) callback.

The error passed will be derived from [`AppCommandError`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.AppCommandError).
vapid parcel
#

Me no understand lol

zenith yarrow
#

How do check if a word is in a embed or not

naive briar
#

!d discord.Embed

unkempt canyonBOT
#

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

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

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

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
naive briar
zenith yarrow
naive briar
#

Yes? But in what part of the embed?

zenith yarrow
naive briar
#

Yes

vapid parcel
# zenith yarrow Can I check in every part?
    "embeds": [
        {
            "id": "embed_774",
            "url": "https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed",
            "type": "rich",
            "rawTitle": "discord.Embed",
            "rawDescription": "``py\n\nclass discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)``\nRepresents a Discord embed.\n\nlen(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.\n\nbool(b) Returns whether the embed has any data set.\n\nNew in version 2.0.\n\nx == y Checks if two embeds are equal.\n\nNew in version 2.0...",
            "contentScanVersion": 0,
            "fields": []
        }
    ],```
#

You can see embeds easily

#

its not hard lol

viscid hornet
scenic pike
#

any who have code for invite tracker in python?

viscid hornet
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

viscid hornet
#

damn it

viscid hornet
viscid hornet
dusk ermine
#

Oh

viscid hornet
dusk ermine
#

Ticket System

viscid hornet
dusk ermine
#

What?

viscid hornet
#

yk the code you've written?

#

the product of pressing letters on the keyboard??

dusk ermine
#

Do I have to send you the entire ticket code?

snow elbow
#

hi

viscid hornet
viscid hornet
snow elbow
#

no

#

just new to server

#

getting grip on

viscid hornet
unkempt canyonBOT
viscid hornet
snow elbow
#

ok

#

thankx

viscid hornet
snow elbow
#

are you staff

viscid hornet
snow elbow
#

will you be my helper because i am newbie

viscid hornet
#

whats your issue

snow elbow
#

nothing, i want to be your coding partner

snow elbow
dusk ermine
#

async def select_callback(interaction):
if interaction.select.custom_id == "ticket_select":
value = interaction.values[0]
category_id = None
embed_desc = ""
ping_role = ""

@viscid hornet

viscid hornet
snow elbow
#

be parnters

#

patners

viscid hornet
viscid hornet
snow elbow
#

coding and helping @viscid hornet

snow elbow
#

interaction.self

viscid hornet
dusk ermine
#

whatt do i put in che code

viscid hornet
viscid hornet
# dusk ermine i dont know where to put it

take a look at how this works ```py
class ExampleView(ui.View):
...
@ui.button(...)
async def hi(self, interaction: Interaction, button: Button):
# button refers to the button while self refers to the view

class ExampleButton(ui.Button):
def init(self):
super().init(...)

async def callback(self, interaction: Interaction):
    # self refers to the button now```
#

i'm guessing the select is a separate class

dusk ermine
#

async def select_callback(self, interaction):
if interaction.self.custom_id == "ticket_select":
value = interaction.self[0]
category_id = None
embed_desc = ""
ping_role = ""

this?

viscid hornet
#

interaction.self does not exist. i told you to just use self

dusk ermine
#

async def select_callback(self, interaction):
if self.custom_id == "ticket_select":
value = self.values[0]
category_id = None
embed_desc = ""
ping_role = ""

this?

viscid hornet
#

self refers to the entire select menu

#

custom id, options, view, etc

dusk ermine
#

New Error

#

select_callback() missing 1 required positional argument: 'interaction'

Should I put () interaction?

viscid hornet
#

also why are you calling a separate function?

viscid hornet
# dusk ermine select_callback() missing 1 required positional argument: 'interaction' Should ...

this is taken from an example written by the guy who made dpy ```py
class SelectMenu(ui.Select):
def init(self):
options = [
discord.SelectOption(label='Red', description='Your favourite colour is red', emoji='🟥'),
discord.SelectOption(label='Green', description='Your favourite colour is green', emoji='🟩'),
discord.SelectOption(label='Blue', description='Your favourite colour is blue', emoji='🟦'),
]
super().init(
placeholder = 'Choose your favourite colour...',
min_values = 1,
max_values = 1,
options = options
)

async def callback(self, interaction: discord.Interaction):
    await interaction.response.send_message(f'Your favourite colour is {self.values[0]}')```
dusk ermine
#

Can I send you all the code and then you can fix it for me? to say it like that I don't know how to fix it

sick birch
viscid hornet
#

im honoured 😭

viscid hornet
sick birch
#

Anyway yeah, please send the whole view code

viscid hornet
dusk ermine
#

yes wait

#

dm?

viscid hornet
dusk ermine
#

ok

viscid hornet
# dusk ermine ok

your select callback requires arguments so you cant just define the select in the command, you have to use an external class

dusk ermine
#

And how?

viscid hornet
dusk ermine
#

fix it, I don't understand anything anymore

vapid parcel
viscid hornet
ivory falcon
#

is it possible to delete slash commands for the bot? if it is, how? (discord.py)

slate swan
hushed galleon
unkempt canyonBOT
#

commands/Owner/owner.py line 16

@commands.command()```
latent jay
#

If there's an uncaught exception within a task is the entire task destroyed?

slate swan
#

anyone familiar with discord buttons, how do i check if a message has a button? ive tried everything and nothing works

mighty terrace
#

how can i make something like this into my bot profile too?

viscid hornet
# slate swan anyone familiar with discord buttons, how do i check if a message has a button? ...
class ExampleView(ui.View):
    def __init__(self):
        super().__init__(timeout = 30)
    
    @ui.button(label = "hello", style = BS.blurple)
    async def hello(self, interaction: Interaction, button: Button):
        await interaction.response.defer()

    @ui.select(options = [SelectOption(label = 'hi', value = 'hello', description = 'example') for _ in range(3)])
    async def select(self, interaction: Interaction, button: Button):
        await interaction.response.defer()

...

@bot.command()
async def view(ctx):
    view = ExampleView()
    await ctx.send([type(child) for child in view.children])
#

get it from there using isinstance

#

the instance you're comparing each child to is ui.Button btw

steel pecan
#

@client.event async def on_member_join(member): SysC = client.get_channel(SystemChannel) # when user joins, bot mentions user await SysC.send("Hi" + member.mention)

#

idk how to make member mentioned

#

when joined

latent jay
#

what's it doing now?

viscid hornet
steel pecan
viscid hornet
#

so whats the issue

steel pecan
#

but also I accidentlly put "number" in SystemChannel ID

#

I fixed it tho

#

so dw

viscid hornet
latent jay
steel pecan
#

I was searching where did I found that

viscid hornet
steel pecan
#

also how do ya share code in that text format lol, I never did much share, but want to know

viscid hornet
unkempt canyonBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

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

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

For long code samples, you can use our pastebin.

steel pecan
#

OH

#

ty

latent jay
#

responded to wrong msg

pale zenith
young dagger
#

@silver wolf Sorry for the ping. Did you created the discordLevelingSystem package?

shadow vigil
#

is there a way to look into the guild permissions for a member?

#

I want to make sure the member has the server manager

pale zenith
unkempt canyonBOT
#

property guild_permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for).

This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.

Changed in version 2.0: Member timeouts are taken into consideration.
young dagger
shadow vigil
young dagger
shadow vigil
unkempt canyonBOT
#

A library to implement a leveling system into a discord bot. Contains features such as XP, level, ranks, and role awards.

Released on <t:1685718094:D>.

latent jay
#

Is there anyway to keep old interactions active after restarting bot?

hushed galleon
#

for any interaction in general (slash commands, modals, etc.), its theoretically possible but not supported by dpy, or at least not via a public interface

latent jay
sick birch
#

yes

latent jay
#

ahh that makes sense

drifting arrow
#

Hey, so I am using AIOSQLITE with a discordbot. and primarily it will only be used with a websocket feed to constantly add and check data.
There may be the occasional command used to check data, but overall it's just the websocket.

Will I encounter issues?

#

Should I change database types?

barren cave
#

if anyone knows simple code and wants to earn some money fast dm me

unkempt canyonBOT
#

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

drifting arrow
#

hhmm

supple jacinth
#

Heyo, I want to try doing ui modals, but i specifically want to make some sort of date selector that looks like this. Is it possible?

swift siren
#

discord.https , how to use for beta app commands brainmon

sick birch
swift siren
sick birch
swift siren
sick birch
#

ah, you mean the new global app commands

#

i don't think discord.py has support for it just yet

swift siren
slate swan
slate swan
#

it doesnt work though

slate swan
#

Doesnt work mean? You get an error?

silver wolf
# young dagger Is there any way to display the rank as an image like that?

no. adding an image like that was in development at one point, but the person that was working on it (the one who created a pull request) stopped working on it so it was nvr added. i had nvr originally planned on adding something like that because all the information u need numbers wise is already in the lib and i didn't wanna depend on any other lib other than discord.py.

plus there are a few image libs like what ur looking for already where u just have to put in the numbers and .read() a file for the background image

viscid hornet
slate swan
slate swan
slate swan
viscid hornet
slate swan
#

try putting print before isinstance to see what components it sees

viscid hornet
#

i showed it to you in that screenshot

slate swan
#

it shows nothing or it shows empty list

#

like it doesnt print anything

#

and where is this code located

#

on_message event

#

thats what u mean?

#

yea

#

can you show full code?

#

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

slate swan
#
@client.event
async def on_message(message):

    channel = client.get_channel(channel_id)
    user = client.get_user(user_id)

    if message.channel == channel and message.author == user:

        for action_row in message.components:
            for component in action_row.children:
                print(message.components)
#

print out channel and user they might be None

#

it passes the if statement

#

i know that, i tried it

#

i suppose it detects bot messages

#

yes

#

how about you put print(message.components) at top

viscid hornet
#

i dont think thats a thing hold on

slate swan
slate swan
#

ill try

viscid hornet
slate swan
#

it printed a whole lot of text

#

!code send it here

unkempt canyonBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

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

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

For long code samples, you can use our pastebin.

slate swan
#
[<ActionRow children=[<Button style=<ButtonStyle.success: 3> custom_id='7fae2a8b77c42513ce7fe4f9fe27c997' url=None disabled=True label='FIRST' emoji=None>, <Button style=<ButtonStyle.success: 3> custom_id='b2cb3aeceec04c97f10cd230e348ad60' url=None disabled=True label='PREVIOUS' emoji=None>, <Button style=<ButtonStyle.secondary: 2> custom_id='2af12a0678a6a49986dc3d08912577f2' url=None disabled=True label='1/10' emoji=None>, <Button style=<ButtonStyle.success: 
3> custom_id='a2f22abb4b1d37ee165f0ecfe7365968' url=None disabled=False label='NEXT' emoji=None>, <Button style=<ButtonStyle.success: 3> custom_id='773f1eeb3022d703d3052fa3f58dbf4b' url=None disabled=False label='LAST' emoji=None>]>]
#

so it does have the action rows

#

most likely the if check does not pass

#

it does

#

then put that print under that if

#

you talking about this one?

if message.channel == channel and message.author == user:
#

yea

#
@client.event
async def on_message(message):

    channel = client.get_channel(channel_id)
    user = client.get_user(user_id)

    if message.channel == channel and message.author == user:

        print('test')
#

then when you have that for loop

#

put print(1) inside

slate swan
# slate swan put `print(1)` inside
        for action_row in message.components:
            print(1)
            for component in action_row.children:
                print(1)
                if isinstance(component, discord.ui.Button):
                    print(1)

i tried it like this and it doesnt print anything

#

not one 1

#

impossible

#

hahah i mean thats what happened

#

do you have any error handler in your code?

#

no

#
@client.event
async def on_message(message):

    channel = client.get_channel(channel_id)
    user = client.get_user(user_id)

    if message.channel == channel and message.author == user:

        print('test')

        for action_row in message.components:
            print(1)
            for component in action_row.children:
                print(1)
                if isinstance(component, discord.ui.Button):
                    print(1)
#

this is the message, im just using carl-bot for testing

#

cause its help command has a button

#

can you try this code? ```py
@client.event
async def on_message(message):

channel = client.get_channel(channel_id)
user = client.get_user(user_id)

if message.channel == channel and message.author == user:

    print('test')

    for action_row in message.components:
        raise
#

yes 1 sec

#

doesnt print anything

#

not even the test?

#

oh right it prints 'test'

#

mb

#

can you show full code?

#

whole file?

#

cause it seems something is blocking errors i think

#

sure

naive briar
#

I don't know what error could it be

slate swan
#
import discord
from discord.ext import commands
import json
import asyncio
import re
import rand

with open("config.json", "r") as conf:
    config = json.loads(conf.read())

    token = config["startup"]["token"]
    prefix = config["startup"]["prefix"]

    channel_id = config["listener"]["channel_id"]
    user_id = config["listener"]["user_id"]

client = commands.Bot(
    command_prefix = prefix,
    intents = discord.Intents.default()
    )

@client.event
async def on_ready():
    print(f'online')

@client.event
async def on_message(message):

    channel = client.get_channel(channel_id)
    user = client.get_user(user_id)

    if message.channel == channel and message.author == user:

        print('test')

        for action_row in message.components:
            raise

client.run(token)
naive briar
#

You didn't enable the message_content intent

slate swan
#

you dont have message content?

naive briar
#

So you cannot access the components

slate swan
#

oh, how do i do that

#

!mcintent

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.

slate swan
#

so like this?

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

client = commands.Bot(
    command_prefix = prefix,
    intents = intents
    )

#

done should i try it again now

slate swan
slate swan
#

yeah i was wondering the same thing lol

naive briar
#

Probably the bot's own buttons? Idk

slate swan
#

no

slate swan
naive briar
slate swan
#

with this

    if message.channel == channel and message.author == user:

        print('test')

        for action_row in message.components:
            raise
#

i mean come back to old code

#

with print 1

naive briar
slate swan
#

alr hold on

#
    if message.channel == channel and message.author == user:

        print('test')

        for action_row in message.components:
            print(1)
            for component in action_row.children:
                print(1)
                if isinstance(component, discord.ui.Button):
                    print(1)

with this still only prints test

#

im out of ideas

#

😂

#

guess its not happening, ty for helping all that time still

#

!d discord.Message.components

unkempt canyonBOT
slate swan
#

weird

#

my only guess could be that maybe something else than a for loop?

#

i dont see what is wrong with for loop

#

should be working

naive briar
#

There's nothing to lose anyway

slate swan
#

it printed []

naive briar
#

Did you get a message about the message_content in the console?

slate swan
#

no

naive briar
#

😕

slate swan
#

yeah thanks for the help anyway

supple jacinth
#

How can i make a slash command in a cog?

spice junco
#

slash commands are scum created by the discord elite to make using your bot infuriating, do not give in to their demands

slate swan
#

its his choice what he uses

spice junco
#

^ agent paid by discord, do not listen to their requests

spice seal
#

Guys can I know a free hosting service for a bot 24/7

cloud dawn
naive briar
#

Love me some Discord conspiracy theories

supple jacinth
#
@app_commands.command(name="reload")
async def reload(self, interaction: discord.Interaction):
     try:
         await self.bot.unload_extension([extension for extension in self.bot.extensions.copy()])
         await self.bot.load_extension([extension for extension in self.bot.extensions.copy()])
         synced = await self.bot.tree.sync()
     except Exception as e:
         await interaction.response.send_message(f'An error occured: {e}')
         return
     await interaction.response.send_message(f'Successfully reloaded cog(s)')
     await interaction.response.send_message(f"Successfully synced {synced} command(s)")

An error occured: 'list' object has no attribute 'startswith'
What have i done wrong?

cloud dawn
#

You're using a string function on a list.

long quartz
#

...

cloud dawn
#

Do you have the whole traceback?

supple jacinth
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

cloud dawn
#

!d str.startswith

unkempt canyonBOT
#

str.startswith(prefix[, start[, end]])```
Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, stop comparing string at that position.
supple jacinth
#

Wait so whats the fix?

#

Oh i think i might have an idea

#

so i guess i cant just put the for loop in the load and unload extension then?

cloud dawn
supple jacinth
#

i dont have a startswith function, i wil try get full trace back

jade fern
#
class invitebutton(discord.ui.View):
    def __init__(self, page: int, total_pages: int):
        super().__init__()
        self.page = page
        self.total_pages = total_pages

    @discord.ui.button(label="<", style=discord.ButtonStyle.primary, custom_id="prev")
    async def left_button(self, button: discord.ui.Button, interaction: discord.Interaction):
        if self.page > 0:
            self.page -= 1
            await self.update_page(interaction)

    @discord.ui.button(label=">", style=discord.ButtonStyle.primary, custom_id="next")
    async def right_button(self, button: discord.ui.Button, interaction: discord.Interaction):
        if self.page < len(self.entries) - 1:
            self.page += 1
            await self.update_page(interaction)```

for some reason this discord.ui stuff is not working up for me. 
AttributeError: 'invitebutton' object has no attribute 'entries'
supple jacinth
jade fern
#

!d discord.ui.button

unkempt canyonBOT
#

@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button 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 [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button) being pressed.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button) manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
cloud dawn
jade fern
cloud dawn
jade fern
#

in the embed

cloud dawn
jade fern
cloud dawn
#

So page is the embeds..?

jade fern
#

await interaction.message.edit(embed=embed, file=file, view=invitebutton(page, total_pages))

#

should i pass all the embeds there?

#

page, total_pages, embeds

cloud dawn
jade fern
#

ooo

cloud dawn
#

Since unload expects extension paths.

cloud dawn
# jade fern ooo

The list of embeds is needed in the view otherwise the code wouldn't know what embed to show.

supple jacinth
#

['cogs.util_cog', 'cogs.fun_cog', 'cogs.faa_cog']

cloud dawn
supple jacinth
#

Yes that is what [extension for extension in self.bot.extensions.copy()] returns

cloud dawn
#

Well unload and load doesn't take lists, lol should've seen it sooner.

#

!d discord.ext.commands.Bot.reload_extension

unkempt canyonBOT
#

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

Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.unload_extension) followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension) except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
cloud dawn
#

I also recommend using this.

#

Also be careful when syncing globally like that.

supple jacinth
#

Ah i see, i assume this doesnt take in lists also?

supple jacinth
cloud dawn
cloud dawn
# supple jacinth How come?

Because you can only sync that many times per day, also takes long to sync and this doesn't take into account if metadata is being updated or not.

supple jacinth
#

Ohh, so what do i do then?

cloud dawn
#

Preferably you'd want to sync to a development guild, when you're done building the features you then push it to production and sync them globally.

supple jacinth
#

Right I see, and how can I do that?

cloud dawn
#

!d discord.app_commands.CommandTree.sync when passing a guild it will sync to that guild instantly and not sync globally yet.

unkempt canyonBOT
#

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

Syncs the application commands to Discord.

This also runs the translator to get the translated strings necessary for feeding back into Discord.

This must be called for the application commands to show up.
supple jacinth
#

Thank you for your help

#

Haven’t developed in a while so getting used to so many new things XD

cloud dawn
#

Np, gl!

paper sluice
#

@marsh furnace found u

supple jacinth
#
tfr_group = app_commands.Group(name='tfr', description="Request, Accept, Deny or List TFR's")

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

What is wrong here? I'm getting no errors or anything but the command is not coming up when I do /

naive briar
#

Did you sync them?

supple jacinth
#

Yes I did

naive briar
#

Loaded the cog/extension?

supple jacinth
#

Yep

naive briar
supple jacinth
#

And yes I also reloaded my Discord

viscid hornet
supple jacinth
#

Yes

viscid hornet
#

what happens when you type /

#

like what commands from your bot show up

supple jacinth
#

Previous ones I have made

viscid hornet
supple jacinth
#

Alright, lemme try that

viscid hornet
viscid hornet
supple jacinth
viscid hornet
supple jacinth
#

Ah okay, thank you

viscid hornet
# supple jacinth Ah okay, thank you

it's also not a good idea to use youtube tutorials because most of them only teach 1 thing which means people who follow the tutorials only learn how to do that 1 thing very well

supple jacinth
#

yeah, ive tried watching a bunch of tutorials and they have so many different methods. I don't know which is the best or even which works ect :/

#

even following the api reference its confusing to me, like i dont understand what all this is

drifting arrow
#

Well

viscid hornet
# supple jacinth even following the api reference its confusing to me, like i dont understand wha...

ok i'll break down the docs for you:

  • class: it's telling you what you're looking at is a class, not a variable or coroutine or whatever
  • discord.app_commands.Command(): this is telling you what you would have to write if you only started your file with import discord (ie. how to get that thing from the discord folder)
  • (*, ...): this means you need to call everything using kwargs (ie. name = ... and not just ...)
  • (*, name, description ...): these are the arguments it takes (what to put into it)
drifting arrow
#

:D

#

he said it better than me

viscid hornet
supple jacinth
drifting arrow
#

oh

#

you dont need to use ever argument either

#

The documentation even breaks it down explaining what every argument does

viscid hornet
#

just to double check because i don't know off of the top of my head

supple jacinth
#

Im hoping to make a group which the base command is /tfr and the different options are
/tfr request <information inputs here>
/tfr accept <id>
/tfr deny <id>
/tfr list <id/all> <id here if id selected>

drifting arrow
#

🤔

#

Does grouping work like that?

#

I would've assumed you'd need to make a list using the choices thing

#

¯_(ツ)_/¯

#

but idk never used group

supple jacinth
#

Well i was able to accomplish it with normal commands but when i migrated to slash commands its a pain in the butt

drifting arrow
#

Normal commands are different tho lol

supple jacinth
#

Exactly

#

[WARNING ] discord.http: We are being rate limited.

drifting arrow
#

lol

drifting arrow
#

just close the app and wait a ew minutes.

#

a few minutes*

#

or ew minutes if you think it's icky

hushed galleon
#

syncing is about 2/30s last i checked, shouldnt take too long

supple jacinth
#

yeah what is subgroups? Whats the difference between them and groups?

#

oh wait

#

you just explained pretty much

viscid hornet
drifting arrow
#

Grouping commands seems useful

supple jacinth
drifting arrow
#

🤔 indeed. <headnods> Yep. when I can be bothered all my bots will be updated.

viscid hornet
#
tfr = app_commands.Group(name = 'tfr', description = 'hello')```
drifting arrow
#

UPDATE ALL THE BOTS!!

viscid hornet
#

what was the initial issue?

drifting arrow
harsh orbit
#

is there a way to run a bot by another bot
like I have a discord bot that detect messages in a cretin channel if a discord bot token was sent in this channel the bot will detect it then run the token in a certin code

#

I saw someone doing this but IDK how

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.

viscid hornet
#

thats also not gonna work lmao

#

if you try and send a discord bot token, discord will automatically revoke it and reset the token

drifting arrow
#

Doesn't discord actively detect most places, like github, gitlab and even discord itself if a token is sent?

harsh orbit
drifting arrow
#

I know it at least checks github

#

That message is not fun to see as a novice for the first time

viscid hornet
drifting arrow
#

THE WHOLE OF GITHUB

viscid hornet
harsh orbit
#

there is bots called "bot makers" doing this

drifting arrow
#

ya, that message when it first appears. you do be getting heart sinky moment

#

like "oh god. oh no. pleease. please. WHAT DID I DO?! is this the end? tell my mum i loved her."

viscid hornet
viscid hornet
supple jacinth
#

:(

tfr = app_commands.Group(name='tfr', description='testing')

@tfr.command(name='test', description='test testing')
async def test(self, interaction: discord.Interaction):
      await interaction.response.send_message("Testing", ephemeral=True)
drifting arrow
viscid hornet
#

you just pressed /, type in the rest of the command 💀

supple jacinth
drifting arrow
#

i got nothing.

viscid hornet
supple jacinth
drifting arrow
#

HHMM. Did you try turning it off and on again?

supple jacinth
drifting arrow
#

BRB lemme test myself

drifting arrow
#

gotta see if I got a test bot setup..

supple jacinth
drifting arrow
#

hold up. music time.

viscid hornet
drifting arrow
#

WOO

viscid hornet
#

works fine

#

@supple jacinth show the file with that code in

#

im guessing its a cog w like 5 commands or something

#

!code

unkempt canyonBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

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

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

For long code samples, you can use our pastebin.

viscid hornet
#

use that bottom hyperlink

supple jacinth
drifting arrow
#

works for me!

#
from discord.ext.commands import Cog, Bot
import discord
from discord import app_commands
from discord import Interaction
from discord.app_commands import guild_only, command

class TestClass(Cog):
    def __init__(self, bot:Bot, config:dict):
        print("[Cog] TestClass has been initiated")
        self.botBot = bot
        self.config = config
    
    tfr = app_commands.Group(name='tfr', description='testing')

    @tfr.command(name='test', description='test testing')
    async def test(self, interaction: discord.Interaction):
      await interaction.response.send_message("Testing", ephemeral=True)
    
    @command(name="ping", description="Pong")
    @guild_only()
    async def ping(self, interaction:Interaction):
        await interaction.response.send_message("Pong!")
#

:D

supple jacinth
#

How-

drifting arrow
#

uhh

#

Lets do some basic troubleshooting. Starting at the most obvious. Is your test function used elsewhere?

#

is the command name test used elsewhere?

#

assuming the code is the same, is the cog loaded properly?

#

Try and make another command in said cog like i have to test this

supple jacinth
drifting arrow
#

is the indentation wrong on the paste? or is that actual indentation you have on your IDE?

supple jacinth
#

No, the indentation is wrong on the paste haha

drifting arrow
#

Try my code

#

oh actually. dont.

#

My code is different.

#

Try and remove all the useless stuff you dont need atm just to test the code. So remove all the imports that arent being used (You can bring them back dw)

#

and change the tfr command group to something else, something you know you havent used at all.

#

So instead of tfr = app_commands.Group(name='tfr', description='testing')
it's: test_group = app_commands.Group(name='testgroup', description='Testing')

#

this way you know for sure you havent re-used the name elsewhere

#

If it works with new placeholder names, then you know it's just a naming issue and you can figure out where you went wrong, I suspect it's a naming issue.

#

And lastly, put the test command I have in, the ping command.

#

This is just to make sure the cog itself has been loaded and is running.

#

This is just how I debug shit when it doesn't work. Just change all the shit. remove all the shit. force the program to focus my shit.

#

When all else fails. Cry in a corner.

supple jacinth
#

Alright, just give me uno second

drifting arrow
#

Then realize mid sob you actually made a really basic mistake, come up with a story about how it wasnt your fault and actually you're super awesome and smart for figuring it out.

supple jacinth
#

Great start...

drifting arrow
#

you're using a command to reload?

#

:|

supple jacinth
#

but no errors lmfao

drifting arrow
#

you're not syncing the command tree up. that's the issue lol

supple jacinth
drifting arrow
#

If you are using a command to reload the cog instead of the entire bot, you're not syncing the command tree up properly.

supple jacinth
#

thats in my on ready event

drifting arrow
#

But that's not in your cog.

supple jacinth
#

nope

drifting arrow
#

Which means those commands arent getting loaded in

#

Try reloading the entire bot not just the cog.

supple jacinth
#

Thats what I have been doing

#

I did say xd

drifting arrow
#

Do we ree now? or cry now?

supple jacinth
#

Nothing comes up, I think it is time to cry

drifting arrow
#

well anyway. try my debugging steps. See if any of those work. Coz the code I shared definitely works.

supple jacinth
#

I dont get it though, because this command is in a seperate cog and it works..

drifting arrow
#

Wait. so the "cog" itself with the tfr command isnt being loaded in at all?

#

This is also why I said to just change all the names and things

supple jacinth
#

Um, lemme try changing names then

drifting arrow
#

all the names. Not just 1 at a time.

#

Change them all. You can figure out which one specifically it was afterwards.

supple jacinth
#
async def load_cogs():
    for cog in os.listdir('/home/joshy/Bot/cogs'):
        if cog.endswith('_cog.py'):
            module = cog[:-3]
            await bot.load_extension(f'cogs.{module}')
``` is there anything that looks wrong with my load cog function?
#

What the dir looks like

drifting arrow
#

all hail the bob cog

#

BOB COG

#

if the other cogs are loading then I doubt its your code

supple jacinth
#

Should i try manually add it?

drifting arrow
#

Part of programming is debugging such things. Instead of asking just do it.

#

See an issue, think of ways to fix it. No matter how dumb, the only one who will know is you.

#

and your locally assigned FBI agent.

supple jacinth
#

😭

drifting arrow
#

yay

supple jacinth
#

Nothing happens though.. :(

drifting arrow
#

But you learnt something.

#

What knowledge do you have.

supple jacinth
#

The cog has loaded, so there is no issue with that?

drifting arrow
#

\o/

#

1 thing debugged. We now know the cogs are loaded, there's no need to be worried. so the issue lies with the codeblock itself \o/

#

as i said earlier, it probably has something to do with your names for the functions and variables. Try and change those. Give them something completely random.

#

In the example code you sent earlier, I noticed a lot of the characters tfr being thrown around a lot. There's a good chance you've accidentlaly used tfr elsewhere and its being overwritten.

#

and the function test could have also been used elsewhere

#

So to ensure nothing is repeated, use random names as placeholders now. Load the bot, reload discord.

supple jacinth
#

This has been what i have had since you told me to change the names

drifting arrow
#

hehehe goofy goober

#

you definitely watched spongebob recently

#

oh

#

you're using the same function name for both commands sponge and bob

#

change the function name to be test1 and test2

#

rleoad the bot. reload discord.

#

then thank me.

#

Maybe even worship me a little bit.

supple jacinth
#

oh my god i didnt notice that..

#

i swear to god if this is the reason..

supple jacinth
#

IT WASNT IT

drifting arrow
#

Do you want the left corner or the right corner? I prefer the left corner to cry in.

supple jacinth
#

WAIT WAIT

supple jacinth
#

the name is nolonger tfr..

#

hold on

drifting arrow
#

OH RIGHT. YEAH.

#

it's goofy

drifting arrow
#

k well. i give up. this rollercoaster of emotions hurts.

supple jacinth
#

yep

drifting arrow
#

someone else smarter than me can figure it out. im going back to anime.

supple jacinth
#

have fun lmao

#

thanks for trying lol

drifting arrow
#

Thanks. Im rewatching all of tensei shitara slime datta-kun.

#

New seasons coming out and I wanna make sure I remember everything. plus it's a good anime.

supple jacinth
#

I have no clue what that is, but imma take your word for it haha. Have fun.

drifting arrow
#

anime. about a guy reincarnated as a slime. super strong.

#

anime = cartoon. :D

supple jacinth
#

Ahh slime 🤣

slate swan
# naive briar Try printing out the components before the loop

@slate swan@naive briar I know why it wasnt working, but idk why this happens
if i put print(message.components) above the if message.channel == ......etc line, it prints all the components, but if i but it below that line, where my print('test') was, it would just print []

#

its like the components disappeared after if message.channel .....etc line

shrewd vapor
#

Hiiii, i got a problem, after renaming 2 times a channel in 1 minute my bot get rate limit for 600 seconds

#

i really don't understand why

supple jacinth
#

@mild saddle I FOUND THE BLOODY ISSUE, I NEEDED TO SYNC TO ALL GUILDS

mild saddle
#

huh?

supple jacinth
#

Omg I’m so sorry

#

Wrong person

#

@drifting arrow

mild saddle
#

haha no worries, I'm also a discord bot person so I was assuming this was something that happened like a year ago lol

supple jacinth
#

😭 so sorry

midnight oracle
supple jacinth
#

Yes, I am aware. I previously did only for the guild but I did not know when making new slash commands I had to do it to all guilds?

midnight oracle
#

Ooh

#

I don't know. It may be a bad practice, but I always clean the guild and then sync every time the bot restarts, like this:

    @bot.event
    async def on_ready():
        logging.info(f'{bot.user} Is ready!')
        await bot.tree.sync(guild = None)


        for file in Path('cogs').glob('**/*.py'):
            *tree, _ = file.parts
            await bot.load_extension(f"{'.'.join(tree)}.{file.stem}")

        await bot.tree.sync()
supple jacinth
#

i can't tell you if that is good or not, i have literally only just learnt about all this slash command stuff today haha

midnight oracle
#

Oh xD

#

Fast learner xd

supple jacinth
#

Haha XD

supple jacinth
#

Aww ValueError: could not find open space for item, trying to make a modal, i guess i have too many fields? Are pages a thing or something?

sick birch
#

there is no built in paging, but you can implement it yourself. make one modal for each page, and go to the next page with buttons after a user submits their current page

supple jacinth
#

Right I see, thank you.

#

Hmm I dont know where to begin lol

quick gust
#

whats your use case?

supple jacinth
# quick gust whats your use case?

Want to create a form where people can submit TFR requests (Temporary Flight Restriction) basically a virtual FAA lol. Modals would be perfect but since the maximum field is 5 and I need an extra input for a reason... im stumped lol

quick gust
#

idk if having pages for this makes sense, maybe you could merge the Date and Time fields

#

Into a single "Date & Time" field and the date n time can be separated with a new line

supple jacinth
#

True, I just don't know what would be the best way to do this and make it easily accessible

quick gust
#

you still could make pages nothing wrong with that

#

you will have to figure out what u think is best in your opinion

supple jacinth
#

Yes, I was thinking of just sending separate messages which only the user can see but i feel like that would be too complicated since there is literally this Modal lol

quick gust
supple jacinth
#

Yes, I forgot to add a recent screenshot

quick gust
#

Ah okay

supple jacinth
#

Also another question, Is it possible to make a date selector?
Because i found out Unix Timestamp is a thing but im not sure how i would do it lol

vocal plover
#

you can make a slash command/modal that interpretes something like "april 20th 2024" but there's no native client thing for it

#

which is a shame cause it'd be really useful

quick gust
#

agreed they should just copy paste the date selector for the search thing in discord

#

😀

supple jacinth
#

Surely I could get the current unix date and do some math to add the correct amount of time?

supple jacinth
#

Wait a minute, it is entirely possible, couldnt I used drop downs or buttons to act as the "calendar"

sick birch
#

making UI in discord is just not great

#

i avoid it as much as i can but for really simple stuff. everything else, i'd just throw together a quick little frontend

supple jacinth
#

Apologies, I'm not very good with that type of terminology haha

sick birch
#

a website

quick gust
#

I'm guessing he means a website?

supple jacinth
sick birch
supple jacinth
#

First it would get sent to a sqlite3 database stored on my raspberry pi, then and embed wil be sent in a channel ready to be reviewed by moderators who can use commands to accept/deny blah blah blah and when it gets accepted the status in the database changes to active. And then another embed gets sent into another channel which shows all the active TFRs. And i was really hoping to get that date/time thing done so it can be sorted and possibly when the time runs out the status changes to inactive automatically

sick birch
# supple jacinth First it would get sent to a sqlite3 database stored on my raspberry pi, then an...

the way I'd do this is write a flask app that will directly get the form data from the website and put it into the bot. your bot could poll the database (say every minute) to check for new TFRs, if it finds any, post that embed into a channel with some buttons and what not. once a user verifies/denies it, the bot would send a request back to the web server saying so.

essentially you generally want a web server to be the central system and controls database access, and everything else talks through it (since source of truth)

#

what you can also do is cut out the bot entirely, you can send messages directly from a flask backend using a webhook

supple jacinth
#

right I see, so how would the bot be able to recieve and send to the website? Well like you said I could also just use webhooks lol

#

Could you also make the website on github or something? Or is that a lack of security?

sick birch
supple jacinth
#

Ahh I see

sick birch
#

github pages works nicely for static pages (that is, you just serve a bunch of HTML files and call it a day)

supple jacinth
#

Aww man, so I will have to get a web server then? I could run from my raspberry pi but I will definitely not do that

sick birch
supple jacinth
#

Yeah of course, but i think it would be really cool to have a dashboard like thing haha

sick birch
#

sure. it'd be a fun project and there's lots to be learned

supple jacinth
#

yeah, just feel like that hard part would be communicating the bot/webhook and website lol

#

Oh was going to ask what do you use for a web server?

sick birch
#

FastAPI is my personal favourite

#

well, my team & I ran into some really obscure fastAPI issues the other day so not my favourite ATM :P

supple jacinth
#

Ah alright, thanks alot

#

XD

slate swan
#

@slate swan @naive briar turns out bots defer their message if its a slash command, all i had to do was sleep for 3 seconds and it all wouldve worked 😂

shut river
#

Hello I need some help

#

whats the problem

viscid hornet
#

something in terms of internet is refusing you from connecting to discord

lyric solar
#

oh golly oh gosh

#

i have this:

        await interaction.followup.send("Loading...")
        time.sleep(10)
        await interaction.response.edit_message(content="Loaded!")```
however that doesn't work, so how do i edit a followup message?
golden portal
lyric solar
lyric solar
golden portal
#

it is an async environment, discord.py is purely async

viscid hornet
viscid hornet
#

so say you have a 10s time.sleep

#

everything on your bot doesnt work for the next 10s

drifting arrow
#

This is why you use async sleep :D

#

Async is the best

sour parrot
#

yo can someone vc with me and helkp me with my bot?? ive tried everything aand it isnt working

#

or i can send picturesp ls

drifting arrow
#

Just share your code.

sour parrot
#

ok

drifting arrow
#

If it's too big to be sent here, you can use !paste

snow coral
#

if i have 2 on_message events why does one stop working and how do i get around it

drifting arrow
#

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

sour parrot
#

!paste

drifting arrow
snow coral
drifting arrow
sour parrot
#

@drifting arrow

drifting arrow
#

Uhh lessee

sour parrot
#

and ive tried eveyrhting but it says my msg intent is missing

drifting arrow
#

Whats the issue exactly?

sour parrot
drifting arrow
#

oh. you need intents? You probably havent enabled intents in discord developers

sour parrot
#

i didd thio

drifting arrow
#

D:

sour parrot
#

exactly and idk whatsh appening

#

shouyld i try making a new project?

drifting arrow
#
# Intents
intents = discord.Intents.all()
#intents.members = True
#intents.messages = True
#intents.guilds = True
``` try this
sour parrot
#

ok

#

OMGG

#

IT WORKED I LOVE YOU SO MUCH

#

THANK YOU

drifting arrow
#

I will need to let you know, this does enable all intents and is not ideal if you do want to properly manage it

#

It is recommended you only enable what you need to better manage your security

sour parrot
#

and how do i do that/

drifting arrow
#

Lemme find the documetnation

sour parrot
#

wait @drifting arrow why cant i like use my commands

drifting arrow
#

¯_(ツ)_/¯

sour parrot
#

whenever i put / it doesnt show my commands

drifting arrow
#

coz those arent slash commands

sour parrot
#

what command is it then?

drifting arrow
#

Looks like text commands that are suppose to be executed using /

sour parrot
#

?

#

wym

drifting arrow
#

try /add_teamroles in chat

#

just type it and dont expect it to be a slash command

sour parrot
#

OH

#

ok that worked but i want it do display the commands how do i do that

naive briar
#

It depends on what library you're using

sour parrot
drifting arrow
#

lookup in the docs "app commands"

sour parrot
#

ok

charred sable
#

can someone help how do i get rid of this error message on python ?

#

*import discord
from discord import Intents , Client
from random import randint , choice

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

client = discord.Client(intents=intents)

token = "---"

@client.event

async def on_ready() :

print('we logged in as {0.user}'
      .format(client) )

@client.event
async def on_message(message) :

if message.author == client.user :
    return

if message.author == "servettoprak" :
    await message.channel.send("as")

    return

@client.event
async def on_message(message) -> None:
if message.author == client.user:
return

username: str = str(message.author)
user_message: str = message.content.lower()
channel: str = str(message.channel)

print(f'[{channel}]  kanalında {username} :  {user_message}" yazdı')

client.run(token)

if name == 'main':
main()*
my code

unkempt canyonBOT
#
Pasting large amounts of code

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

After pasting your code, save it by clicking the 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.

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

naive briar
charred sable
#

i just started...

naive briar
#

Sorry, I probably went too far 🥴

merry cliff
slate swan
#

is it possible to send a message in on_ready() event?

quick gust
#

sure

#

if you have the ID of the channel you want to send the message to

charred sable
merry cliff
#

ok

charred sable
#

i found this python code on yt for the audio play on channels can someone help me how to fix it i downloanded ffmpeg already.

#

i can make it join discord voice chats but i cant make it play sound

#

im getting this error when i run the code and try command

slate swan
#

!ytdk

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
charred sable
#

do i violate some sort of terms..

#

cuz im just gonna use the bot on my server

#

and i cant fix the problem

slate swan
#

by using ytdl you do no matter how you use it

#

so we cant help based on rule 5

charred sable
#

then how does the other music bots are legal

slate swan
#

who said they are

charred sable
#

idk lol

#

hmm

slate swan
#

you think why most of music bots got closed

charred sable
#

i added the feature that bot can join calls but what can i do with it

#

im not using discord that often

#

didnt notice many

slate swan
#

🤷‍♀️

charred sable
#

atleast can u help me with this code ?

slate swan
#

its await member.kick()

charred sable
#

ty

#

i have a help command here how can i make it to send every command line by line

slate swan
#

use next line \n

#

!e print("hi\nthere")

unkempt canyonBOT
#

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

001 | hi
002 | there
slate swan
#

or you can use multiline string

#

!e ```py
print("""hey
a
b
c
123""")

unkempt canyonBOT
#

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

001 | hey
002 | a
003 | b
004 | c
005 | 123
charred sable
#

ty

lyric solar
naive briar
#

That includes your bot's heartbeat to Discord

#

So it'll end up making your bot disconnects

charred sable
#

can someone explain to me how can i fix that problem ?

slate swan
#

Its discord.User

charred sable
#

i need to make it big right..

#

the u

#

my brain is not workin today

#

i learned much things and im tryna store all

#

made it work ty alot

shut river
#

How do I fix this bug?

#

@viscid hornet

#

Or anyone please?

viscid hornet
viscid hornet
# shut river

the line you drew isnt where the error message is, it’s below it

viscid hornet
shut river
#

await.self.dispatch_event?

viscid hornet
#

i just said you drew the line incorrectly

#

thats not where the error is

shut river
#

oh where's the error im just trying to fix it

viscid hornet
#

and its saying self.db.deposit is None so it doesn’t have an attribute called .world

shut river
#

thats weird

viscid hornet
#

hit Ctrl + F then type in “.deposit”

slate swan
#

👍

viscid hornet
#

it’ll bring up everywhere in your code where that term is found

viscid hornet
shut river
viscid hornet
#

you probably want discord.Member instead

viscid hornet
shut river
#

hm

viscid hornet
#

@shut river

shut river
#

its self.client.deposit

#

my deposit commands works fine but when i initiate the withdraw command its not working

viscid hornet
shut river
#

why

viscid hornet
#

not self.client.deposit

shut river
#

why tho

viscid hornet
#

oh wait nvm i read the error msg wrong

shut river
#

;-;

viscid hornet
viscid hornet
shut river
#

but i do have it

viscid hornet
#

wait it’ll give you lines as well, hold on

#

line 51 is where the error is

#

show me like lines 45 to 55

shut river
#

of client events

#
        await self.client.withdraw.report(embed=embed, add_fields=False)

        self.client.stop()

    @growtopia.Listener
    async def on_request_world_select_menu(self, _: growtopia.Context) -> None:
        await self.client.join_world(self.client.deposit.world)
        self.client.sent_enter_world_packet = True

    @growtopia.Listener
    async def on_send_map_data(self, ctx: growtopia.Context) -> None:
viscid hornet
shut river
#

alr

viscid hornet
#

somewhere in your code you’ve set it to None and thats whats causing the issue

viscid hornet
shut river
viscid hornet
#

“.deposit = None” is somewhere in the code

shut river
#

its not there

viscid hornet
shut river
#

is there a way to check through all my project

viscid hornet
#

what type is .deposit?

#

variable? string? im guessing a class by how you’re using it

#

put in “print(type(self.client.deposit))” somewhere there

viscid hornet
shut river
#

yes

#

i quit i dont know how

#

its been a week and idk how to fix it

viscid hornet
#

hmm thats strange

shut river
#

im fr

shut river
slate swan
#

Look for where you initialize it

spice seal
#

?work

#

?leaderboard

#

Sorry wrong server

#

😉 Hope y'all have a nice day with developing bots

charred sable
#

guys can someone explain me how do i kick or ban or do whatever i want to do with user id instead of using their @ ?

supple jacinth
#

What is the best way to organise all my code? I am a very un organised person and its starting to effect my programming, I want to organise it so it is all nice an easily accessible and understandable to read.
If anyone can even give me a few ideas, that would be appreciated very much!

#

im using discord.py by the way, not like pycord or something

viscid hornet
supple jacinth
#

also, another questions, does ctx not working with app commands?

viscid hornet
supple jacinth
#

so ctx.send and stuff wouldnt work?

viscid hornet
viscid hornet
#

and then if you want to do anything after, its .followup.

#

as long as you typehint to discord.Interaction or Interaction if you’ve imported it from discord, your IDE will handle all the suggestions

viscid hornet
slate swan
#

Depending what you want to do, you'll have to get the member rather than the user

supple jacinth
viscid hornet
#

oh right, i forgot about .get_member()

slate swan
#

And you probably want to combine get_ and fetch_ to get an accurate result

viscid hornet
viscid hornet
slate swan
#

It checks in cache, so even if the member is in the guild it may return None

viscid hornet
#

ohh

slate swan
#

Hence combining as get_member(...) or await fetch_member(...) will use API calls as well, and make sure you get something in return

viscid hornet
slate swan
#

Yeah it's pretty useful, a library also has getch_ iirc

#

Which does exactly that in the background, which is pretty nice

slate swan
#

disnake or nextcord or idk

#

Yeah, that's why I said "a library" and not discord.py or "it also has"

supple jacinth
#

is it meant to come up with more things?

quick gust
#

disnake does yes

supple jacinth
#

I have installed Discord Tools extensions

#

let me try disnake

quick gust
#

no I wasn't replying to you

supple jacinth
quick gust
#

all good

viscid hornet
supple jacinth
#

the user snippets are enabled

viscid hornet
#

why is djs there 😭

charred sable
#

can someone help me to figure out what am i making wrong im beginner just tryna learn how to make bots

supple jacinth
#

at least i think they are

#

have you defined commands?

charred sable
#

uhm

#

im watching a tutorial there is 20 and i just begun 2 days ago so i dont know that many things

supple jacinth
#

@commands.Cog.listener() have you defined commands

#

did you do

import discord
from discord.ext import commands
supple jacinth
supple jacinth
#

obviously haha

#

i think so anyways..

viscid hornet
#

also if you have git installed, use that link

#

yay i got the link right

supple jacinth
#

dont think i have git installed, lemme do that

viscid hornet
supple jacinth
#

wait i think its something to do with the ssh connection

viscid hornet
#

whats wrong w it

supple jacinth
#

one second

charred sable
supple jacinth
#

whats the full file look like?

charred sable
#

bro if im gonna past full file

#

its 152 tiles

slate swan
#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

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

After pasting your code, save it by clicking the 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.

slate swan
#

youtube_dl ducky_cat

#

And yeah that as well

supple jacinth
#

whats youtube_dl?

slate swan
#

!ytdl

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
charred sable
#

i didnt know it was illegal

viscid hornet
charred sable
#

still code not working tho the play

#

bro..

#

its already imported

viscid hornet