#discord-bots
1 messages Β· Page 906 of 1
lol
Best we don't, since this is bordering on rule 5 like I mentioned. Better safe than sorry, as it is
can a bot check if a user online/offline? and if they can ,how?
you can use the status property on the User/Member object, for this, you need to have the members intent
so i need to create new intents?
no? just enable the members intent
if you havent already
presences*
hi
@client.command()
async def emojify(ctx, url: Union[discord.Member, str], size: int = 14):
if not isinstance(url, str):
url = url.display_avatar.url
def get_emojified_image():
r = requests.get(url, stream=True)
image = Image.open(r.raw).convert("RGB")
res = emojify_image(image, size)
if size > 14:
res = f"{res}"
return res
result = await client.loop.run_in_executor(None, get_emojified_image)
await ctx.send(result)``` error ```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message ```
Hmm, try printing res
res is None π

happens
So Iβm making a economy bot but the buy command is not working
please send code in a block
yup I forgot to return the emoji in my function thanks
It should still send None tho 
nope it works now, but like this π
(Happens to me tho)
Haha cool
Also
Use aiohttp cz why not
I use requests
cuz idk how π
it says aiohttp has no attribut called get

but I have another question please
async with aiohttp.ClientSession() as session:
url = 'url'
async with session.get(url) as resp:
json = await resp.json()
#do some stuff with it
an example ^
thanks
can I add instead of the normal emoji colors, an self made emojis?
or downloaded one
you made it?
not complettly
repo?
repo?
I mean if you are using git
no
github repository
ah, alright
aka src code

yes
how can I add more than those colors?
ansi color codes?
well, but it should send them as emojis
thats why I am not sure if I can use downloaded emojis
like not the normal emojis
downloaded emojis won't work in codeblocks
oh true, thanks
COLORS = {
(0, 0, 0): "β¬",
(0, 0, 255): "π¦",
(255, 0, 0): "π₯",
(255, 255, 0): "π¨",
(190, 100, 80): "π«",
(255, 165, 0): "π§",
(160, 140, 210): "πͺ",
(255, 255, 255): "β¬",
(0, 255, 0): "π©",
(0,0,0) : " ",
}``` but can I do something like that?
the dice part won't work if you sent the final thing like this
yup, but it will work if I send it without the code block?
it will
thank you very much
It wonβt send this message
Nvm
I think the dice will overwrite the black square
yeah
yup, this was only an example
cuz I didnt have any rpg number in head π
why does it send brown and purple emojis
api error?
oh
hey guys
hey
2022-03-14T15:38:45.788774+00:00 app[worker.1]: Traceback (most recent call last):
2022-03-14T15:38:45.788798+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nextcord/client.py", line 415, in _run_event
2022-03-14T15:38:45.788799+00:00 app[worker.1]: await coro(*args, **kwargs)
2022-03-14T15:38:45.788818+00:00 app[worker.1]: TypeError: on_member_join() missing 1 required positional argument: 'guild'
@bot.event
async def on_member_join(member, guild):
embed= nextcord.Embed(Title= "Welcome!", description=f"**Hello {member.mention}!**\nWelcome to **{guild.name}**!")
embed.set_image(url="https://tenor.com/view/no-way-home-spider-man-no-way-home-tobey-maguire-spider-man-portal-gif-25114767")
await welcome.send(embed=embed)
!d discord.on_member_join
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.
yes
no ikt
ye, it takes 1 argument which is member and not guild (I haven't used discord bots for a while so I might be wrong)
ig thats correct
I think nextcord is diffrent
nono
well.. it's worth a try
fork*
because I started with discord py then I switched to pycord then nextcord and now back to discord py because I found it was the best
async def on_member_join(member, guild): so.. you have this, but it only takes member param
2022-03-15T07:26:06.078121+00:00 app[worker.1]: Traceback (most recent call last):
2022-03-15T07:26:06.078137+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nextcord/client.py", line 415, in _run_event
2022-03-15T07:26:06.078138+00:00 app[worker.1]: await coro(*args, **kwargs)
2022-03-15T07:26:06.078157+00:00 app[worker.1]: File "/app/main.py", line 64, in on_member_join
2022-03-15T07:26:06.078158+00:00 app[worker.1]: embed= nextcord.Embed(Title= "Welcome!", description=f"Hello {member.mention}!\nWelcome to {guild.name}!")
2022-03-15T07:26:06.078175+00:00 app[worker.1]: NameError: name 'guild' is not defined
member.guild to get the guild
meaning change guild.name to member.guild?
member.guild.name
or ```py
guild = member.guild
embed = nextcord.Embed(Title= "Welcome!", description=f"Hello {member.mention}!\nWelcome to {guild.name}**!")
if I'm correct
this should work^
Ok thx
this is what i did
embed = nextcord.Embed(Title= "Welcome!", description=f"Hello {member.mention}!\nWelcome to {member.guild.name}**!")
@worldly bane
yeah it works
no
How to use footer and color in nextcord embed(slash)
2022-03-15T07:30:20.672660+00:00 app[worker.1]: Ignoring exception in on_member_join
2022-03-15T07:30:20.673597+00:00 app[worker.1]: Traceback (most recent call last):
2022-03-15T07:30:20.673629+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nextcord/client.py", line 415, in _run_event
2022-03-15T07:30:20.673630+00:00 app[worker.1]: await coro(*args, **kwargs)
2022-03-15T07:30:20.673652+00:00 app[worker.1]: File "/app/main.py", line 64, in on_member_join
2022-03-15T07:30:20.673654+00:00 app[worker.1]: embed= nextcord.Embed(Title= "Welcome!", description=f"Hello {member.mention}!\nWelcome to {member.guild.name}!")
2022-03-15T07:30:20.673691+00:00 app[worker.1]: TypeError: init() got an unexpected keyword argument 'Title'
</>
title="Welcome!"
It doesnt work honestly
not Title
oh tile
Thats why
Title should be title
i got it
Caps error lol
I'm not exactly sure since i don't use nextcord
Wanna flood your console?
Use
sus = 'amogus is sus '
print(sus*1000)
or use a while loop
Yes,that also works
hmm so in
embed = nextcord.Embed(title = "idk", description = "testsubject", color=nextcord.Colour.random())
some thing like this ig
try it and see β¨
oooooooooooooooo
color = nextcord.color('ff0000') Will this work
ill annoy my friend with this
its Colour
not color
py doesnt use american english ig
Yeah,btw here is a tip,use sus* then as many times as you want,in that code its 1000
it doesn't depend on python
but the library devs; they decided to use both tho...
discord/colour.py line 331
Color = Colour```
That's not a python thing.
i will roger that
Yeah,btw you can also put emojis for emoji spam
2022-03-15T07:36:12.857156+00:00 app[worker.1]: Ignoring exception in on_member_join
2022-03-15T07:36:12.858099+00:00 app[worker.1]: Traceback (most recent call last):
2022-03-15T07:36:12.858124+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/nextcord/client.py", line 415, in _run_event
2022-03-15T07:36:12.858125+00:00 app[worker.1]: await coro(*args, **kwargs)
2022-03-15T07:36:12.858138+00:00 app[worker.1]: File "/app/main.py", line 66, in on_member_join
2022-03-15T07:36:12.858139+00:00 app[worker.1]: await welcome.send(embed=embed)
2022-03-15T07:36:12.858158+00:00 app[worker.1]: NameError: name 'welcome' is not defined
Just edit the sus = ''
ooooooooooooooooo
got it
cause welcome is not defined
send the full code again
welcome has to be a discord.Channel object
a discord.abc.Messageable to be accurate
welcome
π
welcome = bot.get_channel(channel_id)
something like this
!d discord.Guild.system_channel
property system_channel```
Returns the guildβs channel used for system messages.
If no channel is set, then this returns `None`.
( you can access it with member.guild.system_channel)
so whichever channel this message comes in , the bot should send in this channel
can you explain?
Explain, but what?
what the code does?
It cant happen with bots,its how built-in discord join commands happen
nvm
It gives the channel that's used for system messages
what idea do you get from the property names
Hmm,I dont know
I think you need to set a channel manually
ikt , but whichever channel that message come in, the bot should send a message
in the same channel
I am not sure about that
hmmm
welcome=member.guild.system_channel
await welcome.send("message")
this should work if I'm not mistaken
never tried doing it so π€·ββοΈ
So
ok lemme try
imagine using nextcord after discord.py comeback
You want to send a message whenever that messages get sent in that channel?
Technically what you want is to check if a new user joins the server if that is what you want
Yes
Also,Can I know whzt are intents,idk what it is honestly
Did you just learn about this and it is now your favourite thing to do
Nope,Just tellin
i see
I know alot about python
But anyways
Yall know how to ban using slash commands?
Weren't you that dude that got fun of because of their bio
Uhh,what
that yellow wave made my flinch for some reason π
I remember seeing someone with discord bot coder in their bio and they didn't knew basic python and was struggling in this channel
Seeing what everyone says when they mention you in this channel i'm thinking that's you

who's everyone
@worldly banecreative bio
ποΈ
Search mentions:RyanDang#0001
is it alot of content?
oh yeah π
Lmao see that was only 4 days ago
btw @supple thorn
how you know alot of python if dosnt even know indentations
Yeah i know i was pointing that out
hi, I got a question please, it is actually a how to question:
I have made yesterday a command for the server I am in, it is to help them to manage the donations in a discord bot called anigame and yes they have a clan and they needs to donate.
I made the bot that if they type .cl donate 10000 the bot takes the 10000 and save them as if they donated it, what I am trying to do if the other bot says donation failed, you don't have enough money to donate my bot should then ignore their donations
discord py
You can check wether anigame said the donation worked or failed and you can ignore or store based on those messages
yup, the thing is I dont know how
Can you send in dms what anigame exactly says if it succeeds or not
yes ofc
What's your problem,I had a 1 year of gap in python development and thats not my problem I guess
My bot is sending the command 2 times when i type the commands ones
i have restart bot and my pc i dont now what do to xD
Show the code
how set time like that?
I don't have a problem with you i'm just pointing out the contradictions in your statements
Epoch and unix timestamp converter for developers. Date and time function syntax reference for various programming languages.
Use this
@worldly bane i got it
It is how it works
it works
ok, you can do something like this:
from typing import TypeVar, Callable
from discord.ext.commands import check, CheckFailure, Context
T = TypeVar("T")
class DonationError(CheckFailure):
def __init__(self, message):
self.message = message
super().__init__(message=self.message)
def has_money()->Callable[[T], T]:
def predicate(ctx: Context):
user = ctx.author
user_money = # Your way to retrieve the user money
if user_money < ctx.kwargs["money"]: # money is the name of the argument passed in the command
raise DonationError(message="not enough money")
return
return check(predicate)
oh thanks
#commandos
@commands.command()
async def ping(self, ctx):
await ctx.send(f'The speed of the bot is {round(self.bot.latency * 1000)}ms')
#info commands
@commands.command(aliases=['info'])
async def hello(self,ctx, member:nextcord.Member=None):
infoEmbed=nextcord.Embed(color=0xdc0909)
infoEmbed.add_field(name="Hello guys!", value="I am the new bot for the EPYC|DPYC community\nif u have any suggestions for the botπ", inline=False)
await ctx.send(embed=infoEmbed)
@cosmic agate hey! What about annoying your friends,did it work?
The bot could be running multiple instances
wow thank you very much
Which command is it
Man blvck typing out a whole essay
Lmao
all of them
but how to set time like that in embed?
then when you declare the command you can just do this:
@bot.command()
@has_money()
async def your_command(ctx: Context, money: int):
#your stuff here
the check will be called automatically
Nextcord? like branch lib?
thank you
<t:(timecode):(format)>
Nextcord is a fork of dpy, if that's what you're asking, idk
thanks
Yeah, iirc, dpy is dev is going on atm
version 2 release by may 1st
Yeah, to bump it to API 10, because after April, it would have been unusable
HELP MEE
10 is out?
Thats the reason why I use nextcord
has_permissions maybe?
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Mhm, 10 came out, 9 and I think 8 are deprecated and 7 is in the way of being decommissioned
Oh ok,should the permission name be in strings?
remember that the class will be a new error, so remember to handle it in your error handler, you can just check if the error is an instance of your DonationError class
no.
I want that in nextcord
Cool. Needs a little read for catching up on the gateway doc
Nextcord is a fork of discord.py so everything except the namespace remains same
It should start with @discord?
!d nextcord.ext.commands.has_permissions
@nextcord.ext.commands.has_permissions(**perms)```
A [`check()`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.check "nextcord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`nextcord.Permissions`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Permissions "nextcord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.MissingPermissions "nextcord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.CheckFailure "nextcord.ext.commands.CheckFailure").
I mean @nextcord
try , you won't be able to do that :)
from nextcord.ext import commands
@commands.has_permissions(...```
but this only works if anigame is mine?
wdym?
like you wrote that I should check if they have the money
anyone here know postgres?
yeah... that's what the check does
Help
!d discord.TextChannel.delete
await delete(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the channel.
You must have [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
No,Its in / commands
That changes nothing...
Oh wait
you need a channel object
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Changed in version 2.0: The `reason` keyword-only parameter was added.
Examples
Deleting botβs messages...
How to code this code
you just the need the channel object no matter what package are you using
well, for example in disnake:
from disnake import ApplicationCommandInteraction
@bot.command()
async def purge(ctx: ApplicationCommandInteraction, messages: int = None):
messages = 5 if message is None else messages
await ctx.channel.purge(limit=messages)
messages = messages or 5
i'm actually sleepin yet so don't complain my code hahaha
Irish land day in python cord sheesh people know I exist
isnt application command a slash command?
or is it just me
Application commands include slash, user and message commands
Resources
Help me
await purge
Bruh
You need the channel from where the bot should delete the messages
await channel.purge(limit = {amount}) is this correct?
hi i just made this command and can y'all look through it and see if it works or not:
cool my command is too long
i cant send it
You t3st it yourself and tell us the error
Get nitro or paste it to pastebin
await Interaction.channel.purge
You need the context/inter
Though you should try both ways
Your name just tells me you watch glow stick
well im not gonna buy a nitro just for this but i will use pastebin lol
Let me try
this is a part of the command tho. i get the error context has no attribute "discord"
async def pay(ctx, member: discord.Member, amount):```
^
Lol
also, it's irrelevant to do {amount} and have no f string
you either limit = amount or limit=f"{amount}"
No,You know it cause we both are in glow's git repo LMAO
1 is none what ? why would you do that
bruh
@bot.command(name="claim",description="yb better",pass_context=True)
async def _claim(ctx, *, reason=None):
username, user = reason.split(':')
if not get(ctx.guild.roles,id=int(952619437427654696)) in ctx.author.roles:
return await ctx.send("you dont have role 3l make ticket to apply")
webhook = DiscordWebhook(url= os.environ['alexlol'])
embed = DiscordEmbed(title=f'{user}', description= f'{user} {username}', color= '264dd9' )
webhook.add_embed(embed) ## Adds embed to webhook
response = webhook.execute() ## Executes the webhook```
yes idk wtf i did
I didnt do anything
instead of doing ctx.message.author i did ctx.discord.message.author
I think its a issue with the nextcord package
Webhook sends without command
i was really dumb
ok then send the code after modifications, though it's weird
whats even worse is i only did that once
Anyone?
i did it right all the other time
pass_context = True 
Idk what just happened
code
But Im 100 sure i didnt do 1 is none
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: '>' not supported between instances of 'set' and 'int'
Since your top tier coder fix my code ty
Res..
I will trust one of the peps and give them code link for repl
Yeah
You could of used vs code, pycharm but you decided to pick replβ¦
Tablet user lol,idk any good python ides for android tablets
My friend uses android phone and has a python app
Pydroid 3?
Kinda but the big ol screen makes it easy
Who thinks I should use Pydroid 3,ping me
pro tip, you don't do programming on mobile phones/ tablets
i don't like ur code, i refuse
But what to do aaaaa
Iβm Irish and my day is in 2 days come on now
Use parents/ur pc or use chrome book from school
All the ideas are worse,if they know I code discord bots then they would kill me and if I do in school same happens
Iβm gonna be honest you wonβt get far with tablet
Why do they hate discord bots
Why?
Also alternatively, you could say the bot is machine learning and not discord lmao
Or, use a phone
Acode
Tough, that's what I do
I am a beginner and i am trying to make a public welcome bot
it will first be enabled by the user through command if they wanted then it will run (basically run event on user input whether they want it or not)
and i need this for every diffrent server
Can anyone please give me any hint how to do it because i dont have any clue
@final wagon so when a member joins, it sends a message sayin "hi @member" to the channel the owner picks?
You will need to work with a database for this
Idk if u should do this as a beginner tbh
Use a database, make a config command probably which lets the user save the channel and it's id the database
Then just use
#shit to get channel ID, save it to ID
channel = self.bot.fetch_channel(ID)
await inter.channel_send(embed = welcomeEmbed)
Is how I would probably do. All the discord code shit is easy
It's only the database shit which is a bit harder
is there really any way to make bot dm me without being in m mutual servers?
like with id
semcret
I'm gonna pretend like I know what semcret is
awww'
What's semcret?
secret*
cant we use this?-discord.Object(id=member_id)
Not possible
Itβs like trying to dm user without mutual server or being added
listen
It's impossible ok
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
yeah and i want one command for the user to enable it then set the welcome message
well i know mongodb i will try it
is it a public bot or a personal bot
oh hi yerli
what's this for
fetch the user and dm
!d discord.ext.commands.Bot.fetch_user
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
Changed in version 2.0: `user_id` parameter is now positional-only.
gets the user with an api call ^
i want to make it public
store the options in a db
hm then u need to keep a database
and store the values according to the server owners wish
okay i have to create a database but how can i enable or disable welcome message(event) acc to user
use the event and check the guild and check if its in the db and get the text of it
yeah thats a great idea
thank you i will try it tonight
Hey guys am using discord python to develop a bot and its an NSFW bot how to check if the channel it is in is NSFW one?
!d discord.TextChannel.is_nsfw
is_nsfw()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.10)"): Checks if the channel is NSFW.
Cool
channel.is_nsfw
oh wait
@client.event
async def on_ready():
print("\n")
print("We have logged in as {0.user}".format(client))
?
I have commands like this how do I fix all that in it?
Like do I need to add client or something
mycodecamp?
thats an event and thats on ready
!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.
Aye wait ill do that
How do I make it such that when -agif is typed it checks if channel is NSFW and then serves the gif
just check if the channel is nsfw with the method given since it returns bool check if its true
I get ratelimited whenever I try on message
Umm like where should I add that? discord.TextChannel.is_nsfw directly this?
it's a bool
try if channel.is_nsfw == true:
Umm like see let me make a function
def check_channel():
a = discord.TextChannel.is_nsfw
return(a)
a = check_channel()
if a == True:
#do something
Is that correct
umm
i have been using mongodb and it's slow in responding what do you suggest i use now
is there a way to get/store the interaction message?
wouldn't it be easier if u just do
"""guild1 = await bot.get_guild(guild_id)
channel1 = await guild1.fetch_channel(channel_id)
if channel1.is_nsfw == True:
#do stuff"""
yes
I'm in a 1gb ram tablet so I cant type muc faster
Aha let me try that too!!
yea
i recommend u to use @is_nsfw()
for example py @bot.command() @is_nsfw() async def ur_command(ctx): #whatever you want then use on_command_error event or just locate the command error like : ```py
@bot.command()
@is_nsfw()
async def ur_command(ctx):
#whatever you want
@ur_command.error
async def command_error(ctx, error):
if isinstance(error, commands.NSFWChannelRequired)
#message
ye but how?
await bot.wait_for('message',check = lambda,m.author = ctx.author, m.channel = ctx.channel)
that exists damm
I've been wasting my time then
I would prefer to check docs
but the bot is not going to have message intents bc of the discord api changes
Aha let me try that too
ye, i just want to get the get_bucket but that needs message + interactions doesnt have messages ig. Well when i tried inter.message it gave me a error
hmm maybe ask in #python-discussion ?
alr
async def give(ctx, a: int, member: discord.Member=None):
users = await chung_data()
await ctx.send(f"Given {a} coins")
users[str(member.id)]["Wallet"] += a
with open("chungbank.json", "w") as f:
json.dump(users, f)```
how do i make it so that itll remove the same amount from the person who gave
what do you want to do?
custom cooldown
uhm
class is_premium:
def __init__(self, rate, per, rate1, per1, type, guilds: list):
self.cooldown = commands.CooldownMapping.from_cooldown(rate, per, type)
self.premium_cooldown = commands.CooldownMapping.from_cooldown(rate1, per1, type)
self.type = type
self.guilds = guilds
def __call__(self, inter: disnake.Interaction):
key = inter.guild_id
if key in self.guilds:
bucket = self.premium_cooldown.get_bucket(inter.message)
else:
bucket = self.cooldown.get_bucket(inter.message)
retry_after = bucket.update_rate_limit()
if retry_after:
raise commands.CommandOnCooldown(bucket, retry_after, self.type)
return True```
it looks like dis
first of all, don't use type as name of variable, type is a builtin method
ah, alr. what abt the get_bucket(inter.message) ? do yk how to get the msg
what package are you using and what do you want to get from the slash command?
for some reason, its not working
disnake, basically get_bucket requires message so thats why i want to get the message 
you need a message object so?
?
anyone?
ya
get the money of the ctx.author(giver) and then remove the a from they money
uhm basically the message that was sent to call the interaction will not be accessible anymore, but you can do some workaround, you can make the bot send a message before you do your things and then you can get the message object from the interaction response by doing await ApplicationCommandInteraction.orginal_message()
alr tnx 
Mind if I pm?
note that this will return disnake.InteractionMessage which inherits from disnake.Message
ye sure
Thanks
ahh
how tho
for example ```py
users[str(ctx.author.id)["wallet"] - a
Hello,so is this possible that you do a command saying /verify #verify @Verified in which #verify is the channel and @Verified is the role name and you can do this on different servers and with different channels and role names and every user who joins will go to verify channel and click the button called verify and it will say You are verified in ephemeral form and if you clicm that button again it shows You are already verified! in ephemeral form...
async def give(ctx, a: int, member: discord.Member=None):
users = await chung_data()
await ctx.send(f"Given {a} leancoins")
users[str(member.id)]["Wallet"] += a
users[str(ctx.author.id)["Wallet"] - a
with open("chungbank.json", "w") as f:
json.dump(users, f)```am i doing it wrong or something i keep getting invalid syntax on open bank.json line
i need help with my economy bots pay command. this is my code: https://pastebin.com/RJe4mafJ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
oh ye i forgot something
users[str(ctx.author.id)]["Wallet"] - a
Help meee
the type on w?
@regal cove can ya help me
and the error i get is: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: no such column: getter_id
no u just forget to clode the []
ohh
can someone pls help me
ye
not getting any errors rn but its not working on discord
its giving but not removing
@slate swan
i personally cant help you with that maybe someone else can
i wouldnt use json as a database
json isnt a database and ur gonna have huge problems with lag
i dont have a choice and besides it a pretty small bot
i had a bot working with like 20 people and it started to lag a lot
thats why im trying to switch over to sqlite
i see
he can use mongodb (it looks like json)
i havent heard of mongodb
idk tbh
does the giver have money more than a?
but what i would need
its a nice database tbh
is for someone to help me with my code
ye
whoever looks through my code and help me with my probably pretty simple mistakes in my code is a goat
@slate swan thanks for the help, i fixed it. just had to put an = after the negetive symbol
Hey @cold oyster!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
noice
Please help
code
I did
Oh
Oh wait wrong place
thats the error 
i need help
go ahead
but people ignored me -_-
oopsie
.
.
do yk wut does this do ? await inter.response.defer
show us the code? idk i've never seen that error
yes, it waits for the command to complete its functions because the slash commands time out if there isnt any response sent within 3 seconds, so it shows up bot is thinking and waits for what to send
like you're making an api call , you may have to use that, since you cant get the response and send that within 3 seconds
ohhhh
I'm bad at SQL-related stuff π
i've never used sql db
Thanks @slate swan @gaunt ice @slate swan for the help my bot works fine now may god bless you!!
anytime 
np C:
Show the query and the your database schema
May Godbless you too
hm
im making a calculator in my bot and when i input 0.1+0.2 it gives 0.3000000004
i tried the math round function but it rounded to 0
similarly it gives cube root of 1000 as 9.99999998
is there a way to fix this
How are you doing the calculations?
π
π
ans=float(num1+num2)
await message.channel.send(f"<@{message.author.id}> Your answer is {ans}")
return
if operator=="-":
ans=num1-num2
await message.channel.send(f"<@{message.author.id}> Your answer is {ans}")
return
if operator=="/":
ans=num1/num2
await message.channel.send(f"<@{message.author.id}> Your answer is {ans}")
return
if operator=="^":
ans=num1**num2
await message.channel.send(f"<@{message.author.id}> Your answer is {ans}")
return
if operator=="%":
ans=(num1/100)*num2
await message.channel.send(f"<@{message.author.id}> Your answer is {ans}")
return
if operator=="rt":
ans=round(num1**(1/num2))
await message.channel.send(f"<@{message.author.id}> Your answer is {ans}")
return
else:
await message.channel.send(f"<@{message.author.id}> Invalid")
return
Alec, u got demoted?
okok, so basically the reason it is giving you weird numbers is due to how computers do addition, they work in binary rather than decimal so you get things called rounding errors for things like this
i used round for root and it worked because of whole numbers right?
one way you could fix it is by using the decimal module which works in decimal rather than binary and will make more familiar looking answers
ok i will look it up.
thanks for support
c = 0.1+0.2
print(f"{c:,.2f}")
this will print the first two digits after the decimal, you can do any number if you change the 2
is there a way for me to not get ratelimited for using on_message
sorry for the ping, Hunter π
process commands ok but stil?
you can get rate-limited for using on_message? huh
yes?
no?
um
it doesnt
Uhhh, I got a ghost ping....?
sending too many reqs to the dc api at once
hm
Ah gotcha
like the bot checking every message in a alive general chat for swear words
what abt that
dont think so
hm
the only thing you can get ratelimited for is making api calls
receiving events doesnt affect ratelimits
so if I get a channel id inside the on_message event and use it
everytime a message triggers
the API has to fetch the channel
generally speaking if you're not awaiting a call, it doesnt contact the api
so I have to define the channel outside the event
@gaunt ice Which host are you using?
hmm
uptime robot lmfao
ima peasant
With replit?
definitely not freecodecamp
yes
ik ik I'm that average freecodecamp guy
but all I could do was that at that time
Don't use replit for hosting bots, they use shared IPs so if one bot on replit gets rate limited, your bot will get rate limited too :)
now I'm learning from docs
WAIT
FRICK
I DIDNT KNOW THAT
ig time to buy raspberry pi
Now you know
which one is better is not None or != None
yea
I prefer !=
I prefer if value:
um can i ask python things here
If it's related to discord bots
Consider using is when comparing to types
oh i see
cant post pic
well it for my discord bot things but...
thats wut i thought
Isnβt is for checking if 2 Objects are equal?
it's for checking if 2 objects are the exact same object
how to get the get_bucket for a command 
Yeah thatβs what I was thinking, it wonβt work for checking if an object is if a certain type will it?
holy im dumb
@brave flint use motor instead of pymongo
nah im fine with pymongo
awesome
well
no offense
what motor does lol
it's just like pymongo
idk i just hating asyncio thing
asynchronous wrapper for pymongo
ikr so what is the dif tho?
that'll make your life very very challenging if you want to make bots with discord.py
ikr i mean asyncio + threading
im bad on it soo...
replit ?
correct
yes
lol
freecodecamp making a killing
so it gets limited rn?
how long is it?
idk
3hr?
yes sm what
this is all?
Don't use replit for hosting bots
prolly
true 100%
heroku?
yes
or which one
i don't understand haha,hard to use heroku
bots are not what heroku was designed for but feel free to use it I guess
neither do i
bruh it ran justnow
awesome!
than it gets the error after like 10 seconds
too soon to speak π
no on message gets triggered on a websocket message event
how do you get the timestamp for a discord embed in relation to the day? i.e today, yesterday, e.g.
why do you guys even like hosting bots on replit 
"its free"
easy to use also
"normal IDEs are free too"
Gateway?
it ran again then stops
Awesome
yeah gateway sorry its just in docs on wait for it says websocket eventd which does get sent through it but it confuses me a bit
Websocket is just a connection to the gateway it has nothing specifically to do with discord but just being a two way communication between the gateway and your bot
yeah ik its just docs on wait for confuses me because the wording is a bit off
const Discord = require("discord.js")
client.on("guildCreate", async (guild) => {
let channel = new Discord.WebhookClient(
client.config.webhook.id,
client.config.webhook.token
);
const embed = new Discord.MessageEmbed()
.setColor(client.config.embed.color)
.setThumbnail(guild.iconURL({ dynamic: true }))
.setTitle("New Server!")
.addField("Server Name", guild.name, true)
.addField("Server ID", guild.id, true)
.addField("Owner ID", guild.ownerID, true)
.addField("Owner Mention", `<@${guild.ownerID}>`, true)
.addField("Member Count", guild.memberCount, true)
.setFooter(client.user.username, client.config.embed.thumbnail);
await guild.channels.cache
.first()
.createInvite()
.then((invite) => embed.addField("Invite link", invite.url, true))
.catch(() => embed.addField("Invite link", "Missing permissions", true));
channel.send({ embeds: [embed] });
});
wrong server lol
Wrong server buddy
i mean a websocket is like making a raw tcp connection
bruh
that's js
Where is js server?
um, this is a python server, not a js server
Slap it inside your code
Nowhere, javascript doesn't have a server
Means?
Put it inside your code
I put in last but this error is coming
In config
@sick birch oohhh robin
||csgo||
I have no idea what that means, and you need to go somewhere else for help (no offence)
why are you pinging robin?
in a what
yes, in a python server
cause robin knows js
me too
prove it
I know js too

ok bet
show me your JSON file
yes
@boreal ravine dm
thats cool
javascript has dunder methods (attribute):
class Bar {}
var bar = new Bar()
console.log(bar.__proto__);
Ok
seems like doing classname.__init__()
π³
anyone?
no its the objects prototype. since js does prototypal inheritance
ew
Using relative timestamp
LMAO
i can't find it
whats funny?
Idk what that was Iβm not gonna lie. Shitty mobile
tyler sent a funny gif
Right.
Are you even able to do that with strftime
like this
Check dm
Oh

okay actually i don't know which thing it uses but
I think you can just slide
also it adjusts automatically so if the embed sent yesterday is looked at today it will say yesterday and if it is two days ago is will show dd/mm/yy or whatever but I think this is a discord thing
A datetime object into it
and?
thatβs it
to the embed footer?
To the time stamp
samething tbh
!d discord.Embed.timestamp
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
the timestamp kwarg still gets set to the footer of the embed
anyways , thx for the little help.. have a wonderful night!
me? orr
or..
ooh okay
yeah or
thank you Tylerr
you know you can set the timestamp in the class constructor and not the class's instance
I will, that was just to test it
ah
doesn't matter too much though
nope but its cleaner
whats wrong with setting it on its instance
Itβs cleaner and thereβs not really a reason to
its weird and a bit less readable
Unless your dynamically setting it
^
nah
embed = discord.Embed()
embed.description = ''
embed.timestamp = ...
``` is more readable
bro what?
#bot-commands
Having in the constructor tho makes it more aligned and makes it seem more localized tho
Right
yeah so its more together with the class construction
!Paste
https://paste.pythondiscord.com/kitubisavo How can I make it like when someone doesn't provide a emoji and just does .ei that it will give a message like hey please enter a emoji
you can set a default value of none and check the value or just add another value of whatever you want
tl;dr optional arguments
anyone js?
bro this is a python server lmao
ask here^
heyyy, I have a problem I put my moderation commands in a cog but when I add it in the hand I get an error
show
you dont import it
lol
you add the cog in the file with the method and you pass the class
that are the problems that we mentioned to you yesterday
Explain to me how I can correct this problem please
I don't see how to add the class. Sorry for my ignorance on discord.py
bot.add_cog(CogModeration(bot))
in the cog file
if i have a float assigned to a variable is it possible to find out the decimal places?
its in my calc in a bot
I always have the same mistake
i used this but if user gives a very small decimal place then it gives unnecesary 0s so just to stop that i can find the decimal values and put that
like it converts it to a long decimal?
if the decimal is long just round it out
!e print(round(45.55))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
46
!e print(round(0.1+0.2))
@swift monolith :white_check_mark: Your eval job has completed with return code 0.
0
Yea
Cz 0.3 rounds off to 0
^ math
i need help for this if possible
Just use math.ceil()
import math
print(math.ceil(0.1+0.2))
!e
import math
print(math.ceil(0.1+0.2))
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
1
bro?
ans=float(num1+num2)
await message.channel.send(f"<@{message.author.id}> Your answer is {ans:,.8f}")
return```
i want it to give only the required decimal places if there are any
I did what you told me but it didn't work
bro you didnt even tried it
if you did and an error is raised show if you have another problem say
I did tho
!d disnake.ext.commands.Bot.fetch_member
No documentation found for the requested symbol.
fetch_user*
Or Guild.fetch_member if u want timeout
Don't import moderation from anywhere
ohh, lol
but one more error now console AttributeError: 'User' object has no attribute 'timeout'
now thats just being ignorant
'User' object has no attribute 'timeout'
Just do:
class MyCog(commands.Cog):
. . .
def setup(bot):
bot.add_cog(MyCog(...))
@visual island edited it. Now stop bullying me ;-;
now its async π³
If dpy implements voice receive, then am ready to rewrite my bot 
Guild.get_member is way better
But they wanted to use fetch so I just told them with fetch 
its supposed to be outside of the class and in the global setup function
is that even a reason π
Tbh, yes nope. Just tryna stop you from bullying me
how would i react to the command message ($hi) and add a wave react or something
await ctx.message.add_rection("π")
I can't do it
forgot to await π
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function no-longer raises `InvalidArgument` instead raising [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)").
!d discord.Message.add_reaction @tough trellis
await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
Changed in version 2.0: `emoji` parameter is now positional-only.
Changed in version 2.0: This function no-longer raises `InvalidArgument` instead raising [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)").
add_reaction you mean?
rection
I still can't get through, would you like to see my code ?
sure
This is my code
https://pastebin.com/nRnBZSXY
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
what's the issue exactly?
well, I don't see any setup method in the cog itself first of all
why moderation.cogModeration?
because his file is named like that most likely
Hey @slate swan!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
try this instead:
bot.load_extension("cogs.moderation") <- in the init
(it's "cogs." because I assume you have a cogs folder where your moderation is in
in the moderation.py file, last line, NOT in the class
# The setup function below is neccesarry. Remember we give bot.add_cog() the name of the class in this case CogModeration.
# When we load the cog, we use the name of the file.
def setup(bot):
bot.add_cog(CogModeration(bot))```
why does this not work for me to add a role per command?
what error
nah. i put them in. they just arent on the ss
ah
i mean i did forget them but i found out fast enough when i typed the command and got the entire list 
kek
Hi, I am building a discord bot which handles some coin and market system. So I will need to have money data per users. I installed the mongo db but couldnt understand how to make special data per user. can someone teach me how to make it ?
use mongodb atlas, dont use local storage
are you adding roles to a user or member?
whatβs wrong with local storage :<
how can i reset cooldowns in slash commands?
i tried both but nothing worked
show the command
btw you can't add roles to a user
only members
btw
add_field is a thing 
change name="Staff" to id=id and use await ctx.guild.fetch_roles() instead of ctx.guild.roles
ik but i didnt like how it looks
ID's are much better than names
oh 
any idea?
i will try
Ok then if you have an id then thereβs no need to use utils.get
you can ofc use ctx.guild.get_role but it seems they prefer to use utils.get
The only time you should be using utils.get is if you are grabbing by name
i wanna change as little of the code as possible while keeping the functionality the same
Precisely because they want to grab the role by name
i tried but still did nothing
what output are you expecting v.s what happens
If i use the command and ping a user it should automatically give him the staff role but it just ignores it, there is no error, nothing
is client a discord.Client?
replace your client = discord.Client() with bot = discord.ext.commands.Bot(commands_prefix='!', intents=discord.Intents.all())
Spoonfeed go brrrr
it's just a single line
At least explain it
!d disnake.ext.commands.Bot
class disnake.ext.commands.Bot(command_prefix=None, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.GroupMixin "disnake.ext.commands.GroupMixin") to provide the functionality to manage commands.
Questionable explaination
still doesnt work
really?
yes
Using commands.Bot instead of discord.Client allows you to do some extra things. Most notably, use the commands extension
send the new command over
@commands.has_permissions(administrator=True)
async def accept(ctx, member: discord.Member = None):
if member == None:
embed = discord.Embed(title="", description="Please Mention a applicant!", colour=0x992d22)
await ctx.send(embed=embed)
else:
embed = discord.Embed(title="", description=f":smalltick: Welcome in the team buddy!", colour=0x2ecc71)
await member.send(embed=embed)
embed = discord.Embed(title="", description="A Staff Member will message you shortly!", colour=0x2ecc71)
await member.send(embed=embed)
id = ("953063650967560222")
role = discord.utils.get(ctx.guild.roles, id=id)
await member.add_roles(role)
idk if i did something wrong
member is None is preferred
dude
an id is an integer, not string
oh
and try async def accept(ctx, *, member: discord.Member = None):
Original
responses={'bren':'@visual basalt'}
@bot.event
async def on_message(message):
for response in responses:
if message.author != bot.user and message.content.lower().startswith(response.lower()):
embed=discord.Embed(description=responses[response],colour=0x960200)
await message.channel.send(embed=embed)
break
else:
await bot.process_commands(message)
New
responses={'bren':'@visual basalt'}
@bot.event
async def on_message(message):
for response in responses:
if message.author != bot.user and message.content.lower().startswith(response.lower()):
await message.channel.send("")
What am I doing wrong DISCORD.PY BOT
so many things
you can't send empty messages
first one works
second one doesnt, trying to make it so it sends as a normal messgae and not a embeded
when you loop through a dict, you loop through the keys
read a few docs on how to use dicts tho
yes
w/ what
what?
what?
is this internet slang im too old to understand?
what?
did you need help with a discord bot?
Hey hey letβs keep it calm okay?
Please calm down and explain what the problem is
if you need some help with discord bots, explain please
what's happening lol
idk
If you explain what the problem is we would be glad to help you
But without knowing what the problem is we canβt help
logic
unless we telepathic
well, they're offline
this was strange
what even does that mean
what
calm down man

