#discord-bots
1 messages · Page 768 of 1
Wouldn’t instance passing voice channels be the same thing as just looking at text channels with guild.text_channels?
yeah yeah, I was just giving you an example, I'm sorry
Okay was just making sure there’s no preformance or api call count advantage lol.
*concurrently
there isnt
well, Dan, Ashley, I'm still stuck with my emoticon. I've tried to send :white-check-mark:, \u2705, it still errors out with AttributeError: 'NoneType' object has no attribute 'add_reaction'
you dont have a message instance
Gifs are simply urls that expand into the video/photo.
As for emotes, you can declare them as a discord.PartialEmoji like this: emote = discord.PartialEmoji(name = 'foo', id = 123)
✅ is \U00002705
You can also add the emote the alternative way, as ashley said: message.add_reaction('✅')
I have a FastAPI app that's hosted in a docker-compose with my discord.py app - say I have a route
http://localhost:8000/test-route/
How do I make a post request properly to it? I got returned
ClientConnectorError: Cannot connect to host localhost:8000 ssl:default [Connect call failed ('127.0.0.1', 8000)]
with the following in aiohttp:
async with aiohttp.ClientSession() as session:
url = await session.post(f"http://localhost:8000/test-route/")
any ideas?
Okay 🙂 Thanks!
yeah I tried with \U00002705 as well, along wiht \✅ aand what not. always keeps going back to NoneType object has no attribute 'add_reaction'
also, can't do this in my editor message.add_reaction('✅')
Oh I just realised the issue is your message is None lmao
Could you send your code please
yeah sure
@quaint scaffold https://www.toptal.com/developers/hastebin/olalasevos.py
huh your code should be fine, I don't use disnake but msg shouldn't be None
Perhaps you could ask in the disnake support server
honestly I've no idea what's going on, but I can't get it to work 😅
yeah that's a good idea, will check them out
how do i define an emoji?
yo
@commands.command(name="gamble")
async def gamble(self, ctx):
print("Gambling")
channel = bot.get_channel(934495060987359272)
message1 = await ctx.send("Test")
message = await channel.fetch_message(message1)
print(message)
returns this error In message_id: Value "<Message id=934496566448914462 channel=<TextChannel id=934495060987359272 name='gambling' position=41 nsfw=False news=False category_id=915357451484790917> type=<MessageType.default: 0> author=<Member id=915593618520158299 name='Cosmic Overground' discriminator='5232' bot=True nick=None guild=<Guild id=915357451484790916 name='Cosmic Overground (Private)' shard_id=None chunked=True member_count=10>> flags=<MessageFlags value=0>>" is not snowflake.
anyone got any idea
I have answered this question already
This code is so cursed. How is bot defined when it's in a class? Why are you fetching a discord.Message object?
hey y'all,
can someone help me regarding how to check if a member has left a particular vc, this is what I've tried so far -
@client.event
async def on_voice_state_update(member, before, after):
if not after.channel and before.channel.id == vc_id:
print('success!')
<:emoji_name:emoji_id> i meant this @quaint scaffold
hey
im having trouble with slash commands
from pydoc import describe
from discord import Embed
import nextcord
from discord.ext.commands import Bot, Cog
from discord_slash import cog_ext, SlashContext
from nextcord.ext import commands
from nextcord import Embed
class slash(Cog):
def __init__(self, bot: Bot):
self.bot = bot
guild_ids = [930186574078017597]
@cog_ext.cog_slash(name="test", guild_ids=guild_ids)
async def _test(self, ctx: SlashContext):
embed = Embed(title="Embed Test")
await ctx.send(embed=embed)
@commands.Cog.listener()
async def on_ready(self):
print('Slash loaded!')
def setup(bot):
bot.add_cog(slash(bot))
this is my code
try this-
@commands.command(name="gamble")
async def gamble(self, ctx):
print("Gambling")
guild = ctx.guld
channel = discord.utils.get(guild.channels, id=934495060987359272)
message1 = await ctx.send("Test")
message = await channel.fetch_message(message1)
print(message)
and why are you trying to fetch a message after sending it?
are you getting any error?
no
hmmm
so it's just not working?
ic
soo any solution?
Fixed it
dw
yo how would I get a animated emoji link? like this one 
I haven't worked a lot with discord_slash, but you can try this code mb -
import discord
from discord.ext import commands
from discord_slash import SlashCommand
intents = discord.Intents.all()
client = commands.Bot(command_prefix=".", intents=intents)
slash = SlashCommand(client, sync_commands=True)
guilds_ids = [930186574078017597]
@client.event
async def on_message(message):
# Slash commands are an extra class but you can recognize them as commands as they got no message content using the on_message function
@slash.slash(name="test", guild_ids=guild_ids)
async def test(ctx):
embed = Embed(title="Embed Test")
await ctx.send(embed=embed)
emoji link?
you mean something like this -
https://cdn.discordapp.com/emojis/795157965304496158.gif?size=56&quality=lossless ?
aight
i am trying to display the roles and channels of a server, i have 3 roles and 2 channels and it returns this:
i am using the len() function
@commands.command(name="serverinfo")
@commands.cooldown(rate=1, per=30)
async def serverinfo(self, ctx:commands.Context):
embed=discord.Embed(title=f"{ctx.guild.name}", color=0x387ba2)
embed.set_thumbnail(url=f"{ctx.guild.icon}")
embed.add_field(name="Member Count", value=f"{ctx.guild.member_count}", inline=True)
embed.add_field(name="Owner", value=f"{ctx.guild.owner}", inline=True)
embed.add_field(name="Roles", value=len(f"{ctx.guild.roles}"), inline=True)
embed.add_field(name="Channels", value=len(f"{ctx.guild.channels}"), inline=True)
await ctx.send(embed=embed)
You are encapsulating the entire string in your len()
oh
The .roles attribute will return a very long string of discord.Role objects. It'll be very long.
i see
embed.add_field(name="Roles", value=(len(f"{ctx.guild.roles}")), inline=True)```
?
Yes, but why are you encapsulating all of that in brackets?
You should learn Python, you are jumping from no fundamental knowledge to asynchronous bot programming
ok sorry
where can i start python i have 0 programming knowledge
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
can someone help me
@bot.command()
async def nick(ctx, member : discord.Member = None, nick = None):
if member == None:
member = ctx.author
await member.edit(nick=nick)
await ctx.reply(f"Nickname was changed for {member.mention} ")
i want it so when u dont mention member
it changes ur nick
and when u mention a member it changes the members nick
Use Optional and an or
i am now watching this 4 hour basics python course https://www.youtube.com/watch?v=rfscVS0vtbw
This course will give you a full introduction into all of the core concepts in python. Follow along with the videos and you'll be a python programmer in no time!
Want more from Mike? He's starting a coding RPG/Bootcamp - https://simulator.dev/
⭐️ Contents ⭐
⌨️ (0:00) Introduction
⌨️ (1:45) Installing Python & PyCharm
⌨️ (6:40) Setup & Hello Wor...
!e py print(bool(None))
@quaint scaffold :white_check_mark: Your eval job has completed with return code 0.
False
Here's a clue
can u help me Dan
I just did
where
ok i will use this then https://dabeaz-course.github.io/practical-python/
Ignore what I just said there, perhaps those videos are good for a start
But for more complex things, don't use videos
-_-
!e py foo = None or 'hi' print(foo)
@quaint scaffold :white_check_mark: Your eval job has completed with return code 0.
hi
And use Optional[discord.Member] for your typehint
-_-
okay, tysm
I'm so funny
please laugh

are you thick?
I'm trying to help you and you're just responding with -_-
Then tell me what you don't understand
that optional thing
I'm not telepathic unfortunately
oh thats sad
you cant have an optional argument prior required arguments
how can I have markdown support in my eval command
anyway to limit button usage 1 per user in discord.py
Use a database
yeah would do so then
what is considered basic knowledge for creating discord bots?
knowledge of OOP, asynchronous functions
and basic python
no
thats perfectly valid assuming :red: is a valid emoji
which it is
lol what?
well it just pops up as :red :
I hate to break the bad news to you, but RAM is volatile
you can do it like that or get an emoji object
whole path
I hate to break the bad news to you, but buttons normally break after bot shuts down
Help, it doesn't work uhh?
depending on what Metal is doing
!d discord.ext.commands.Bot.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
I hate to break the bad good news to you, but persistent views exist
where do I put it
perhaps try sending emojis with that method
you need emoji intents i believe
how to enable that ;-;
he probably has that
how do you use other get_x methods?
intents=intents
what is intents
does on_member_leave exist?
client = commands.Bot(command_prefix='.', intents=intents)
the emoji intent is enabled by default
!d discord.on_member_remove
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.

dont believe so
intents = disnake.Intents.default()
intents.members = True
ty
@manic wing
I know so
@manic wing
!d discord.Intents.emojis
Alias of emojis_and_stickers.
Changed in version 2.0: Changed to an alias.
I hate to break the rude good news, but i am superior to you
!d discord.Intents.emojis_and_stickers
Whether guild emoji and sticker related events are enabled.
New in version 2.0.
This corresponds to the following events:
lolol
@quaint scaffold are you new to this channel? havent seen you around
I've started helping here a few days ago
Caeden indeed good helpr :thumbsup_tone5:

you doubt my prowess
for x in range(0,5):
if number == 0:
time.sleep(1)
embed_dict = startMessage.to_dict()
for field in embed_dict["fields"]:
if field["name"] == "STATUS":
field["value"] = "**ROLLING**"
rolling = True
if rolling == True:
e = 1
for x in range (0,100):
embed_dict = startMessage.to_dict()
for field in embed_dict["fields"]:
if field["name"] == "STAKE":
time.sleep(0.1)
field["value"] = str(e)
e = e + 1
```
why does this not initiate the cool down periodically? right now it just waits 10 seconds then sends the message "100" instead of counting its way up
I do, when you use disnake and call someone inferior when you are wrong about a concept :)
the discord.py has descontinued?
discord bots channel
Yes
complete python code
yes since august 28th
what is the newest ?
You can use forks of it
disnake prolly
i would recommend pycord
disagree
i am not wrong
to each their own
what's wrong with disnake though
Caches are volatile
who said a) the bot was turning off b) it was a button that was going to be resilient
we lack context, therefore you are not correct
Pycord is regarded as on of the worse forks
oh, the best ones are?
- i am always superior
Disnake is pretty good
Basic python is variables, data types, loops, boolean, etc?
can anyone take a look rq?
SCOPING is important
dont use time
time is sync and will stop your whole code
use
await asyncio.sleep(1.0)
which sleeps on the coro only
yeah 
don't you want to start rolling from 1? seems user-friendlier
still does the same thing, it just waits 10 seconds to count up to 100 then edits the message
just testing it right now
you don't want to edit a message every 10 secs, that'll get you ratelimited
counting in general is a bad idea
rolling = True
if rolling == True:```?
uhuh, typehinting, and stuff
I mean I am trying to edit it every 0.1 seconds, but it just doesn't edit until it completes the loop and I don't know why
No it won't the message edit endpoint is 5/5s
don't edit, that's it
if a is True:
and not
if a == True:
it works for other things 😭
yeah, but imagine running 5 editing commands in parallel
for now...
I wouldn't need to
not really
editing messages every x seconds is a bad idea, there's a reason you haven't seen it in other bots
The discord.py ratelimiter won't let it get ratelimited anyways
They lock the bucket once it gets depleted
its just for 1 thing lol
Locking it won't let any other threads enter
in that case, the countdown / timer is useless
you should always compare something with bool with is
OOP are classes attributes and methods?
and subclasses
No not really, your requests need to actually be called, you're saving yourself extra requests
The handler only handles the ratelimits
Inheritance?
a bool can be as simple as
shit = True
if shit:
print("shit is True")
fart = False
if not fart:
print("fart is False")```
yes
Parent child
i love your var naming
that example bro
I won't ever change my examples
love them
better than foo or bar or whatever they use in normal docs
fax
wdym by this?
let's say you edit a message 10 times within 5 secs, then it'll just "not work" since the there's a ratelimit of 5/5s
@command(
aliases=[
"kickhammer",
"userkick",
"memberkick",
"banmember",
"banuser"
]
)
async def kick(
self,
ctx: Context,
member: Member,
*,
reason: str = "No Reason Provided"
) -> Optional[Message]:
if ctx.author.id == member.id:
return await ctx.send(
f"{ctx.author.mention} you cannot ban yourself"
)
await ctx.send(
f"Would you like to kick {member.mention}",
view=KickConfirmation(
ctx.author,
member,
reason
)
)
my commands look like this to follow pep8😭
command = bot.command?
no i imported command
from disnake.ui import (
View,
button,
Button,
)
from disnake.ext.commands import(
Cog,
Bot,
command,
Context
)
from disnake import (
MessageInteraction,
Member,
ButtonStyle,
Message
)
from typing import Optional

🧐
import with () ?
pep8s max line is 72😔
that's a damn lot of imports
yeah
never seen that
yes
helpful
very nice
Can’t say I use that feature though
it's optional
like if (shit):
ig
and why are you typehinting ctx
^
ig for the autocomplete / intellisense
if member == ctx.author is also enough 
Yes, but you still SEND the request
It's not like you send the request and magically discord.py intercepts it from being sent to stop you from being ratelimited
well, you basically mean dpy tells you WHEN you got ratelimited instead of preventing you?
and you missed a ? in the last send() 😠
how can i add slash commands to my bot?
It prevents you from sending more requests when a bucket is depleted thus preventing ratelimits, but it isn't always 100%
And it also handles 429s (ratelimit) responses to stop you further afterwards
Depends if your lib supports them. Most dpy forks do or are developing them
nice to know but I've seen enough people get ratelimited even though dpy "handles" it
Again you don't seem to understand what the ratelimiter actually does
i have buttons to confirm a kick
It HANDLES the ratelimits
like confirm and cancel
smort🧠
hm
and i pass the author and the member and the reason to the view class and i do it within the View subclass
I don't 😈 😈
😳 bro
I would like to learn using buttons so much
hi
I'll start doing that
then learn how to
i know about buttons
hi
I don't
It is great for users but some serious shit for devs

definitely
class KickConfirmation(View):
def __init__(
self,
author: Member,
member: Member,
reason: str
) -> None:
self.member = member
self.author = author
self.reason = reason
super().__init__(timeout=60.0)
async def on_timeout(self) -> None:
self.stop()
async def interaction_check(
self,
interaction: MessageInteraction
) -> bool:
if interaction.author != self.author:
return False
return True
@button(
label="Confirm",
style=ButtonStyle,
emoji="✅"
)
async def confirmcallback(
self,
interaction: MessageInteraction,
button: Button
) -> None:
await interaction.send(
f"You have Confirmed to kick {self.member.name}",
ephemeral=True
)
await self.member.kick(
reason=self.reason
)
self.stop()
see
basic button
okimii
copied the whole thing
no
now I have your code
dude wtf is that
beware
🏃
async def on_timeout(self) -> None:
for child in self.children:
child.disabled = True
``` this wont actually make the buttons disabled - you need to edit the message
thanks for the code g
I'm a professional stackoverflow copy paster
allow me to redistribute

ik hold up
Aren’t all developers
🧠
Is your code written like that as a joke?
no
Or do you genuinely try to make it as long as possible
I don't like doing that

yeah, better devs only know better what to copy paste
i have to follow pep8s max line
You don't have to follow shit
Devise your own style of programming, take what you find useful from PEP8
I do not like your kind of language
seems like we have an anti-statictyper
Lol it might be a problem when you start working in a company

no
i go by the rules
exactly youre smort you get me
used self.stop() to lazy
Btw why did u disable the buttons on on_timeout method?
changed it
i did it at 4am last night so i was high
It's no use ig 
huh
thats not nice
@manic wing i used jarvide for the imports so dont sue me
Lol don't foget to sleep because of programming
caeden is the type of guy who would
Take care of your health 🙂
😡 😡
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.

thats not nice
Dude we are not discussing
about me is trash
sorry
just subclass the bot class in your about me🧠
what
#ot0-psvm’s-eternal-disapproval please guys
?
?
_BotBase
the amount of times this chat has gone off-topic is wild
nobody's asking for help
were all humans give us a break
who said we are humans 🧐
were all friendly unlike the dpy server🏃
😳
true
what if we are cyborgs but look like humans
good point
well made and well reasoned
😳
And we eliminated humans a while ago

🧠
Damn 👀
and pigeons are russian spies with cameras and batteries
Jk lol don't mind
This has been confirmed already
One of my fav gif nowadays
y'all have to stop watching c# stackoverflow codes
really?
~~runs in ruby 🏃 ~~
Didn't work 🤣 🤣
:hmmcat:
runs in Python, c# and rust
🏃
runs in shoes
Runs on basketball court
Lol
**levitates ** 🕴️
___________________________________________
who wants to teach me buttons
basic subclassing
Sorry dude can't teach now

Battery on 20%
can't learn now
🤌
meet you in 3 hours
be smort and red https://github.com/DisnakeDev/disnake/tree/master/examples/views
🧠
infront of the school
😳
andy youre to smort
class Buttons(lib.ui.View):
def init(self):
super().init()
@ui.button()
Shit I tagged someone
no it's just easy to read the source code
you forgot the super
I find them better than examples
mhmm ik
boi wut the hell boi
I’m on phone so I’m not gonna bother to add
i should do that

you dont need super for a simple view class
you need it to inherit children
The list of children attached to this view.
Without the constructing the super classes constructor, you won't have the children attributes
Unless otherwise giving it to your subclass
yeah
And internally your wrapper of choice will iterate through the children of your view to add them
Thus either way, constructing the super class or adding the attribute manually is needed
how the heck you know that?
🚶
understanding what you just said would be sexy
sure
not needed
those indents
only call super when using methods/attrs from the subclassed class
Your using disnake that's why
cause you arent disabling buttons
yes?
you do tho
^
Yes disnake seems to have fixed this
no?
If you take a look at discord.pys examples you see them call the super classes constructor
that is what I just said
so you basically said to use super
yes
yes
https://github.com/DisnakeDev/disnake/blob/2b5635fb4bb2d864624332e63cb2e09bf78b3e8d/disnake/ui/view.py#L154-L159 Here seems to be the fix for why disnake does not need you to call super().__init__(...)
disnake/ui/view.py lines 154 to 159
def __init_subclass__(cls) -> None:
children: List[ItemCallbackType] = []
for base in reversed(cls.__mro__):
for member in base.__dict__.values():
if hasattr(member, "__discord_ui_model_type__"):
children.append(member)```
They iterate through the methods of your subclass
and the decorator marks the callbacks you make as components
so what do you actually need
Differs from wrappers, if you are using discord.py you do indeed need to call the super classes constructor, if your using disnake you don't need to
so only your own stuff
huh
useless on_timeout
in cogs, defining the bot as self.bot is needed
yeah i fixed it a while ago
- your own stuff are optional
thats not a cog
thats a subclass of View which doesnt need bot lol
here, in views, everything's optional
ik -_-
then why say about self.bot lol
cuz I wanna know if anything's necessary
ah
so I used an example to define what I meant
well no bot isnt needed
ah
Where to put it?
Where to put it
lovely type hints
I new
I don't want to see that
!pep 484
never again
me either
member= 👁️👁️


I put an n to ever to make it incorrect
and you didn't put an n to make it incorrect
wut
where
can you even make an embed without a description
How I mention in embed message the user using the command
you mean the author
and with f string in the description
Yes I think
you can't do that in the title!!4!!!4!
f"{ctx.author.mention} hello"
yeah thats why i said description lol
I pointed it out
yeah ik
teamworks makes perfect
yes
🫂
no homo
right

no
yes bro😔
🤫
😉
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
i found the solution
we're done
😔
i can be your homie <33
i tried to use len() to find the number of roles in a server, i realized i had to make a new variable to use () correctly and just make a new field displaying the variable i made
that's what I thought
How can i use config.json data??
🙇♂️
i want to use config.json for take prefix or smthng
i know
then why use it
then put it in code
Yea but i want to use json file for now
you do you but im its not a good way at all
Yes i already want this but idk how to take specific datas...
i'm beginner so i'm starting from basic
bot = commands.Bot(command_prefix="!")
dbs arent hard to learn and will help you with the future
i know this too.... But i want to take from JSON!!!!
Smh i knows basic discord.py
json is not for storing data.
Yes i know
okay but if you can't change the prefix then why store it in a json
why not just put it in the kwarg
i know
then why not use a db.
when i learn basic db i'm gonna use this

it is hard for me ( i didn't start learn)
databases are easy no kappa
once starting a career as a programmer, no one will allow you to use a json
yes dbs are scary at first but when you learn it its all easy all you got to do is get out of your comforts zone and focus
for a db
Not working
error? show
SQl is not hard and is very useful
yeah
well it gets harder when you have to long queries with joins and shit lmao
Yes but json is very very basic and if i don't knows how to use json file... not will be good
uhh
joins are a bit confusing but not that much
U r right
nobody uses json for storing data
try it will it hurt?
^
except websites
is it in a on message?
use sqlite
^
K i'm gonna try then thx :))
Yes
the traceback says it homie
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
basic oop
best of luck i know you can do it ❤️
postgres > all
Why not should I start from mongodb?
mention the user using the command
mongo is a document db
well if you want go for it
it’s similar to json
really doesnt matter lol but sql is like more standard tbh
but rdbms’s are more generally used
Nah
use an object oriented/rdbms db, since that's parallel with dpy
yes
most companies use postgres lol
Choose from:
- MySQL
- sql server
- MSSQL
- oracle
- SQLite
- postgresql
SQLite is prolly best for beginner
- async wrapper
but if you are use their async bridges ofc
yes
bruh
Yes i'll start
He said “blocking is not necessarily bad”
Also mySQL and SQL are different??
SQL is the language used to make wqueries
sql is the language
MySQL is a database
^
my backend skills coming out 😮
just check out sql, start from there
^
What about noSQL?
👍
NoSQL are Dbs like mongo
don't worry about that yet
you do sqlite is the module that gets used to store data in a file which you will need a async bridge to not block the bot from any data exchange
K then
if you know how to set up tables(decent db structures) and do CRUD operations, you're golden as a beginner
mhmm
if you know how to update, add, take, delete data youre good
Triggers
How fix that
No.... Lol
You are not allowed to use that command here. Please use the #bot-commands channel instead.
I told you
🧍♂️
that's literally all you'll ever need for your current project
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
Don’t worry about joins and shit
a pain
you’ll not use that a lot in a simple bot
yeah
nah youre crazy
did you put the f there
🙃
read my about me
😠
No... I now
great
i told it many times stop ignoring me😠
read my about me smh😠
why is it in a code block
Inline code blocks
yes
thank you
and the top msg isnt how you mention a user
@pastel pike is how you do it
Considering you have ID, I guess you can simply use .mention
^
you have 2782 pings
LMAO
the field
.
DRG מאתה עושה פה?
Please English only.
Ok
assuming your variable is named reason
did you just say im a dumbass
No, asking what they're doing here.
use db
that wouldve been funny
why tomorrow
What do you get as output.
What is saved in the variable words
repl and json
How does your JSON file look like.
What is the content of the gradepoints.json
Completely empty?
hello im new to python and im looking for help for my boot
@bot.command()
async def unban(ctx, member:discord.Member = None):
if (member == None):
await ctx.send("Vous devez entrer un @ d'utilisateur valide.")
else:
await member.unban()
await ctx.send("Vous avez débanni {member} !")```
You need to have at least {} in that file.
with open("gradepoints.json", 'w') as f:
user[str(grade.id)]['points'] = user[str(grade.id)]['points'] + 1
with open('gradepoints.json', 'w') as f:
json.dump(user, f)
Why opening twice the file when you can directly overwrite (.dump()) it after increasing the amount by 1?
i don't understand why it is not working if anyone can explain me thanks
my error is: discord.ext.commands.errors.MemberNotFound: Member "@tall sandal" not found.
no need for the () in the if statement and no need for else
intents
do you have members intents?
it doesn't matter.
You open the same file twice.
Open it only once and do your manipulation.
what it means ?
!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 the Members and Presences intents, which are needed for events such as on_member 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.
wut
Well, there's one small issue.
theres a cooldown
You never read the file content :p
How do I do the reason?
is reason an argument?
Add your variable after =
he's doing this in on_message
No, the reason they called the staff I'm doing a command to call the staff
bruh
use commands
he don have it
You need to take a better look at how JSON and Python themselves works as you can change the entire command.
Here is a decent tutorial for JSON: https://stackabuse.com/reading-and-writing-json-to-a-file-in-python/
Whereas for Python, you can see some resources here: https://www.pythondiscord.com/resources/
and thats a coro lol
How does your command function look like?
me ignored
As I said.
how i fix the ''REASON ''
Are you using commands?
you can set a bracket
means
a += 1
a = a + 1
it's just + 1, not +=1 probably
you're doing
shit = shit += 1
just do
shit += 1
You need to understand how JSON look like and how Python works better.
like this
now I look ignorant
How can i add reaction if message == "....":
!e
my_str = "!help aaaaaa bbbb"
print(my_str.split(" ")[1:])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
aaaaaa
However, consider using commands.
its basic python?
on_message event is what you need
you'll check the content of every message that's not from a bot
i did but not worked
Ah i used it as command...
!e
a = 1
if a == 1:
a += 2
print(a)
print(a)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | 3
002 | 3
If someone
can help me fix the reason send me in DM how
he's the ignorant one
its ok🫂
json cant decode unicode
you defined message the wrong way
it's not a string
I literally pinged you 3 times.....
!e
my_str = "!help aaaaaa bbbb"
print(" ".join(my_str.split(" ")[1:]))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
aaaaaa bbbb
I'M NOT USING JSON, ROFL
cant decode it
When? Can you send again?
You you doing it on purpose?
It's just here.....
Smh, ty
No i new in py
What I printed would be your reason argument.
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

read errors, it'll help you in your journey
Replace my_str with message.content
OK
i was reading but it was long... Lel
shouldn't demotivate you, the last line isn't always what you want to read
Hmmm
2 things you can learn from it
- which line
- why
Much more actually
I just summarized the main ones
an useful line of the error is usually above the
The above exception was the direct cause....
line
f string
NOT WORK
and the line, in which the error appeared, is also there
OK
Can you please read my code?
👍
or just do this
message.content
instead of
"message.content"
Do you see this anywhere in your code?
With my_str replace to message.content
I don't think so..
Also can i use lower() func with aliases?
you can make commands case insensitive in general
No
It's not what they want.
Please.........
it is
No.
How?
tho cutting out the first two words should be easy
tho he's here without that knowledge
" ".join(message.content.split(" ")[1:])
Was it so hard to replace one thing?
so that's not easy either
Not put value= and that thing.
yeah, Ic it's not, I'll give up on him, do your thing
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
ENGLISH
what does message return in a message listener?
Like I know content is one, which are the others?
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
take a look yourself
ty sir
yw
value=" ".join(message.content.split(" ")[1:])
In case you can't do that either.
in an on_message event, you mean?
!rule 9
We don't do this type of help. As per rule 9.
OK
just ask ig
Of course that's what this server is for
its work Thanks
Consider using commands for the future.
https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html
It will be much easier for you.
How can I avoid the bot from adding {} and "" ? I'm using {message.author.mention} and {message.content}
you have to think about it again
your thought process should be like this
- open json and read the data
- edit the data
- dump the edited data back to the json
Show me ur code
never seen again
Can someone recommend a database that's the closest to just using JSON?
I don't need it to be heavy duty, it's for a trading bot and I just want to memorize positions if the bot is reset or shutoff briefly.
The key is just ease of use and simplicity
async wrapper tho
Well you said it yourself. Remove {} and just keep message.author.mention for example.
close to json
mongo?
but sql is superior
yer
Solved it. It obviously wont work that way though, the bot will just send message.author.mention and wont mention the author.
It will work. Want me to prove it by making a command?
If you do value=message.author.mention, which is what I've said, it will work. If you put value="message.author.bot" of course it won't work.
Well if you don't use it correctly of course it won't work.
logic involved 😉
It's message.edit()
but i'm using embed.... will it work with embed?
Yes
yes
.edit(embed=embed)
edit completely removes everything
But it only works on a Message object
and then sends in what's passed in
Need add message param?
no
Well you need a message variable..
Message = embed?
No.
How then
What are you trying to do exactly?
i want to make a time counter, if i use reboot command, bot will count from 5 to 0 and when it's 0, it will reboot
How does the command look like, like the code.
You can maybe get the message object you need based on what you did above.
Okay so, you will need to send the first embed.
When you send it, it returns a message object that you can later edit.
Hmmm
class InteractiveView(discord.ui.View):
def __init__(self, ctx):
super().__init__(timeout=10)
self.expr = ""
self.calc = simpcalc.Calculate()
self.ctx = ctx
async def interaction_check(self, interaction: discord.Interaction):
if interaction.user != self.ctx.author:
await interaction.response.send_message("Um, Looks like you are not the calculator author...", ephemeral=True)
return False
else:
return True
async def on_timeout(self):
for button in self.children:
button.disabled = True
await interaction.response.edit_message(view=self)
await self.ctx.send("Um, Looks like the calculator has expired!")
You only send it once, then you edit it.
buttons wont get disabled
i am trying to work on this
but idk how to do it in another way
i already used ctx.send() for 1 time
And yes it stayed at 1, since you made your loop do it.
the heck interaction can send msg to
!e
for x in range(0, 5):
print(x)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
Then you have 2 instances of your bot running.
Ah yes 🤦🏻🤦🏻🤦🏻🤦🏻
how do i make it so the timestamp on an embed is when the server was created? i only know about
embed=discord.Embed(color=0x387ba2, timestamp=ctx.message.created_at)```
i cant seem to find it on the disnake docs
property created_at: datetime.datetime```
Returns the guild’s creation time in UTC.
And you have a Guild object in ctx.guild.
Ah yess that's right
im dumb i put server instead 🤦
and that timeout is useless and no need for else
Everything with server is guild in coding and Discord backend ^^
i know its my muscle memory and i somehow forgot to type guild
!e
for i in range(4,0,-1)
print(i)
@devout iris :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | for i in range(4,0,-1)
003 | ^
004 | SyntaxError: expected ':'
!e
for i in range(4,0,-1):
print(i)
@devout iris :white_check_mark: Your eval job has completed with return code 0.
001 | 4
002 | 3
003 | 2
004 | 1
Nice
When will discord change intents?
Change intents?
how can i fix these errors?
somewhere this year
decode errors





