#discord-bots

1 messages · Page 71 of 1

digital charm
#

thnx

worthy acorn
primal token
#

btw your annotation is incorrect it would be user: discord.User | None and you can always do user or ctx.author and yen = bal[0] if bal else 0

silk fulcrum
slate swan
#

meh i really doubt if people use those typehints for type check, its just utilised by discord.py internally

primal token
#

And thats why everyone comes with NoneType attr errors kek

slate swan
#

discord.py shows unexpected behaviour when Optional[type] is used

primal token
#

never seen any

slate swan
#

theres this method ```py
@bot.command()
async def wave(ctx, to: discord.User = commands.parameter(default=lambda ctx: ctx.author)):
await ctx.send(f'Hello {to.mention} :wave:')

vocal snow
#

wtf

slate swan
#

don't tell me y'all never used it

vocal snow
#

wtf is tish

#

!d discord.ext.commands.parameter

unkempt canyonBOT
#

discord.ext.commands.parameter(\*, converter=..., default=..., displayed_default=...)```
A way to assign custom metadata for a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")'s parameter.

New in version 2.0.

Examples

A custom default can be used to have late binding behaviour.

```py
@bot.command()
async def wave(ctx, to: discord.User = commands.parameter(default=lambda ctx: ctx.author)):
    await ctx.send(f'Hello {to.mention} :wave:')
slate swan
#

its from the docs tho lmao

vocal snow
#

wtf

pliant gulch
primal token
#

smh

shrewd apex
#

imagine one-lining the command in default only

pliant gulch
shrewd apex
#

lambda won't be required i think will it we can just pass a function with ctx as a positional arg

pliant gulch
#

Oh right yea that would work, I overlooked that

ashen perch
#

anyone know if java is better for discord bot coding in contrast to python or vice versa ?

slate swan
#

do you know both languages?

#

!! considering you know both languages !!

python imo, it has better extensions and easier interface if using discord.py
java would be faster but I don't see how speed would really matter for a discord bot...

pliant gulch
#

Java has some more features than python would when it comes to discord bots

#

Like receiving voice

slate swan
#

Very kool event

silk fulcrum
#

Server was demolished using magik

primal token
#

Whats the point of having multiple bots if the whole guild will get ratelimited when raided

slate swan
#

I have 4 bots

#

Incognito is the prototype

primal token
#

Ive seen it with my own eyes lmao,(unofficial official discord api raid)

slate swan
#

This is event the more destruction you more likely to ween

#

Were gonna create new server

#

And everyone perm is admin

primal token
#

that just needs a bot that isnt in like 5 plus guilds iirc?

primal token
#

to create a server

slate swan
#

Im gonna mass dms

#

@primal token

#

SCRATCH VS PYTHON

#

Help idk how to nucke

primal token
#

What?

silk fulcrum
slate swan
#

How to nuke?

#

@silk fulcrum what is you're favorite ballistic missile lunchcode?

silk fulcrum
slate swan
#

how can i distinguish between different activities someone is doing aka playing a game listening to music etc

#

Is it required to have the role separate?

#

If you want to give roles

#

Display separately thing

#

i mean like this

shrewd apex
#

for pycharm?

#

press cntrl alt s u will get a pop up

#

go for last option plugins or extension something idr click there will be discord option click and customise

slate swan
#

sorry im not being specific here

#

ive got a who is command for my bot which takes a user and displays information about them

#

one of those bits of information is there activity

shrewd apex
#

yes

slate swan
#

i user user.activity to get the activity there doing

shrewd apex
#

mhm

slate swan
#

but it gives a long <Activity type=<ActivityType.playing: 0> name='Code' url=None details='In viola - 3 problems found' application_id=782685898163617802 session_id=None emoji=None>

#

how can i just get the name

shrewd apex
slate swan
#

thank you

#

lmao

#

how to make the bot send select menu to private messages. Well , that is , how to change it await member.send(view=view) ?

slate swan
#

@silk fulcrum

how do I need to change this line so that it is responsible for sending private messages ?

await interaction.response.member.send("Список вашей инфомации", view=view)```
shrewd apex
#

just fetch the member then do member.send

primal token
#

?

slate swan
#

interaction.user.send

#

and defer the response so you don't need get a Interaction not responded message

shrewd apex
slate swan
#

I'm using bot-hosting.net to host my bot, and I was wondering what database you could recommend for it?

#

don't they provide a free mysql database with that?

slate swan
primal token
#

no? interaction.user returns the user/author that invoked the app command

shrewd apex
#

fetch the mentioned user

#

then send

primal token
#

?!?!?

shrewd apex
#

?

primal token
#

Cant you just expect a member obj?

shrewd apex
#

why u keep '?' marking me 💀

slate swan
shrewd apex
primal token
#

what

shrewd apex
#

how do i know how he is going to get the member object

#

he can pass as a param or just fetch from id

slate swan
#

interaction.user.send in this case, he just throws it to me in the bos, and not to the mentioned user

primal token
slate swan
shrewd apex
primal token
shrewd apex
#

i even said he can pass in the member as a param to the view

primal token
#

?!?!??!

shrewd apex
#

bruh subclassed view u can pass in extra args

#

so in callback u can send member as param if this menu is sent as a callback

#

if not just send in the command

primal token
#

I know that, but your methods are just baffling me right now, should read the python zen

slate swan
shrewd apex
#

i am just saying the easiest way possible...

primal token
#

?!?!?!?? easiest pardon??!??

shrewd apex
#

so question asker can get it easily how they apply it is up to them

#

argh u can just go ahead and explain then

#

ask noid pithink

primal token
#

sarth can answer it i have work to do lmao

slate swan
#

@slate swan interaction.user.send in this case, the bot sends a message to me in the bos. And how to make it so that he sends not to me, but to the user I mentioned ?

vale wing
#

And get a normal VPS

slate swan
slate swan
slate swan
vale wing
#

Ok but do you have a bank card

slate swan
#

Nope

vale wing
#

Sad

slate swan
#

Yeah, I'd like a free version on AWS or something.

shrewd apex
#
@bot.command()
async def foo(ctx: commands.Context, member: discord.Member) -> None:
    view = YourView()
    await member.send(view=view)
slate swan
shrewd apex
#

...

slate swan
#

I know how to do this for an ordinary command. And for command with slash I don't know

shrewd apex
#

bruh convertor will still give a member object all u need to do is await member.send() y is that so hard to understand

slate swan
#
    @commands.has_permissions(administrator = True)
    async def __holiday__(self, interaction: discord.Interaction, user: discord.Member):
        view = SelectMenuHolidayView(interaction)
        await interaction.that_user.send("Причины по которым вам могли это отправить", view=view)```
shrewd apex
#

await user.send()

vale wing
#

Why do you name it __holiday__ it's not a magic method

#

Also yeah = shouldn't be surrounded with spaces in kwargs

shrewd apex
vale wing
#

Wtf discord made with the last update everyone can legit see hidden endpoints now 💀

#

Funny how app still uses v9

vale wing
#

That science endpoint is pretty sus

#

Oh gosh I actually found messages search endpoint 😳

peak comet
#

anyone can help me

placid skiff
#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.

async with x Asynchronously initialises the client and automatically cleans up.

New in version 2.0.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").
primal token
#

Client

peak comet
silk fulcrum
placid skiff
#

D_D
discord.py is not beginner friendly, consider learning python and OOP

primal token
#

and asynchronous python

sick birch
silk fulcrum
#

I think your table is empty, and that is why it doesn't work

#

You have to fill it in with something

#

@magic gust nice try

#

well that warning means you have no primary key (primary key is a key that must be unique, so you can get any row by just specifying it, usually it is an ID, and it's auto increment, which means it will increase itself in each new row). Example of the primary key "id":

id |   name   |   info   |
---+----------+----------+
1  |   foo    |   bar    |
2  |   apple  |   banana |
---+----------+----------+
#

@slate swan

ebon island
#

I have a rotation feature which mutes/unmutes users automatically in a set order for users in a certain channel. I want to automatically unmute any users who leave the channel automatically, which works fine if they move to a different channel, but if they simply disconnect is there any way to clear their mute?

maiden fable
#

At least in my client lol

maiden fable
unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
maiden fable
#

Check if after.channel is None

dense kayak
#

!d intents

unkempt canyonBOT
#
dense kayak
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

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

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

maiden fable
#

But I'm sure u still do use that event

#

!d discord.VoiceState.channel

unkempt canyonBOT
#

The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.

digital charm
#
  @commands.Cog.listener()
    async def on_ready(self):
        db = sqlite3.connect("ab.sqlite")
        cursor = db.cursor()
        cursor.execute('''CREATE TABLE IF NOT EXISTS ab (
            user_id INTEGER, wallet INTEGER
        )''')
``` Is there some issue with this?, and every time i do (prefix) balance it creates a new a ab.sqlite file
slate swan
unkempt canyonBOT
slate swan
#

also delete the image cause it has your credentials

digital charm
#

@slate swan delete the image... as sarth said

vocal snow
vocal snow
#

And then assign the connection to some attribute of your bot instance so you can use it throughout your code

slate swan
#

How to change server pfp using bot?

#

@digital charm

#

@vocal snow

vocal snow
unkempt canyonBOT
#
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., afk_channel=..., owner=..., afk_timeout=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.

Changed in version 1.4: The `rules_channel` and `public_updates_channel` keyword parameters were added.

Changed in version 2.0: The `discovery_splash` and community keyword parameters were added.

Changed in version 2.0: The newly updated guild is returned...
vocal snow
#

icon kwarg

slate swan
#

@vocal snow

#

Like

#

await ctx.Guild.edit

vocal snow
#

ctx.guild.edit

#

lowercase g

slate swan
#

Ohh thanks

#

How to put the image?

vocal snow
#

you'll need to go to the doc link

slate swan
#

Yes ik but

#

How you gonna put the icon?

vocal snow
#

did you see what type icon kwarg takes?

slate swan
#

Icon.png?

#

Like that?

#

@vocal snow

vocal snow
#

icon (bytes) – A bytes-like object representing the icon. Only PNG/JPEG is supported. GIF is only available to guilds that contain ANIMATED_ICON in Guild.features. Could be None to denote removal of the icon.

#

what do you think?

#

you need a bytes-like object. If you have a file, you can open it in rb mode and pass file.read() to it

digital charm
#

@vocal snow what is WHERE for sqlite3

vocal snow
vocal snow
digital charm
vocal snow
#

what is member?

#

what's the point of doing member = result? why not just use result

#

anyways, are you sure that if statement is executing?

misty magnet
#

can someone help me making a discord bot that sends random 4 green picker? command: .mines

cloud dawn
#

Just get a random number beteween 5*5

#

!d random.sample

unkempt canyonBOT
#

random.sample(population, k, *, counts=None)```
Return a *k* length list of unique elements chosen from the population sequence or set. Used for random sampling without replacement.

Returns a new list containing elements from the population while leaving the original population unchanged. The resulting list is in selection order so that all sub-slices will also be valid random samples. This allows raffle winners (the sample) to be partitioned into grand prize and second place winners (the subslices).

Members of the population need not be [hashable](https://docs.python.org/3/glossary.html#term-hashable) or unique. If the population contains repeats, then each occurrence is a possible selection in the sample.
cloud dawn
#

@misty magnet

gentle crescent
#

How do i check any message for a reaction with a specific emoji?

swift pumice
#

@slate swan

hushed galleon
gentle crescent
#

But how do i check any message? More specifically, how do i do that with both message and ctx?

#

on_message only takes message

placid skiff
#

!d discord.on_raw_reaction_add

unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
placid skiff
#

@gentle crescent

gentle crescent
#

Thanks!

#

Is payload the emoji or ctx and message?

cloud dawn
unkempt canyonBOT
#

class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
silk fulcrum
#

I don't think result is what you expect it to be. Could you print(result) and show what it says?

ebon island
# maiden fable Check if after.channel is None

but for example if they disconnect and I try to unmute them by my recollection it throws an exception. I might be misremembering but I'm 90% sure that behavior is there, that if they have disconnected completely when the bot tries to do .edit(mute=False) it will throw an error.

tawdry tendon
#

just a random question, what IDE are you using

#

oh ok

silk fulcrum
#

It is None I guess. Try executing this query (SELECT userID from afk WHERE guildID = your_guild_id) in your GUI and see what it gives

sick birch
#

imagine no vim

silk fulcrum
#

Graphic User Interface

maiden fable
silk fulcrum
#

The database itself is not human-friendly, and this GUI is like... a shell, a cover of your database, that makes it human-friendly (viewing the components with graphic things like buttons).
(Graphic User Interface - a graphics-based operating system interface that uses icons, menus and a mouse (to click on the icon or pull down the menus) to manage interaction with the system.)

dull knot
#

Guys help. fuck

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from disnake.ext import commands
  File "/home/runner/Neko-Nyan/venv/lib/python3.8/site-packages/disnake/__init__.py", line 23, in <module>
    from . import abc as abc, opus as opus, ui as ui, utils as utils  # explicitly re-export modules
  File "/home/runner/Neko-Nyan/venv/lib/python3.8/site-packages/disnake/abc.py", line 28, in <module>
    import asyncio
  File "/home/runner/Neko-Nyan/venv/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
    from .base_events import *
  File "/home/runner/Neko-Nyan/venv/lib/python3.8/site-packages/asyncio/base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^
SyntaxError: invalid syntax

Tried messing with asyncio and this happened. smh Help. I'ma need to sleep in 30 mins

paper sluice
#

async is a keyword

dull knot
#

So, what do I do?

maiden fable
#

what is the python version

paper sluice
#

looks like python 3.8

#

wasn't async added in 3.5 or something

maiden fable
#

idrk tbh

dull knot
#

I messed up WorryWorry

#

Never should've tried it smh

maiden fable
#

what happened

dull knot
#

Tried asyncio.sleep lol

dull knot
#

Pretty sure all my cmds are working fine though. It happened after I tried doing aysncio.sleep smh

maiden fable
#

u using replit?

#

i mean asyncio.sleep works for others lol

dull knot
#

Ah, wait. I think I did something like
asyncio.sleep(2, loop=self) or something lol
And yeah. pretty much. Replit

#

Planning to go VSCode soon though smh Replit too buggy

sick birch
#

Good, good!

dull knot
paper sluice
dull knot
#

I think I did something like this
import asyncio something I forgot

maiden fable
#

@dull knot upgrade from 3.8 and it will work

dull knot
#

I'm still fairly new to python

dull knot
maiden fable
dull knot
#

Alright lemme try

primal token
#
pip uninstall asyncio
primal token
#

!pypi asyncio

unkempt canyonBOT
slate swan
#

lmao that's like 7 years old isn't it

dull knot
slate swan
#

This version is only relevant for Python 3.3, which does not include asyncio in its stdlib.
replit moment

primal token
dull knot
#

That's the first thing I tried sad

slate swan
primal token
#

damn

dull knot
# dull knot That's the first thing I tried <:sad:647898449509089280>
Traceback (most recent call last):
  File "/home/runner/NekoNyan/venv/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/configuration.py", line 27, in <module>
    from pip._internal.utils.misc import ensure_dir, enum
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 38, in <module>
    from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_vendor/tenacity/__init__.py", line 522, in <module>
    from pip._vendor.tenacity._asyncio import AsyncRetrying
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/pip/_vendor/tenacity/_asyncio.py", line 19, in <module>
    from asyncio import sleep
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
    from .base_events import *
  File "/home/runner/NekoNyan/venv/lib/python3.8/site-packages/asyncio/base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^
SyntaxError: invalid syntax

Showed me this instead.

slate swan
dull knot
primal token
#

since when does replit have 3.3? dont they run on 3.8?

dull knot
#

Meh, I'll probably leave this be for now. Gotta sleep smh

primal token
#

either way isnt disnake python 3.5+ ?

slate swan
#

yes they do, and they keep installing wrong python packages automatically at the same time

#

disnake is 3.8+, since 2.0 was meant for same

primal token
unkempt canyonBOT
#

setup.py line 81

python_requires=">=3.8.0",```
paper sluice
primal token
glad cradle
#

yeah but

#

that version is old

primal token
#

then what were you looking for?

#

asyncio is an stdlib?

ebon island
glad cradle
primal token
#

why would it if its not in pypi?

#

wait you did !asyncio right? (with a big typo)

glad cradle
#

yes

primal token
#

yeah it wouldnt appear either way

glad cradle
primal token
#

yeah but iirc default in 3.8 not sure

finite falcon
#

!guild_join

#

!guild_info

unkempt canyonBOT
#
Server Information

Created: <t:1483877013:R>
Roles: 156
Member status: status_online 58,399 status_offline 295,940

Members: 354,341

Helpers: 145
Moderation Team: 38
Admins: 14
Owners: 3
Contributors: 42
Leads: 10

Channels: 326

Category: 35
News: 10
Staff: 63
Stage_Voice: 2
Text: 205
Voice: 11

primal token
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
primal token
#

you never defined a variable named bot and the bot kwarg isnt needed anymore

#

since youre subclassing the Bot class you would use super() to access the method from an instance of Bot

finite falcon
primal token
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

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

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

primal token
finite falcon
primal token
#

Can you show the actual error? im not aware of which one

glad cradle
#

nice new pic

finite falcon
primal token
primal token
finite falcon
glad cradle
primal token
#

You probably passed it to the method

#

and not the initializer

finite falcon
primal token
finite falcon
primal token
#

!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 floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

finite falcon
#

!paste

import discord, asyncio

token = '' # Account's token.
reply_message = "".
main_message = '' # Message to send in the channel.
channel_id = 970546476675633182 # Channel ID to send the message in.
delay = 300 # In seconds.
dmed_list = [] # Prevents from DMing the same user twice.

class Main(discord.Client):
async def on_ready(self):
print('Logged in as %s.' % self.user)
while True:
channel = self.get_channel(channel_id)
await channel.send(main_message)
print('Sent message in #%s.' % channel.name)
await asyncio.sleep(delay)

async def on_message(self, message):
    if isinstance(message.channel, discord.DMChannel):
        if message.author.id != self.user.id:
            if message.author.id not in dmed_list:
                await message.reply(reply_message)
                print('Replied to %s.' % message.author.name)
                dmed_list.append(message.author.id)

Main().run(token, bot = False)

primal token
#

Theres so much wrong in this code

glad cradle
#

true

slate swan
#

how to make the avatar of the author of command in embed in a small picture ?

primal token
unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
glad cradle
# finite falcon !paste import discord, asyncio token = '' # Account's token. reply_message = ...

your Main class should have an __init__ method where you make a call to the __init__ method of the subclassed class ex.

def __init__(self):
    super().__init__(command_prefix='your prefix here', intents=discord.Intents.default())

also it's recommended to use discord.ext.commands.Bot (Bot class, that is a subclass of discord.Client) and not discord.Client

constants should have capitalized names

don't make api calls on on_ready event

sick birch
slate swan
slate swan
glad cradle
#

¿

primal token
unkempt canyonBOT
#

property display_avatar```
Returns the user’s display avatar.

For regular users this is just their default avatar or uploaded avatar.

New in version 2.0.
slate swan
primal token
glad cradle
#

assuming that you have a user or member object

embed.set_author(name=member.display_name, icon_url=member.display_avatar)
primal token
unkempt canyonBOT
#

set_thumbnail(*, url)```
Sets the thumbnail for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Changed in version 1.4: Passing `None` removes the thumbnail.
primal token
#

the image on the right is what youre talking about?

glad cradle
slate swan
#

ERROR

#
Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 113, in wrapped    
    ret = await coro(arg)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 762, in _invoke    
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 124, in __prof__
    await interaction.response.send_message(view=view, embed=embed)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\interactions.py", line 638, in send_message
    await adapter.create_interaction_response(
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\webhook\async_.py", line 213, in request   
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "{member.display_avatar}" is not supported. Scheme must be one of ('http', 'https').```
#

Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 755, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 312, in invoke
    await injected(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 119, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds.0.thumbnail.url: Scheme "{member.display_avatar}" is not supported. Scheme must be one of ('http', 'https').```
primal token
#

you forgot the char f

#

why would it be in an f string though?

#

Why the f string in the url kwarg and why do you need a user argument if its not being referenced?

silk fulcrum
#

and also it's ...display_avatar**.url**

primal token
#

iirc display_avatar used to return a string

sick birch
#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
silk fulcrum
sick birch
#

It returns an asset

#

Don’t know if it returned a string before

silk fulcrum
#

isn't it new in 2.0?

primal token
#

it is actually

silk fulcrum
#

it wasn't even an str it just never existed

slate swan
primal token
#

mhm odd

slate swan
#
    @commands.slash_command(name = 'profile', description="Посмотреть свой профиль сервера. \n Пример: /profile")
    async def __prof__(self, interaction: discord.Interaction, user):
        view = SelectMenuProfileView()
        embed = discord.Embed(colour=0x2F3136)
        embed.set_author(name= "Список вашей инфомации")
        embed.set_thumbnail(interaction.user.display_avatar.url)
        await interaction.response.send_message(view=view, embed=embed)```
silk fulcrum
primal token
slate swan
silk fulcrum
slate swan
silk fulcrum
slate swan
#
    async def __prof__(self, interaction: discord.Interaction, user):
        view = SelectMenuProfileView()
        embed = discord.Embed(colour=0x2F3136)
        embed.set_author(name= "Список вашей инфомации")
        embed.set_thumbnail(url = f'{interaction.user.display_avatar.url}')
        await interaction.response.send_message(view=view, embed=embed)```
#
    @commands.slash_command(name = 'profile', description="Посмотреть свой профиль сервера. \n Пример: /profile")
    async def __prof__(self, interaction: discord.Interaction, user):
        view = SelectMenuProfileView()
        embed = discord.Embed(colour=0x2F3136)
        embed.set_author(name= "Список вашей инфомации")
        embed.set_thumbnail(url = f'{interaction.user.display_avatar.url}')
        await interaction.response.send_message(view=view, embed=embed)```
primal token
#

why the f string, the user argument and dunder namespace? are you running the updated state of the command?

silk fulcrum
#

wait

#

this is pycord 😭

primal token
#

traceback msg?

silk fulcrum
#

slash_command and discord namespace

primal token
#

doesnt nextcord also do the same thing?

#

or does nextcord not use the discord namespace when imported?

silk fulcrum
#

nextcord has nextcord namespace?

slate swan
silk fulcrum
primal token
#

which i asked a serious question so it doesnt fall to being rude either

sick birch
silk fulcrum
sick birch
#

Experienced teachers will often use a question as an answer to convey something

primal token
#

Its also very rude to question my helping methods yk

silk fulcrum
#

or not

primal token
#

How nice of you

sick birch
#

Yes, I am

primal token
#

Some people find it rude answering a question with another question

sick birch
#

I suppose, but it’s a useful tool if used in the right manner

slate swan
silk fulcrum
sick birch
#

That’s a hot take

primal token
#

I would rather be "restricted" from society than being accepted by it

silk fulcrum
slate swan
#

<@&831776746206265384> here one person shows aggression

daring olive
#

hello

silk fulcrum
#

man trying to ban himself:(

sick birch
#

I think things are fine here

silk fulcrum
#

wait didn't this happen today already?

daring olive
primal token
slate swan
daring olive
#

we don't blindly mute people. anyway, DM @novel apex please

#

and this channel can get back to discord bots

primal token
#

Thank you for your time mina, now can we go back to the topic of discord bots, sounds good?

slate swan
daring olive
#

you can DM @novel apex about that too. but trust me, we read the room before doing anything.

primal token
#

The only time it happens is when a moderator needs to investigate on the issue so the person doesnt continue doing damage

slate swan
silk fulcrum
primal token
#

I would like an answer, of course if you want further help?

slate swan
primal token
#

?

slate swan
#

how to write it down correctly embed.set_thumbnail(url = f'{interaction.user.display_avatar.url}')

primal token
#

you would reference the attribute as the property returns a string and no string formatting is being used

slate swan
#

What exactly should be written in brackets so that when the command is activated, the avatar of the author of command appears there
embed.set_thumbnail(?!?!?!?)

glad cradle
#

is it a slash command or a prefix command? also what library are you using ?

glad cradle
#

why pycord 😭

silk fulcrum
#

same question

slate swan
glad cradle
#

btw you don't need the user parameter

it should be

embed.set_thumbnail(url=interaction.user.display_avatar.url)
silk fulcrum
#

d-d-d-discord2?

glad cradle
silk fulcrum
#

w-w-what is that?

silk fulcrum
#

!pip discord2

unkempt canyonBOT
silk fulcrum
#

w-w-w-what

glad cradle
#

for discord.py should be

embed.set_thumbnail(url=interaction.author.display_avatar.url)
slate swan
silk fulcrum
#

now you are outdated

slate swan
#

@glad cradle aaaaaa
oh my god THANK YOU ❤️

silk fulcrum
#

!d discord.Interaction.user

unkempt canyonBOT
glad cradle
#

just replace author with user

silk fulcrum
#

and you will get the same as in pycord

glad cradle
#

true

#

i use disnake

#

disnake have author as attribute instead of user

#

discord.py an pycord doesn't have consistency in that sense

slate swan
glad cradle
glad cradle
glad cradle
slate swan
edgy maple
#

im using this func to load cogs from a cog folder but I keep getting the error FileNotFoundError: [WinError 3] The system cannot find the specified path: './cogs' any ideas on how to fix it? heres also how I have my files setup

silk fulcrum
glad cradle
primal token
primal token
silk fulcrum
#

w-what?

primal token
#

jk, its just camelCase isnt used in python

silk fulcrum
#

um, actually, i got this habit from PHP

#

idk what is about java

#

i used java too but idk

primal token
#

the tuple shouldve been named with SCREAMING_SNAKE_CASE

silk fulcrum
#

nice

dull terrace
#

my brain hurt

#
main_data = tuple(self.__dict__.values())[1:-9] + (self.id,)
await c.execute(update_queries["main"], main_data)```
after a few times doing this successfully it'll randomly decide that i have too many bindings
#

how does a class gain a random attribute

primal token
#

wdym random attribute?

dull terrace
#
tuple(self.__dict__.values())[1:-9]```
this is getting the values for the class attribute 1:-9
#

somehow it's changing size

#

it's getting one larger, i know it's gotta be something dumb somewhere that makes it seem like that's happening but it isn't but idk

primal token
dull terrace
#

Using discord.py 2.0 how do I get my bot to work on all servers. I have all the commands done and good to go with my test bot but when it comes to the bot that runs on my friends servers there's no option for slash commands anywhere. I'm new to this and I am severely lost, if anyone knows what to do pls help. I'll give you a hug

dull terrace
#

so it has to be adding a attribute after -9

primal token
#

its changing the value of that original variable right?

dull terrace
#

the position of -9 in the dictionary is changing to be bigger

#

im currently printing all attributes after -9 and trying to recreate

#

okay so wtf

#

('inventory', 'prices', 'objects', 'resources', 'dugout', 'barriers', 'enemies', 'chasers', 'cache_time')
turns into
('prices', 'objects', 'resources', 'dugout', 'barriers', 'enemies', 'chasers', 'cache_time', 'name')

#

how did i even do this

primal token
#

mhm

dull terrace
#

how do you even add an attribute to an already created class?

primal token
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

bar
dull terrace
#

i've only used setattr once in my entire code base and it's a special admin command i've definitely not triggered

primal token
#

@dull terrace where did you print main_data?

#

i was thinking that execute overwrites its value with a new tuple but it depends where you printed main_data

dull terrace
#

between the two lines

primal token
#

self.id returns what?

dull terrace
#

just discord id

#

it's doing it after doing a specific action but i've got about 300 lines of code to look through to figure out why

primal token
#

are you sure its value doesnt return tuple | str ?

dull terrace
#

idk what you're saying, every value returns what it should, i should check what this new thing called name is being valued at though, help me find what's going wrong

primal token
dull terrace
primal token
#

so you didnt joined 2 tuples?

dull terrace
#

and the whole thing is growing by 1 len

#

not in the print

primal token
#

but in the print you did print main_data right?

dull terrace
#

well name is my username which i already have a field for called username froggy_chill

#

i printed tuple(self.__dict__.values())[-9:]
which gave ('inventory', 'prices', 'objects', 'resources', 'dugout', 'barriers', 'enemies', 'chasers', 'cache_time') when it was working
and ('prices', 'objects', 'resources', 'dugout', 'barriers', 'enemies', 'chasers', 'cache_time', 'name') when it wasn't

winged coral
dull terrace
primal token
#

can you check what self.id returns before conjoining the 2 tuples?

dull terrace
#

i guess, but i seriously doubt it's gonna be wrong

#

yeah its the same

primal token
#

can you maybe show the code?

dull terrace
#

i wouldn't know which part to paste

#

the entire bot is almost 5k lines

primal token
#

maybe the whole method

#

or class if its not too long

pulsar cliff
#

Is there a chat where they mainly talk about making bots

#

Like crypto bots or bots to snipe certain items

primal token
pulsar cliff
#

Or is it talked about just in here

#

Okay thank tou

primal token
dull terrace
#

i-

primal token
#

¯_(ツ)_/¯

dull terrace
#

i- found it

primal token
#

i would love to see what was the issue

pulsar cliff
dull terrace
#

it's exactly what you think it'd be player.name = str(ctx.author) instead of player.username = str(ctx.author

pulsar cliff
#

Cause u would resell them for cheaper

dull terrace
#

except it wasn't player there it was under something else

primal token
#

so it was just a naming issue?

pulsar cliff
#

Does anyone know a rlly good way of profiting with making bots on discord because I usually just make personal bots but I'm looking to make money from selling now

#

Any good bots to make to sell

dull terrace
#

yup, simplest thing but just hidden

#

every time it's the simplest thing

primal token
#

ah i couldnt have noticed because you never showed the code but im happy you got it

dull terrace
#

commissions?

pulsar cliff
#

Yes yes

#

Cause I'm lowkey stuck on where to get them

dull terrace
#

all i can say is good luck, if you go on fiverr you'll notice about 100 sellers, selling bots for $5

pulsar cliff
#

😪

#

So I'm guessing making personal crypto bots and other bots is the way to go

winged coral
dull terrace
#

only way to actually make money with commissions is building a fan base first

#

what are personal crypto bots

pulsar cliff
# winged coral Your biggest bot, how big is it?

(Im making my own crypto bot atm) but my biggest and most profitable one was making a roblox trade bot cause I played roblox and it earned me at least 100k robux a month and with that I would sell tha robux for 200 euro at least

#

Roblox trade bot though

#

I had help with it but 90 percent of it was my own work

winged coral
#

Got a responsive userbase?

pulsar cliff
#

Yes

winged coral
#

So get some vouches. Get on a platform that allows ratings and get rated by them

primal token
#

this turned from discord bots to an investments course

pulsar cliff
#

Thanks for the feedback though

winged coral
#

It's all about credibility really. Buyers gonna see 20 people on page 1 and the only thing telling them apart is how professional you sound, your reviews, and any nice pictures or content you have that pops out at them

dull terrace
#

im still trying to figure out how you make a crypto bot for discord, is this like an escrow thing where the bot holds the crypto as a middle man and takes a percentage

#

sounds suuuper sketchy legally

winged coral
#

I mean crypto bot is a vague way of describing it

#

It's like calling someone a money man

#

There's probably loads of possible uses

primal token
#

jk im broke😔

winged coral
#

😭 😭 dw me too i'm on minimum wage

dull terrace
#

good luck to you while it lasts, idk exactly what you're doing but i'd say it'll be regulated soon

#

i mean imagine setting up a currency exchange bot with regular cash

primal token
junior verge
#

Ide is free mate?

primal token
junior verge
#

vsc is fine?

primal token
#

i cant pay for a computer
now lets not make a OT discussion about a joke lol

slate swan
#

@glad cradle how to change this part of the code correctly so that it sends a select menu message to the personal ? Command does not use a prefix but a slash
await member.send("Причины по которым вам могли это отправить", view=view)

#

await interaction.member.send_message(...) ?

sick birch
glad cradle
#

be sure to set your slash command as usable in dms

worthy mortar
#

stupid question but i cant find in api docs
the code below says im playing a random game
await client.change_presence(activity=discord.Game("Random Game"))

#

what if i wanted to change playing to watching

slate swan
#
#SERVER IP AND PORT
    @app_commands.command(name = "server", description="ip&port")
    
    async def server(self, interaction: discord.Interaction):
        
        embed = discord.Embed(title = "SERVER ADDRESS & PORT", color = discord.Color.red)
        embed.set_author(name=f'{interaction.user.display_name}'+ f'#{interaction.user.discriminator}', icon_url= interaction.user.display_avatar)
        embed.add_field(name='ADDRESS', value="address", inline=False)
        embed.add_field(name="PORT", value = "port", inline=False)
        embed.set_thumbnail(url=my_thumbnail)
        embed.set_footer(text="MAY BE OFF DUE TO CONSTRUCTION")
        
        
        await interaction.response.send_message(embed=embed, ephemeral=True)

The message is not sending. Please tell me how I can rewrite the send message
I would done fetch_channel, but I want it to work in any channel its done in

shrewd apex
#

discord.Colour.red()

#

u missed the ()

#

also if u can just use f"{interaction.user}"

#

no need to get name and discriminator seperately

primal token
#

f string concatenation😔

slate swan
#

Is there any documentation for vote rewards?

sick birch
#

Different discord bot boards will have different APIs for it

ionic garden
#

how long does it take to register a slash command?

primal token
#

It should be instant

ionic garden
#
import discord
from discord import app_commands


class Mod(app_commands.Group):
    """Moderator commands."""

    @app_commands.command(name="test")
    async def test(self, i: discord.Interaction):
        print("called")

main script: https://paste.pythondiscord.com/cewipijile

#

for some reason the commands aren't registering

slate swan
#

did you sync the command tree? and is the group added in the command tree

ionic garden
austere vale
#
  @commands.Cog.listener()
  async def on_command_error(self,ctx,error):
    try:
      if hasattr(ctx.command, 'on_error'):
        return
      else:
        embed=nextcord.Embed(title=f'Error in {ctx.command}',description=f'`{ctx.command.qualified_name} {ctx.command.signature}`\n{error}', color=0xfd9fa1)
        await ctx.send(embed=embed)
    except:
      embed=nextcord.Embed(title=f'Error in {ctx.command}',description=f'{error}', color=0xfd9fa1)
      await ctx.send(embed=embed)

i want to create an if statement where if the error is an "error in none command not found," it doesnt send an error message. can someone help me with how to write that?

something like

if error is NoneError:
  return
slate swan
ionic garden
#

yeah

#

i added a line

#

thing is, await doesn't work outside of functions

slate swan
#

you need to use setup_hook, check the channel pins it has a guide to slash commands

ionic garden
#

nice

slate swan
#

!d discord.ext.commands.Context.invoked_with

unkempt canyonBOT
vocal snow
#

I think CommandNotFound is the exception

slate swan
#

yes

austere vale
#

that worked! thank you so much

ionic garden
#
class ScoutClient(discord.Client):
    def __init__(self) -> None:
        super().__init__(intents=discord.Intents.all())
        self.tree = app_commands.CommandTree(self)

    async def setup_hook(self) -> None:
        self.tree.add_command(Mod())
        await self.tree.sync()
#

so uh
no way to register events in the class?

#

i have to do it the ol-fashoined decorator & static functions way?

slate swan
#

no

#

you can register events in class even moe easily ```py
class MyClient(Client):
async def on_message(self, msg: discord.Message):
...

#

same for all events, cause thats what @event decorator essentially does

ionic garden
primal token
#

Theres many

ionic garden
#

a similar method

#

to directly register events in class

#

nvm you do the same thing

primal token
#

you just declare a method? as discord.ext.commands.Bot.event uses setattr to set the method to itself

ionic garden
#

can i put events in cogs? if so, how do i do it?

#

nvm lol

slate swan
#

bruh use commands.Cog.listener if you're in a cog

slate swan
silent portal
silk fulcrum
slate swan
#

Hi
I can't get the slash 4.2.1 commands even using Ash's github

placid skiff
#

So, today it's a revolution day for us bot dev

silk fulcrum
#

what

placid skiff
#

The command permission system seems very cool

slate swan
#

I can't get the slash commands 4.2.1 even using Ash's github

placid skiff
#

I don't know what are you talkin about lmao

silk fulcrum
#

4.2.1 wtf is that

slate swan
silk fulcrum
placid skiff
#

yup

silk fulcrum
#

why would you need that all

slate swan
#

I'm only looking to use the slash commands with discord.py 2.0.1

placid skiff
#

The only thing i know is that you have to sync the command tree and use something like @bot.app_command bruh discord.py has a very stupid slash command integration

placid skiff
#

!d discord.app_commands.command

unkempt canyonBOT
#

@discord.app_commands.command(*, name=..., description=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command from a regular function.
silk fulcrum
placid skiff
#

yup, or an instance of Bot

silk fulcrum
#

well, then it's @your_bot.tree.command()

#

as said in the Ash's gist

placid skiff
#

if he followed ash code is probably a subclass

slate swan
#

I don't know

placid skiff
#

!d discord.app_commands.rename bruh wtf is this

unkempt canyonBOT
#

@discord.app_commands.rename(**parameters)```
Renames the given parameters by their name using the key of the keyword argument as the name.

This renames the parameter within the Discord UI. When referring to the parameter in other decorators, the parameter name used in the function is used instead of the renamed one.

Example:

```py
@app_commands.command()
@app_commands.rename(the_member_to_ban='member')
async def ban(interaction: discord.Interaction, the_member_to_ban: discord.Member):
    await interaction.response.send_message(f'Banned {the_member_to_ban}')
slate swan
placid skiff
#

i mean, why even do this

silk fulcrum
slate swan
#

personally think its really nice

silk fulcrum
#

for example if you want commands in diff language

slate swan
#

for example if you want a slash command argument named "list", you can't do that without using this

silk fulcrum
#

write everything in english in your code

#

an then do those renames

slate swan
#

but again im not a big fan of discord.py slash commands lol

silk fulcrum
#

me no care i just use hybrid and me gud

slate swan
#

they could have used something like var = app_commands.Option(name="foo")

placid skiff
#

exactly what i was going to say lmao

#

!d disnake.ext.commands.Param

silk fulcrum
#

dinake not cool

#

dpy cool

unkempt canyonBOT
#
disnake.ext.commands.Param(default=Ellipsis, *, name=None, description=None, choices=None, converter=None, convert_defaults=False, autocomplete=None, channel_types=None, lt=None, ...)```
A special function that creates an instance of [`ParamInfo`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.ParamInfo "disnake.ext.commands.ParamInfo") that contains some information about a slash command option. This instance should be assigned to a parameter of a function representing your slash command.

See [Parameters](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#param-syntax) for more info.
placid skiff
#

disnake is way more cool

silk fulcrum
#

@unkempt canyon takes his time...

placid skiff
#

cuz disnake is too much to handle even for him

slate swan
#

I can't figure out why I changed so much for nothing 😦

#

!d discord.ext.commands.Parameter they took it from here

unkempt canyonBOT
#

class discord.ext.commands.Parameter```
A class that stores information on a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")'s parameter.

This is a subclass of [`inspect.Parameter`](https://docs.python.org/3/library/inspect.html#inspect.Parameter "(in Python v3.10)").

New in version 2.0.
placid skiff
#

And this makes that thing a lot more weird now lmao

slate swan
#

its for the commands extension tho lmao, makes things like default args which utilise ctx easier

#

!d discord.ext.commands.parameter

unkempt canyonBOT
#

discord.ext.commands.parameter(\*, converter=..., default=..., displayed_default=...)```
A way to assign custom metadata for a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")'s parameter.

New in version 2.0.

Examples

A custom default can be used to have late binding behaviour.

```py
@bot.command()
async def wave(ctx, to: discord.User = commands.parameter(default=lambda ctx: ctx.author)):
    await ctx.send(f'Hello {to.mention} :wave:')
slate swan
#

like this one

#

in earlier versions you would set to to None by default and then use to or ctx.author

shrewd apex
#

hmm but this looks kinda ugly i would rather use the or

silk fulcrum
placid skiff
#

Usually i set the default to None, doing something like this:

@slash_command()
async def hi(itx: ApplicationCommandInteraction, member: Optional[Member]=None):
  member = itx.author if not member else member
slate swan
silk fulcrum
silk fulcrum
slate swan
#

just use vscode and live your life

placid skiff
#

Optional, from typing.Optional just says that the type of a variable is the type specified inside the brackets, but as Optional it can be a NoneType object too
for the member or itx.author i don't know, i just find it more ugly tbh, is something mine. I could even do it but meh, i don't really like that syntax

slate swan
placid skiff
#

typehints can save your code, always remember that, always use them

slate swan
#

i find Optional typehints ugly so i just use type | None

placid skiff
#

BRUH no that is absolutely ugly lmao

slate swan
#

saves keystrokes

#

i import typing as t whenever i want to use it, don't know if its a bad practice or not

placid skiff
#

you do import typing as t? lmao

silk fulcrum
#

I do from ... import ... almost for everything

placid skiff
#

T is used in typing.TypeVar

silk fulcrum
#

I think the only exception is discord, I import it, but probably I'll get rid even of that

placid skiff
#

!e

from typing import TypeVar
T = TypeVar('T')

def identity(arg: T)->T:
  return arg

var = "abc"
print(type(identity(var)))
var = 123
print(type(identity(var)))
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | <class 'str'>
002 | <class 'int'>
slate swan
silk fulcrum
placid skiff
#

imagine doing @commands.command when you can just type @command

#

or doing if isinstance(error, commands.MissingPermission): instead of if isinstance(error, MissingPermission):

slate swan
#

15 lines just to import some stuff for typing

slate swan
#

you can literally use discord.utils.Union instead of typing.Union because of the import structure in utils.py

placid skiff
placid skiff
slate swan
#

same amount of memory is used weather you use import typing; typing.List or from typing impot List, List, the first one provides more control on the namespace

#

and tbh i used to import classes seperately until i got bored and it became hard to handle things

#

full path imports actually.

placid skiff
#

yeah but then you will have to type typing everytime you want to use that classes

slate swan
placid skiff
#

i mean, we're devs, we're not noticed for how much we're active, we're noticed for how much we're lazy D_D

shrewd apex
#

hmm i am gonna try and clean up my imports today

shrewd apex
#

sarth downloaded pydroid 👀

slate swan
#

nah thats a 4 months old screenshot

#

i get 250kbps internet speed on average here

shrewd apex
#

so is pydroid like 1gb to download;-;

placid skiff
#

A funny package named hikari

slate swan
placid skiff
#

Like brainfuck

slate swan
slate swan
unkempt canyonBOT
slate swan
#

lightbulb is a command handler for hikari, just like discord.py has discord.ext.commands

#

it write in data2 but doest pop data 1

slate swan
# unkempt canyon

can be compared to brainfuck because its low levelled and you actually know what you're doing instead of just playing with a "Context", "Bot" and "Interaction" object

polar granite
#

How to fix this?

slate swan
polar granite
#

It is

slate swan
#

yea

#

i was gonna ask for the file structure

slate swan
#

try doing, with open('DisnakeMusicBot/bot_utils/config.json")

#

great, so you should be using "DisnakeMusicBot/bot_utils/config
json"

#

alternatively, you can run the main.py by movin to the folder first ```
cd DisnakeMusicBot
python3 main.py

#

if you don't want to change the path in code^

polar granite
#

Okay tysm let me try this

slate swan
slate swan
#

xD

#

yes but that would work only if main.py was run directly

#

however, this error isn't like a dpy error or anything like that 🤓

slate swan
# polar granite

💀 are you like cloning libraries? jishaku doesn't really need to be in your bot files.

#

they manually installing them to save storage fr

slate swan
silk fulcrum
slate swan
#

offtopic help, imagine someone popping with a "how to fix this pytorch error" question

silk fulcrum
slate swan
silk fulcrum
silk fulcrum
slate swan
#

json best database

#

?tag lp

novel apexBOT
#

This is not a Modmail thread.

silk fulcrum
#

wha

#

oh i got it

#

ok ill try

silk fulcrum
# slate swan use json instead of txt then

now im getting this error:
Could not import 'yomama'. The truck delivering this module broke down. You might need to go to this site to order another truck: https://www.youtube.com/watch?v=dQw4w9WgXcQ
Do I go to that site?

gusty shard
#

is it true?

silk fulcrum
#

doesn't every bot dev know that message content intent is now privileged

gusty shard
#

that means prefix system will not work anymore

#

doesnt it?

silk fulcrum
sick panther
gentle crescent
#

How can I check if any message has a certain reaction?

placid skiff
#

if it is a custom reaction then:
if emoji.name in message.content
if it is a unicode emoji then you have to check if the unicode string is in the content of the message

upbeat gust
#

they asked about reactions

upbeat gust
unkempt canyonBOT
upbeat gust
#

this returns a list of Reaction objects, you can access reaction.emoji

placid skiff
#

Lmao sorry i blacked out for a moment

slate swan
# gusty shard

the person who posted it either doesn't read discord api announcements properly or is Just misguiding
bots that are in less than 75 guilds/ non verified bots can access message intents just like any other intent
the limitation is for verified bots without message content intent.
and even if your bot is verified and doesn't have message content intents, you can use your bot's mention as the prefix, it will work.

brittle axle
#

Guys heroku is shutting down, do you guys know any other free hosting services

gentle crescent
brittle axle
silk fulcrum
brittle axle
#

very nice

ashen perch
#

hey is there a way to put a webGL application into an embed

silk fulcrum
#

you cannot put an application into an embed

#

only certain fields

#

thumbnail. image. author etc

ashen perch
#

ok is there any current methods to get arround it, even if its not an embed?

#

basically just need a bot to send a webGL application

silk fulcrum
#

what do you mean by webGL application?

#

iirc it's a visualizer of 3D graphics

#

or smth like that

ashen perch
#

im thinking of idk if your familiar with unity ?

rugged shadow
silk fulcrum
ashen perch
#

ok well ideally my plan is to get a unity project or an equvilant as a webGL application and send via a discord bot

#

i have no clue if theres a way though

silk fulcrum
#

like, how would that look like?

#

with that stuff we have in bots

gentle crescent
#

How do I check if a message is replying to another message?

silk fulcrum
unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

ashen perch
#

yea my only hope is it would work like when you send a yt video, you are able to watch and use the yt inputs on discord. so i thought it would work for other stuff ie a webgl app

silk fulcrum
#

wth

gentle crescent
gentle crescent
silk fulcrum
unkempt canyonBOT
#

class discord.MessageReference(*, message_id, channel_id, guild_id=None, fail_if_not_exists=True)```
Represents a reference to a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message").

New in version 1.5.

Changed in version 1.6: This class can now be constructed by users.
silk fulcrum
#

and from it you can get message_id, channel_id and guild_id

slate swan
#

is it possible not to use the database for private sessions ?

silk fulcrum
gentle crescent
slate swan
rugged shadow
#

😳 private sessions?

slate swan
#

private voice

silk fulcrum
slate swan
#

when you enter the voice channel. and he creates your channel for you that you can edit

gentle crescent
#

wha-?

silk fulcrum
slate swan
silk fulcrum
slate swan
silk fulcrum
gentle crescent
#

AttributeError: 'coroutine' object has no attribute 'attachments'

#
        msg = channel.fetch_message(message.reference.message_id)
        if msg.attachments is not None:
            at = msg.attachments[0]
silk fulcrum
gentle crescent
#

Then i can just use message.attachments?

silk fulcrum
#

wha

gentle crescent
#

After i do channel.fetch_message, will i just use message, or should i do msg?

#

msg = await channel.fetch_message
or
await channel.fetch_message only

silk fulcrum
#

why are you asking? You have the correct code right now, you just need to await the fetch_message

gentle crescent
#

ic

#

ayyy ok

#

Thanks man

slate swan
#

Anyone know what happening?

gentle crescent
#

Guild ID doesnt exist

silk fulcrum
slate swan
#

Where should i find it

#

Or how to fix

primal token
#

!d dict.get

unkempt canyonBOT
#

get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "KeyError").
silk fulcrum
#

second pin on this channel

vale wing
#

Now discord is killing the moderation bots

shrewd apex
#

i hope they don't remove the endpoints

gentle crescent
#

I dont get it man :(

#

Its as if they hate 3rd party devs :((

slate swan
#
@bot.event
async def on_voice_state_update(member, before, after):
    author = member.id
    if before.channel is None and after.channel is not None:
        print('1')
        t1 = time.time()
        tdict[author] = t1
    elif before.channel is not None and after.channel is None and author in tdict:
        t2 = time.time() 
        print('0')
        print(t2-tdict[author])```

to make how much time a participant spent in the voice , you need to add up these variables ?
silk fulcrum
#

time.time() 😭

slate swan
#

?

silk fulcrum
#

its so mean

#

i mean...

#

its just.. bad

slate swan
# silk fulcrum why `time.time()`

I just found it on the Internet so that there was at least an example of how to do it. Because here they throw this documentation that I don't understand at all!!!

silk fulcrum
#

not mean

slate swan
#

@silk fulcrum will I be able to transfer these variables from the event to the select menu ?

rugged shadow
silk fulcrum
silk fulcrum
silk fulcrum
slate swan
silk fulcrum
slate swan
silk fulcrum
slate swan
dull knot
#

Uh, guys help. grumpchib
Just migrated from replit to VS Code and I'm already getting an error. I also wanna try storing in a .env file but Idk how to do it.😮‍💨 Should've went with VS Code before I started

silk fulcrum
# slate swan with the fact that I can explain wrong what exactly I mean

I mean... I can explain what you have to do to get what you want:

  • Have on_voice_state_update event and save the time user joined the voice channel, like you already have (but with discord.utils.utcnow())
  • Create a select menu, and in a callback, check if the user's join time is in the dict or whatever you use to save data
  • Then to display how much time they spent in the channel: you get their join time, you get current time by discord.utils.utcnow() and do time_now - join_time, that will be the time they spent in the voice channel
#

Do you understand what to do?

slate swan
dull knot
slate swan
#

yep

dull knot
#

Taking long to install lol. but I'ma wait

gentle crescent
#

but my bot requires attachments, which means message.content, which really sucks :(

gentle crescent
silk fulcrum
slate swan
#

no you can't hide it on GitHub, just don't commit it there ( use a
gitignore file)

gentle crescent
# silk fulcrum `.gitignore`?

I work on 3 different devices and would prefer if i could pull them all to those 3 then hide it, but at this point the token has been public for like 25 other commits so if im making the bot open source im doing that in a new repo

slate swan
slate swan
#

yeah lol

rocky trench
#

Where exactly? Your explanation is making me a bit confused

winged coral
#

^ Me too

#

.append can take any value, it can be a list if you'd like it to be

rocky trench
#

^^

winged coral
#

If you want to add all the items from one list into another list you can use .extend instead

rocky trench
#

If you append a list to a list, it'll be a list in a list

#

!e
lst1 = []
lst2 = []
lst1.append(lst2)
print(lst1)

unkempt canyonBOT
#

@rocky trench :white_check_mark: Your 3.11 eval job has completed with return code 0.

[[]]
junior verge
#

!e
print(1)

versed nest
winged coral
#

!e
a = list(range(10))
print(a.pop())

unkempt canyonBOT
#

@winged coral :white_check_mark: Your 3.11 eval job has completed with return code 0.

9
winged coral
#

And if you're appending a value then you already have the value

dull knot
#

Guys lol. How... Sorry, Pretty basic mistake but it's my first time working with VS Code and Env files

gentle crescent
#

You already got an answer for this?

gentle crescent
#
@client.command()
async def help1(ctx):
    embedHelp=discord.Embed(title=f"{newline}", description="something something")
    embedHelp.set_author(name="Help!")
    await ctx.send(embed=embedHelp)
#

This command isnt working

dull knot
gentle crescent
vale wing
#

Imagine discord creating own economy system

rugged shadow
#

where did okimii go?

silk fulcrum
rugged shadow
#

i miss him

#

this channel used to be his love playground

silk fulcrum
vale wing
rugged shadow
dull knot
#

Improper token has been passed

silk fulcrum
vale wing
#

Or maybe you pasted something other than token

#

Like client secret

dull knot
#

Ah, rigth. Probably lol. AH, yeah. That might be it Kek

#

Lemme double check

#

Seems like I really did copy client secret lol. Alright. Thanks for the help

gentle crescent
#

did they just disable prefix commands?

silk fulcrum
gentle crescent
#

Mine doesnt work

silk fulcrum
gentle crescent
#

My bot is not verfified and has access to messange content intent

#

It stopped working around 13 gmt

slate swan
#

did you enable message_content intents in your code?

gentle crescent
slate swan
#

whats ur dpy version

#

.all() in 1.7.3 is different from .all() in 2.0

gentle crescent
#

how do i check dpy version

slate swan
gentle crescent
#

1.7.3

slate swan
#

1.7.3 won't work for message commands anylonger

#

unless you use bot mention as the prefix

gentle crescent
#

so, how do i upgrade to 2.0

slate swan
hushed galleon
#

1.7 is using an older gateway so you'd still receive message content if you have it enabled in dev portal

slate swan
#

the version has breaking changes

hushed galleon
#

though afaik gateway v6 will be removed in 2023

slate swan
hushed galleon
#

v6 doesnt know the message content intent exists

slate swan
#

dpy 1.7.3 uses v7 tho

gentle crescent
#

Bot can no longer send message using ctx though 🤨

vocal snow
#

Sure it can

gentle crescent
#

doesnt work however

unkempt canyonBOT
#

discord/http.py line 54

BASE = 'https://discord.com/api/v7'```
`discord/gateway.py` line 219
```py
"""Implements a WebSocket for Discord's gateway v6.```
gentle crescent
#

wait no, it can send embeds

#

but not normal messages

hushed galleon
#

i actually thought they were the same but apparently not, that or its misdocumented cause i wouldnt understand how it works

wicked atlas
#

At least in the Intents object

slate swan
#

yeah

wicked atlas
#

Yeah, you said that. Gotta start scrolling up.

slate swan
#
await ctx.message.delete()```
how do I change this so that it works with slash command ?
#

slash command invocations can't be deleted

#

because ctx in slash command causes an error

silk fulcrum
slate swan
#

you can create an ephemeral response instead

slate swan