#discord-bots
1 messages · Page 71 of 1
sorry that is create database not table
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

meh i really doubt if people use those typehints for type check, its just utilised by discord.py internally
And thats why everyone comes with NoneType attr errors kek
discord.py shows unexpected behaviour when Optional[type] is used
never seen any
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:')
wtf
don't tell me y'all never used it
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:')
its from the docs tho lmao
wtf
thnx
Imagine how bad a slightly complex default would look like
smh
we can always use just a normal def 
imagine one-lining the command in default only
If you mean directly passing a function decoration no, not possible it’s a statement not an expression, unless you mean doing lambda ctx: func(ctx)
lambda won't be required i think will it we can just pass a function with ctx as a positional arg
Oh right yea that would work, I overlooked that
anyone know if java is better for discord bot coding in contrast to python or vice versa ?
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...
Java has some more features than python would when it comes to discord bots
Like receiving voice
Very kool event
Server was demolished using magik
Whats the point of having multiple bots if the whole guild will get ratelimited when raided
No
Ive seen it with my own eyes lmao,(unofficial official discord api raid)
This is event the more destruction you more likely to ween
Were gonna create new server
And everyone perm is admin
that just needs a bot that isnt in like 5 plus guilds iirc?
to create a server
What?
CoffeeScript
what does that even mean
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
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
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
yes
i user user.activity to get the activity there doing
mhm
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
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) ?
yes?
@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)```
just fetch the member then do member.send
?
interaction.user.send
and defer the response so you don't need get a Interaction not responded message

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?
that is , in order for him to send to the mentioned user , I just need to write interaction.member.send ?
no? interaction.user returns the user/author that invoked the app command
?!?!?
?
Cant you just expect a member obj?
why u keep '?' marking me 💀
Well, I need him to send it not to me. And to the mentioned member
same principle get the member object and send
what
how do i know how he is going to get the member object
he can pass as a param or just fetch from id
interaction.user.send in this case, he just throws it to me in the bos, and not to the mentioned user
cant you just use a member object?!??! aka the one mentioned or id passed so the converter makes a member obj...?
Perhaps, but how to use it? Do I have do install anything on my computer?
DID I SAY HE CAN'T why u question marking me for that i just said use the member object to send
you literally said to fetch the id when dpy can do it internally....
i even said he can pass in the member as a param to the view
?!?!??!
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
I know that, but your methods are just baffling me right now, should read the python zen
Anyone know if it's possible to use Sqlite on bot-hosting.net?
i am just saying the easiest way possible...
?!?!?!?? easiest pardon??!??
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 
sarth can answer it i have work to do lmao
@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 ?
that_user.send(...)
Is it possible not to use bot-hosting.net
And get a normal VPS
To my knowledge bot-hosting.net is a paid service
It's free
that is , you don 't need to write this ?
interaction
simply that_user.send(...)
I'm unable to install anything, and since I'm poor I can't buy anything either.
Ok but do you have a bank card
Nope
Sad
Yeah, I'd like a free version on AWS or something.
are u sending this view in a command also is there a param for the user mention in this command
@bot.command()
async def foo(ctx: commands.Context, member: discord.Member) -> None:
view = YourView()
await member.send(view=view)
well, this is for a regular command. And I have a slash command
...
I know how to do this for an ordinary command. And for command with slash I don't know
bruh convertor will still give a member object all u need to do is await member.send() y is that so hard to understand
@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)```
await user.send()
Why do you name it __holiday__ it's not a magic method
Also yeah = shouldn't be surrounded with spaces in kwargs
its fine ig i doubt any name mangling will happen but yeah bad practice imagine python making a holiday dunder
Wtf discord made with the last update everyone can legit see hidden endpoints now 💀
Funny how app still uses v9
Pretty nice in my opinion
That science endpoint is pretty sus
Oh gosh I actually found messages search endpoint 😳
anyone can help me
!d discord.Client
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").
Client
Where do I add it? before what ?
C is C not c

discord.py is not beginner friendly, consider learning python and OOP
and asynchronous python
of course they are holidays are magical
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
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?
!d discord.on_voice_state_update
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...
Check if after.channel is None
!d intents
!intents
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.
The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.
@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
!pip aiomysql use this and provide those credentials for the corresponding args
you won't need to install anything on your own device
Ty!
also delete the image cause it has your credentials
@slate swan delete the image... as sarth said
You should probably use aiosqlite and make the connection in setup_hook rather than on_ready
i c, thnx
And then assign the connection to some attribute of your bot instance so you can use it throughout your code
thnx a lot
!d discord.Guild.edit
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...
icon kwarg
Give example please
@vocal snow
Like
await ctx.Guild.edit
did you see what type icon kwarg takes?
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
@vocal snow what is WHERE for sqlite3
SELECT (column) FROM (Table) WHERE (condition)
k, thnx
https://sqlbolt.com is nice to learn sql queries btw
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
thnx, I'll read it
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?
can someone help me making a discord bot that sends random 4 green picker? command: .mines
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.
@misty magnet
How do i check any message for a reaction with a specific emoji?
@slate swan
Message.reactions gives you a list of reactions, and each Reaction has an .emoji attribute containing the Emoji/PartialEmoji/string you can compare to
But how do i check any message? More specifically, how do i do that with both message and ctx?
on_message only takes message
!d discord.on_raw_reaction_add
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.
@gentle crescent
!d discord.RawReactionActionEvent
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.
I don't think result is what you expect it to be. Could you print(result) and show what it says?
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.
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
imagine no vim
in the list where u r storing the members who have to be unmuted, u can just remove the member object from that when he disconnects or waste an API call and use a try except
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.)
Guys help. 
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.
Help. I'ma need to sleep in 30 mins
async is a keyword
So, what do I do?
what is the python version
idrk tbh
what happened
Tried asyncio.sleep lol
And now it made an error ^^^
Pretty sure all my cmds are working fine though. It happened after I tried doing aysncio.sleep 
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
Replit too buggy
Good, good!
So, is there a way to fix this? If not, I'll probably just fork it and
Redo
why is your asyncio in site-packages?
I think I did something like this
import asyncio something I forgot
@dull knot upgrade from 3.8 and it will work
I'm still fairly new to python
How should I do that?
download a more recent python version from https://python.org
Alright lemme try
uninstall asyncio
pip uninstall asyncio
its the original impl of asyncio thats in pypi
!pypi asyncio
lmao that's like 7 years old isn't it
Yeah, I tried that lol
This version is only relevant for Python 3.3, which does not include asyncio in its stdlib.
replit moment
10ish
That's the first thing I tried 
ah i just checked it, it was last updated in 2015
damn
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.
ditch replit and you're all good
Pretty much
Was planning to do that anyways
since when does replit have 3.3? dont they run on 3.8?
Meh, I'll probably leave this be for now. Gotta sleep 
either way isnt disnake python 3.5+ ?
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

setup.py line 81
python_requires=">=3.8.0",```
oh damn
^ @glad cradle
Wouldn't they still be server muted upon rejoining a VC on the server if we don't unmute? I guess I can build in logic where the bot can watch any and all joins and if they are on the list of users who were supposed to be unmuted it will automatically unmute them, that could be a potential solution I will definitely explore
I was just trying to see if a newest version would be send from the bot
yes
yeah it wouldnt appear either way
replit have python 3.10
yeah but iirc default in 3.8 not sure
!d discord.on_guild_join
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.
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
what
!intents
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.
?
same error
Can you show the actual error? im not aware of which one
nice new pic
^
Thanks
it changes nothing
could you send your actual code?
how do u fix
...
how do i send the code here
!paste
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.
!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)
Theres so much wrong in this code
true
how to make the avatar of the author of command in embed in a small picture ?
!d discord.Embed.set_author
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.
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
Erm… this is pretty wrong and has old code
icon_url=None
it is the link to the picture that is needed here
correct
Well, I asked something else
¿
!d discord.User.display_avatar | is this what you need?
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.
if I knew how this is done and what it takes, I wouldn't ask
how to make the avatar of the author of command in embed in a small picture?
did you mean using set_image?
assuming that you have a user or member object
embed.set_author(name=member.display_name, icon_url=member.display_avatar)
an example of what I want to do
!d discord.Embed.set_thumbnail
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.
the image on the right is what youre talking about?
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').```
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?
and also it's ...display_avatar**.url**
they changed it in 2.0?
iirc display_avatar used to return a string
!d discord.Member.display_avatar
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.
no?
isn't it new in 2.0?
it is actually
it wasn't even an str it just never existed
no work
mhm odd
@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)```
it's a kwarg, so you should consider using set_thumbnail(url=...)
yeah i was confusing myself with discord.User.avatar: str | None
embed.set_thumbnail(url = interaction.user.display_avatar.url)
not work
"not work" is not an available description for the problem. You either send an error if you get one, or say what else does it do/print, if it does nothing say that it does nothing
when writing the triggering command, this is written
Команда больше не действительна. Повторите попытку через пару минут.
I don't know where does this message come from. You wrote it yourself, where is it in your code?
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)```
why the f string, the user argument and dunder namespace? are you running the updated state of the command?
slash_command and discord namespace
doesnt nextcord also do the same thing?
or does nextcord not use the discord namespace when imported?
nextcord has nextcord namespace?
you know, it's very stupid to answer a question with a question!
how is that stupid!
How is it stupid? The only thing it fails to is being rude?
which i asked a serious question so it doesnt fall to being rude either
It’s often a very good pedagogical tool
Um, actually, now I feel philosophy 🧐
Experienced teachers will often use a question as an answer to convey something
Its also very rude to question my helping methods yk
or not
Are you calling me a good teacher?
How nice of you
Yes, I am
Some people find it rude answering a question with another question
I suppose, but it’s a useful tool if used in the right manner
OMG such 'teachers' need to be restricted from society
You need to be restricted from society with such disgusting POV
That’s a hot take
I would rather be "restricted" from society than being accepted by it

<@&831776746206265384> here one person shows aggression
hello
man trying to ban himself:(
I think things are fine here
wait didn't this happen today already?
i'm not sure what you're reporting, i've taken a look. DM @novel apex if you have something specific
Reminds me of the line, "When the world turns its back on you, you turn your back on the world."
this is called duplicity. Sometimes you issue a mutation even if the person has not presented proof
we don't blindly mute people. anyway, DM @novel apex please
and this channel can get back to discord bots
Thank you for your time mina, now can we go back to the topic of discord bots, sounds good?
well, maybe you're not. But I have met in your ranks who just does it like that
you can DM @novel apex about that too. but trust me, we read the room before doing anything.
okay
The only time it happens is when a moderator needs to investigate on the issue so the person doesnt continue doing damage
and what do you want to hear about your question ?
the answer?
I would like an answer, of course if you want further help?
that's the answer to him the same
?
how to write it down correctly embed.set_thumbnail(url = f'{interaction.user.display_avatar.url}')
you would reference the attribute as the property returns a string and no string formatting is being used
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(?!?!?!?)
is it a slash command or a prefix command? also what library are you using ?
slash command, pycord
why pycord 😭
same question
slash command. library discord2
btw you don't need the user parameter
it should be
embed.set_thumbnail(url=interaction.user.display_avatar.url)
d-d-d-discord2?
weren't you using pycord?
w-w-what is that?
that's for pycord
!pip discord2
w-w-w-what
for discord.py should be
embed.set_thumbnail(url=interaction.author.display_avatar.url)
anyone can upload a lib/module on pypi, and that's just a fork
now you are outdated
no?
@glad cradle aaaaaa
oh my god THANK YOU ❤️
!d discord.Interaction.user
The user or member that sent the interaction.
true
i use disnake
disnake have author as attribute instead of user
discord.py an pycord doesn't have consistency in that sense
I have the same
you're using discord.py 2.0.1 or discord2 ?
discord.py 2.0.1
why in the description says pycord wth
is your error fixed now?
YEAH.
thank you very much
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
Is listing the cogs so hard? Just do initial_extensions = ('cogs.music',) and loop through it and load extension
like in this example https://gist.github.com/Master326486/6cf48c1ca0509b98e673451e356ba625#setup-hook
what's your running directory
when i saw
myCoolCogs = (
'cogs.mod',
'cogs.cool',
)
i pressed X instantly
what does that mean?
it means you come from java
w-what?
jk, its just camelCase isnt used in python
um, actually, i got this habit from PHP
idk what is about java
i used java too but idk
the tuple shouldve been named with SCREAMING_SNAKE_CASE
nice
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
wdym random attribute?
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

thats odd, youre didnt redefined it right?
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
so it has to be adding a attribute after -9
well more like overwriting it
its changing the value of that original variable right?
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
mhm
how do you even add an attribute to an already created class?
!e
class A:
...
setattr(A, "foo", "bar")
print(A.foo)
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
bar
i've only used setattr once in my entire code base and it's a special admin command i've definitely not triggered
@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
between the two lines
self.id returns what?
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
are you sure its value doesnt return tuple | str ?
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
well since the newly created tuple main_data changes, the only problem i can think of is self.id returning an empty tuple so the tuples new state doesnt differ from the old one and since youre conjoining 2 tuples self.id can return a tuple like so ("name",)
so you didnt joined 2 tuples?
but in the print you did print main_data right?
well name is my username which i already have a field for called username 
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
I mean you can also just do
a.foo = bar
So there's more than one way you could've overwrote it
did a quick search for player.name which didn't show up anywhere in my code
can you maybe show the code?
Is there a chat where they mainly talk about making bots
Like crypto bots or bots to snipe certain items
Right Here!
im not sure about sniping items tho
i-
¯_(ツ)_/¯
i- found it
Its a bot which snipes item at a certain price if another puts it on sale it can be used on online games so ifs quite op
it's exactly what you think it'd be player.name = str(ctx.author) instead of player.username = str(ctx.author
Cause u would resell them for cheaper
so it was just a naming issue?
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
ah i couldnt have noticed because you never showed the code but im happy you got it
what do you mean by selling?
commissions?
all i can say is good luck, if you go on fiverr you'll notice about 100 sellers, selling bots for $5
Your biggest bot, how big is it?
only way to actually make money with commissions is building a fan base first
what are personal crypto bots
(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
Got a responsive userbase?
Yes
So get some vouches. Get on a platform that allows ratings and get rated by them
this turned from discord bots to an investments course
I'm lowkey new to selling the stuff so that's that's I'm asking dumb questions
Thanks for the feedback though
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
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
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
did someone called me?
jk im broke😔
😭 😭 dw me too i'm on minimum wage
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
youre going to see me writing code on a rock because i cant pay for a computer and IDE😭
Ide is free mate?
pycharm, fleet and sublime licensing moment
vsc is fine?
i cant pay for a computer
now lets not make a OT discussion about a joke lol
@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(...) ?
Wouldn't you just send the view as normal?
mh it should just be await interaction.response.send_message coz an interaction in a server or in dms should be the same thing
be sure to set your slash command as usable in dms
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
Just try lol
#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
discord.Colour.red()
u missed the ()
also if u can just use f"{interaction.user}"
no need to get name and discriminator seperately
f string concatenation😔
Is there any documentation for vote rewards?
Just depends on the provider you're going with
Different discord bot boards will have different APIs for it
how long does it take to register a slash command?
It should be instant
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
did you sync the command tree? and is the group added in the command tree
tree.add_command(Mod(), guild=discord.Object(id=BRI_ID))
```?
@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
"did you sync the command tree"?
you need to use setup_hook, check the channel pins it has a guide to slash commands
nice
someone uses a command that does not exist, so ctx.command is None
you should be using ctx.invoked_with here
!d discord.ext.commands.Context.invoked_with
The command name that triggered this invocation. Useful for finding out which alias called the command.
I think CommandNotFound is the exception
yes
that worked! thank you so much
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?
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
is there a method for discord.ext.commands.Bot?
Theres many
you just declare a method? as discord.ext.commands.Bot.event uses setattr to set the method to itself
yeah
can i put events in cogs? if so, how do i do it?
I was wondering if it is possible to use @bot.event
in a cog for discord.py. I have tried doing
@self.bot.event
async def on_member_join(self, ctx, member):
channel = discord.utils.get(me...
nvm lol
bruh use commands.Cog.listener if you're in a cog
Hi sarth
Hi Samandra
Hi bero
Hi
I can't get the slash 4.2.1 commands even using Ash's github
So, today it's a revolution day for us bot dev
what
The command permission system seems very cool
I can't get the slash commands 4.2.1 even using Ash's github
I don't know what are you talkin about lmao
4.2.1 wtf is that
The slash commands with discord.py 2.0.1
delete everything except discord.py :bruh:
yup
why would you need that all
I'm only looking to use the slash commands with discord.py 2.0.1
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
!d discord.app_commands.command
@discord.app_commands.command(*, name=..., description=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command from a regular function.
what is SlashBot? Is that your subclass?
yup, or an instance of Bot
if he followed ash code is probably a subclass
I don't know
!d discord.app_commands.rename bruh wtf is this
@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}')
hey!
i mean, why even do this
helpful (almost)
personally think its really nice
for example if you want commands in diff language
for example if you want a slash command argument named "list", you can't do that without using this
that too
but again im not a big fan of discord.py slash commands lol
me no care i just use hybrid and me gud
they could have used something like var = app_commands.Option(name="foo")
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.
disnake is way more cool
@unkempt canyon takes his time...
cuz disnake is too much to handle even for him
I can't figure out why I changed so much for nothing 😦
ah the alias is not added in discord.py
!d discord.ext.commands.Parameter they took it from here
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.
And this makes that thing a lot more weird now lmao
its for the commands extension tho lmao, makes things like default args which utilise ctx easier
!d discord.ext.commands.parameter
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:')
like this one
in earlier versions you would set to to None by default and then use to or ctx.author
hmm but this looks kinda ugly i would rather use the or
same, i would only use parameter for a description, which I don't need cus of app_commands.describe
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
I'd prefer declaring a single ```py
conv = lambda ctx: ctx.author
and using
commands.param(default=conv)
what's the point of setting Optional to None and what's the point of that if member or itx.author is shorter and does the same?
PyCharm will say don't use raw lambda, use def
thats why you don't use pycharm
just use vscode and live your life
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
Optional is just the typehint, None sets the default value
typehints can save your code, always remember that, always use them
i find Optional typehints ugly so i just use type | None
BRUH no that is absolutely ugly lmao
saves keystrokes
i import typing as t whenever i want to use it, don't know if its a bad practice or not
you do import typing as t? lmao
I do from ... import ... almost for everything
T is used in typing.TypeVar
I think the only exception is discord, I import it, but probably I'll get rid even of that
!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)))
@placid skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | <class 'str'>
002 | <class 'int'>
yeah who tf is going to type typing.Callable all the time
that's why you do from typing import Callable
I always ask myself why most people do from discord.ext import commands
i mean, everything that is useful is inside the commands module, just do this: from discord.ext.commands import *
imagine doing @commands.command when you can just type @command
or doing if isinstance(error, commands.MissingPermission): instead of if isinstance(error, MissingPermission):
🗿too lazy, i don't want my src to end up like discord.py
15 lines just to import some stuff for typing
and then you don't know how Union and hundreds of other stuff came into your code
you can literally use discord.utils.Union instead of typing.Union because of the import structure in utils.py
tbh it is how everyone should import things, you should not import classes or modules that you don't really need
but there you will not import discord.utils lmao
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.
yeah but then you will have to type typing everytime you want to use that classes
yeah.. thats why i import it as t
i mean, we're devs, we're not noticed for how much we're active, we're noticed for how much we're lazy 
hmm i am gonna try and clean up my imports today
🫂
lmao
sarth downloaded pydroid 👀
so is pydroid like 1gb to download;-;
what is that
A funny package named hikari
how funny
Like brainfuck
dang very funny
!pip hikari
lightbulb is a command handler for hikari, just like discord.py has discord.ext.commands
it write in data2 but doest pop data 1
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
How to fix this?
this error isn't related to discord bots
It is
could you show your full file structure, especially relative to your main.py
yea
i was gonna ask for the file structure
try doing, with open('DisnakeMusicBot/bot_utils/config.json")
great, so you should be using "DisnakeMusicBot/bot_utils/config
json"
if you don't want to change the path in code^
Okay tysm let me try this
if this doesn't work just remove the ./
that's what i've said originally
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 🤓
💀 are you like cloning libraries? jishaku doesn't really need to be in your bot files.
they manually installing them to save storage fr
yeah true, but since this Server is general python based we help with other stuff too ( unless it goes totally offtopic)
don't we talk about totally offtopic stuff here a lot?
offtopic help, imagine someone popping with a "how to fix this pytorch error" question
what do I do? I'm getting this error ModuleNotFoundError: Module 'yomama' not found. I'm making a web game with cats jumping all around, help pls
create a txt file named mum.txt with yomama in it
and pip install -Ur mum.txt
ok, thx, ill try
now i'm getting this error: SuckItMoronError: yomama is too big to be held in just a .txt file. Btw I decided to remake my game so now it's about raining cats and dogs, if that matters
use json instead of txt then
how
This is not a Modmail thread.
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?
what
doesn't every bot dev know that message content intent is now privileged
if your bot is verified and doesn't have an access to message content intent from discord then yes
my verified bot does work with prefixes, well i got message content intents for a month now. not hard to get tho
How can I check if any message has a certain reaction?
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
they asked about reactions
!d discord.Message.reactions
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
this returns a list of Reaction objects, you can access reaction.emoji
Lmao sorry i blacked out for a moment
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.
the only change will be enabling that intent from https://discord.dev
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Guys heroku is shutting down, do you guys know any other free hosting services
aws has a free year trial
Do i call this on on_message or when do i do it?
is there anything that is free forever though
uhm... I think repl.it is the only one, but it is trash
very nice
hey is there a way to put a webGL application into an embed
what exactly do you want?
you cannot put an application into an embed
only certain fields
thumbnail. image. author etc
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
what do you mean by webGL application?
iirc it's a visualizer of 3D graphics
or smth like that
im thinking of idk if your familiar with unity ?
it's opengl for the web
uhm, I am, but I didn't develop anything more serious than square jumping
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
uhm, i dont think you can have games more detailed than some minesweeper for example
like, how would that look like?
with that stuff we have in bots
How do I check if a message is replying to another message?
!d discord.Message.reference has information about a reply
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.
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
wth
Does this just return ID or what does it return?
<MessageReference message_id= channel_id= guild_id=>
!d discord.MessageReference
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.
and from it you can get message_id, channel_id and guild_id
is it possible not to use the database for private sessions ?
What do you mean by "private sessions"
Do you know how i could get attachments from a message id?
private voice
😳 private sessions?
private voice
What do you mean by "private voice"?
when you enter the voice channel. and he creates your channel for you that you can edit
wha-?
uhm... not from message id but from message, and you can get message from it's id
when you enter the voice channel. and he creates your channel for you that you can edit
still don't understand what do you want
can I write this to you in Russian ?
uhm, ok, but in DMs
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]
fetch_message is async, you have to await it
Then i can just use message.attachments?
wha
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
why are you asking? You have the correct code right now, you just need to await the fetch_message
Guild ID doesnt exist
there is no that_guild_id in your dict
!d dict.get
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").
Now discord is killing the moderation bots
no message content and auto mod they don't want any mod bots
i hope they don't remove the endpoints
@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 ?
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!!!
not mean
@silk fulcrum will I be able to transfer these variables from the event to the select menu ?
just helps, if you want a multipurpose bot atleast you won't have to implement those features ig
oh... I was confused how could you make such a good code on your own, even tho it has time.time() in it. but now I get it, you stole it from internet
sad plot twist
what do you mean? how do you imagine that?
and that is why we throw docs and "learn python" in you, so you can make code on your own
well, just in the select menu there will be an item that will show how long the author of the command has been in the voice channel
well, that is possible, but I'm pretty sure that you don't clearly understand how that code you have works, so you won't clearly understand what I'm saying
I'm just writing through a translator, so it's not clear what exactly I mean
How is that connected to that you don't understand how your code works?
with the fact that I can explain wrong what exactly I mean
Uh, guys help. 
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
I mean... I can explain what you have to do to get what you want:
- Have
on_voice_state_updateevent and save the time user joined the voice channel, like you already have (but withdiscord.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 dotime_now - join_time, that will be the time they spent in the voice channel
Do you understand what to do?
.env file ```
TOKEN = "YOUE TOKEN HERE"
How to get the env?
`pip install python-dotenv`
```py
# your python file
import os, dotenv
dotenv.load_dotenv()
token = os.getenv("TOKEN")
Aight. Lemme try that.
Installing dotenv in the cmd prompt works just as how it would on the terminal, right?
yep
Taking long to install lol. but I'ma wait
ig
but my bot requires attachments, which means message.content, which really sucks :(
You know if you can hide env files on github?
.gitignore?
no you can't hide it on GitHub, just don't commit it there ( use a
gitignore file)
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
i just store bot tokens in their dms and it helps lol, why store them on GitHub
tokens in DMs
yeah lol
Where exactly? Your explanation is making me a bit confused
^^
If you want to add all the items from one list into another list you can use .extend instead
If you append a list to a list, it'll be a list in a list
!e
lst1 = []
lst2 = []
lst1.append(lst2)
print(lst1)
@rocky trench :white_check_mark: Your 3.11 eval job has completed with return code 0.
[[]]
!e
print(1)
Okay, sorry for misunderstanding. I kinda get that. Maybe I wrongly like wrote the sentance, I mean't like instead of .append() and .pop() I need to make an assignment.
Well .pop returns the popped value
!e
a = list(range(10))
print(a.pop())
@winged coral :white_check_mark: Your 3.11 eval job has completed with return code 0.
9
And if you're appending a value then you already have the value
Guys lol. How... Sorry, Pretty basic mistake but it's my first time working with VS Code and Env files
You already got an answer for this?
what do you have in .env?
@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
just DC_TOKEN = "Bot Token"
and its not giving any error message
Imagine discord creating own economy system
where did okimii go?
b-b-b-bruh
we all miss him, he left discord and other socials
Remove the "" and spaces around =
NOOOOO WHAT
Ah, alright. Lemme try
Improper token has been passed
he left us... 😭
Regenerate token on dev portal and put the new one to env file ig
Or maybe you pasted something other than token
Like client secret
Wym?
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
did they just disable prefix commands?
no
If your bot is verified and doesn't have access to message content intent, then yeah, they don't work
My bot is not verfified and has access to messange content intent
It stopped working around 13 gmt
did you enable message_content intents in your code?
yea
how do i check dpy version
pip show discord.py
1.7.3
1.7.3 won't work for message commands anylonger
unless you use bot mention as the prefix
so, how do i upgrade to 2.0
pip install -U discord.py
1.7 is using an older gateway so you'd still receive message content if you have it enabled in dev portal
the version has breaking changes
though afaik gateway v6 will be removed in 2023
the intent value won't suffice for message content intent in the payload, will it?
v6 doesnt know the message content intent exists
dpy 1.7.3 uses v7 tho
Bot can no longer send message using ctx though 🤨
Sure it can
doesnt work however
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.```
ah i see
i actually thought they were the same but apparently not, that or its misdocumented cause i wouldnt understand how it works
well either way the message content intent is enforced in v10 as per the gateway intents page https://discord.com/developers/docs/topics/gateway#gateway-intents
In 2.0, the message content intent isnt enabled by default, but you can still enable it
At least in the Intents object
yeah
Yeah, you said that. Gotta start scrolling up.
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

you can create an ephemeral response instead
thanks a lot for this information!!!
I'm just transferring all the commands to slash commands and I'm having problems. With a translation command that clears the chat

58,399
295,940