json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting [file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).
If *skipkeys* is true (default: `False`), then dict keys that are not of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"), `None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError").
The [`json`](https://docs.python.org/3/library/json.html#module-json "json: Encode and decode the JSON format.") module always produces [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") objects, not [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. Therefore, `fp.write()` must support [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") input.
If *ensure\_ascii* is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If *ensure\_ascii* is false, these characters will be output as-is.
#discord-bots
1 messages · Page 908 of 1
ok
it works
before
An exception has occurred while executing command `mine`:
Traceback (most recent call last):
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\client.py", line 1353, in invoke_command
await func.invoke(ctx, **args)
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\model.py", line 210, in invoke
return await self.func(*args, **kwargs)
File "C:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer\main.py", line 94, in mine
with open('storage.json', 'w') as f:
TypeError: 'BaseCommandObject' object is not callable
im trying to dump this{'683041051740602402': {'doge': 0.079, 'bank': 0, 'mining_cooldown': 7.3641541, 'balance_cooldown': 0, 'hack_cooldown': 0, 'hack': 0, 'timesmined': 1, 'pickaxes': 1, 'fourtunes': 1, 'beta': True, 'timeline': 0, 'rocksmined': 0, 'moonc': 0, 'marsc': 0, 'jupiterc': 0, 'earthc': 0, 'titanc': 0}}
Okay
First of all json isn't a database
Also what's your code
if chance_for_rock <= chance_radius:
users[str(ctx.author.id)]["rocksmined"] += 1
rocksmined += 1
embed = discord.Embed(description=f"{ctx.author.mention} Mined!",color=0xf8fd08)
embed.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/en/d/d0/Dogecoin_Logo.png")
embed.add_field(name="Amount :", value=f"{money}Ɖ" , inline=True)
print(users)
with open('storage.json', 'w') as f:
json.dump(users, f)
if chance_for_rock <= chance_radius:
embed.add_field(name=f"Dude, you mined a rock! You now have {rocksmined}:rock:", value="⠀", inline=False)
await ctx.send(embed=embed)
else:
embed = discord.Embed(description=f"Oops, cooldown! you need to wait {round(cooldown - time.perf_counter(), 2)} Seconds! WOW")
embed.set_thumbnail(url="https://upload.wikimedia.org/wikipedia/en/d/d0/Dogecoin_Logo.png")
await ctx.send(embed=embed)
huhhhh, discord bot maker
It is an application
You can even download it on your phone 
Indeed, but idk if its the same developer who made it for pc
Imagine using carl 😔
Either way. It’s still trash
I used to use that to create bots in the start
I did too. That’s why I know it’s trash
cool
Indeed, too limiting
but what does the application charge for.....
It doesn’t
Why that happen
ads?
It is paid iirc
The hosting is paid.
(At least the PC version is)
error
ew
why are u talking here????
the one on mobile they make money off of ads. They have like a hosting system setup. The more adds you watch the more hours you get of free hosting.
I mean, uhhhh
Technically, this is related to discord bots dev hehe
steam....
okay I'm going to cry
yes
LMAO
Inb4 it’s a token stealer
woah
Not surprising
Free hosting be like
I mean.....steam's sanity........ 😔
LMAO
👌
That’s definitely not euro
👀
from audioop import mul
from pydoc import describe
import discord
import random
import os
import math
from discord_slash import SlashCommand, ButtonStyle
from discord.ext import commands
from discord_slash.utils.manage_components import create_button, create_actionrow
from discord_slash.model import ButtonStyle
import json
import time
just see the age pffttttt
Yea, its INR tho
Oh sorry it's small for me cause im on phone
Rupee?
It looked the same so i guessed
Just give your 5 y/o your iPad and he will take care of the rest
Yea. Indian Rupee
controversial
So it’s like around 3 USD
but okay, cool kid
You could pay someone to actually code a discord bot for you that's actually good
Oh
I can bet its not less than 5
Nevermind then lmao
Games/Apps on Steam are costlier in USA
I thought they be charging it like how Apple does
Indeed. Pay 5 bucks for a good discord bot with features, maintenance and hosting
I'm not saying they do anything wrong
I'm just saying their prices are high
Just divide it by 75 or smth
Ofc they are
😔 And they don't even have voice receive or support for sending requests to other APIs
idc meh, pounds are the easiest to calculate
Indian?
Totally not trying to shift HunAI to it
Don't mind me but
Yup
I always wanted to do this
ey
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
@slash.slash(name="mine", description="This Mines For some good doge WOW")
async def minerock(ctx):
I'mma just go away, thanks
Imagine paying 6 dollars instead of carl 😔
Totally not sponsored to upvote Carl
Humans better than bots
Hire humans
everybody's a dumbass ic
^preferably adults
At least I am, idk about others 👀
count me in
Why not 10 y/o's?
@slash.slash(name="profile", description="Profile with stats! WOW")
async def profile(ctx, user: discord.User = None):
that works
Anyways I'mma just go away before mina comes here and bothers @unkempt canyon to give us a warn
anyways, I'm breaking the rule of not using discord, so bye, ||and yes, ot||
Same 👀
I saw that
how to make this "f'{ctx.author.mention} slaps {user.mention}!'"
work in an embed
the Leyes?
its this!!!
with open('storage.json', 'w') as f:
json.dump(users, f)
uhm what is going on here?
Put it in a embeds description kwarg
ot talks related to discord bots
I did but it dosent mention then
What did you try?
then you didn't break any rules xD
embed = Embed(description=f"{ctx.author.mention} slaps {member.mention}")
description="f'{ctx.author.mention} slaps {user.mention}!'")```
brake 😔
Hahahaha dunno why but i wrote brake
using an f string inside a string?
Any1 has term of service format for discord bots?
It's discord.Embed
thanks
You forgot to tell them to import it
you can lol
I mean, you could say that in a polite way but okay
whats the need
Bad
@slate swan :white_check_mark: Your eval job has completed with return code 0.
f'{x} {y}'
take variables...?
No thanks
yes
nvm lol, I'm going to cry now, bye
conc is shit compared to the beauty of f string
Nvm
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
shit, ot2 is cursed today
🙄
You were the one who said that at the first place
You do know we all read that message, right? @slate swan
LMAO
Bed
lol
I'm using that as a placeholder of lies
!ot nice
Stop it
you are abusing the ot
Yes, it is annoying asf now
from now until new order you are forbidden from using the ot word
how do I make main be able to use the commands from the commands folder
addcog
Hey Guys, I need help with whitelisting certain roles for my discord bot and blacklisting certain roles from doing commands
If someone could help that would be great
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
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 invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
@slate swan ^
^ This will only help with whitelisting and not blacklisting
well all that is not whitelisted are blacklisted????
That would be a pain in the ass to do all of the roles except for the roles you don't want
Might aswell just do a custom check yourself
my commands now dont work when i use cogs
:incoming_envelope: :ok_hand: applied mute to @terse blade until <t:1647434581:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 11 consecutive newlines in 10s).
!unmute 820370330203062294
:incoming_envelope: :ok_hand: pardoned infraction mute for @terse blade.
!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.
@terse blade please use this for big pieces of code
How to know when a bot has stopped playing music in a vc
when u dont hear music anymore?
yes
When u dont hear music anymore
yup. this there anything like is_music_playing or smth, idk
!d discord.VoiceClient.is_playing
is_playing()```
Indicates if we’re currently playing audio.
tyyy
or using something in the after kwarg of VoiceChannel.play
why wont commands work with my cog
what's in your cog
commands
show the cog file bruh 🥲
send as ss
you put the command outside if the cog
indent the help command
why exactly are you defining bot again?
lmfao
im autistic
prolly not
wym
the load_extension you're doing in the other file
it said to on the example 😭
will put bot to your setup function
you don't even use it
so i can get rid of it?
def setup(bot):
bot.add_cog(HelpCog(bot))
delete this?
Heh
you can do this right? ```py
@commands.group(aliases=something, invoke_without_command=True)
async def something():
pass
@ssomething.command(aliases=something_else)
async def anotherthing():
pass
you don't need this, dpy does it for u
why not
gives an error when i delete this
just told you you need it
whats this for then
for this, so there's no missunderstanding
so does it work with the setup function?
U lost me 🤣
no
It works with the indents
Ye
should've stopped right there
basically delete this
made sense
of the bot?
Yes
ofc nvm, I'm dumb
How do I make a nested group command in ex.commands. I have this role_group role command func with a subccomand func of info_legacy ```py
@commands.group(name = "role", invoke_without_command = True, case_insensitive = True, aliases = ["rank"])
async def role_group(self, ctx):
await parent(ctx)
@role_group.command(name="info", description=info_description, usage = "<role>", aliases = ["whatis", "ri"])
async def info_legacy(self, ctx, role: Role = None):
await Roles(self).info_func(ctx, role)```but I want to make a subcommand func for `info_legacy` so would it be ```py
@role_group.group()
async def info_legacy():
@info_legacy.command()
async def info_sub():```
either define it in the bot constructor (use the activity kwarg) or use the change_presence method on the Bot object
Idk how to use change_presence
# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))
# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))
# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))
# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))
It works for Nextcord?
How do I make a handler for BotMissingPermissions in try except /
//nextcord
yes
huh?
you need to use the check and the error command handler
@slate swan Any idea to use streaming status without twitch url
dont give the url
So it must stay what?
huh?
It should be my_twitch_url?
class discord.Streaming(*, name, url, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity") that represents a Discord streaming status.
This is typically displayed via **Streaming** on the official Discord client.
x == y Checks if two streams are equal.
x != y Checks if two streams are not equal.
hash(x) Returns the stream’s hash.
str(x) Returns the stream’s name.
just dont define it
Ok got it
Yes what is the instance for that ?
Btw I am making a powerful security bot so if any of you wanna help then you can dm me
Found it exception nextcord.ext.commands.BotMissingPermissions
Check profile rule 3
I'll give you an example, are u using a cog?
yes
id love to but en exams
Respect staff members and listen to their instructions. ?
No,profile rule no 3
they get over like in a month
No noisy unicode characters (for example z̯̯͡a̧͎̺l̡͓̫g̹̲o̡̼̘) or rapidly flashing avatars.
does my name look like z̯̯͡a̧͎̺l̡͓̫g̹̲o̡̼̘ ? if not kindly don't talk.
Oh!
Its unpingable
then don't
you can reply to the message with mention on.
And it is
it's fine ryan
@commands.Cog.listener("on_command_error")
async def uwu_command_error(self, ctx, exc):
if isinstance(exc, commands.BotMissingPermissions):
'''whatever you wanna do here'''
@commands.command()
@commands.bot_has_permissions(any_discord.Permissions=True) #this check will trigger the error handler
async def whatever_command(self, ctx):
whatever```\
chill
thanks
Ok,bye
Ima get back to coding and have some music 
bye dpy coder 
Nextcord here bruh
🏃||self, ctx||

Eh?
UwU
Btw thats an event?
*listener
Samething
they've specified the event in the parenthesis
The name of the event Is inside listener decorator
not really
@slate swan can you tell how to make changing status? It needs intents or not?
If you think that, you really need to read docs
Atleast they do the samething
make a task
!d discord.Client.event
@event```
A decorator that registers an event to listen to.
You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events).
The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)"), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") is raised.
Example
```py
@client.event
async def on_ready():
print('Ready!')
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
Example?
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").
Example...
still a big difference in how they work, instead of what they do
Im getting that error
Code?
`def pop_random_line6():
"""picks a random line from a file, then deletes the line"""
with open("Month Spoofer Key.txt", "r") as file:
lines = file.readlines()
chosen_index = random.randrange(0, len(lines))
chosen_line = lines[chosen_index]
with open("Month Spoofer Key.txt", "w") as file:
del lines[chosen_index]
file.writelines(lines)
return chosen_line
@client.command()
async def MonthSpoofer(ctx):
roles = [role.name for role in ctx.message.author.roles]
if 'Owner' in roles:
line = await pop_random_line6()
await ctx.message.reply(line)
else:
await ctx.message.reply("You don't have the permission to execute the command!")
await asyncio.sleep(5)
await ctx.send("INSTRUCTIONS WILL BE TYPED HERE")`
There can be only one event, but multiple listeners
Use the code block system duh
wym?
ur function isn't async but you're using await inside it...?
Show me line 93 to 95
wait nvm i read it wrong
Yep
@nextcord.ext.tasks.loop(minutes=5)
async def uwu_status():
list_of_status = []
await bot.change_presence(activity=discord.Game(name=random.choice(list_of_status)))
uwu_status.start()
there you go
line = await
There it is,the error is in line 94
Try to determine it
Remove that await
alr
only async functions ( coroutines ) need to be awaited
Thanks for the help @slate swan & @drowsy thunder
Inside list_of_status 's [], should I use double quotes inside it and put the desired statuses?
np,if you get more errors,tell us
list_of_statuses = ['Halo Infinite', 'Call of Duty: Warzone', 'Grand Theft Auto V']
just dont judge me by the selection of the games
Ok,also in loop(minutes=5) can I use seconds?
yeps, but dont change it too often
seconds, minutes, hours, whatever
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
10 secondsis ok right or will it lag
you will get ratelimited
you shouldnt
How much should it be then
30 seconds?
keep it 45 seconds at least
Ok thx
Ok
anyways, whats the point of statuses if you wont let people even see them for 10 seconds ;-;
LOL
Whats the command to eval code?
!eval
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
!src e
Command: eval
Run Python code and get the results.
Source Code
bot/exts/utils/snekbox.py:268
/home/container/main.py:43: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
client.load_extension(f"cogs.{file[:-3]}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Lol why this?
ping if you can help me
src link for how python bot does this?
the error says it all you must swair the coroutine
await
I need the source link for how @unkempt canyon does that
Does what
!src src
what?
Command: source
Display information and a GitHub link to the source code of a command, tag, or cog.
Source Code
bot/exts/info/source.py:22
he means display the code
No..? it reads the lines from the link and sends it on discord
smh you guys
yes
No he means how it pulls the code from the repo and posts it in chat
im not sure infernum but you should browse around the repo
exactly!
!src
ill try to find it hold on
alr sure take your time
bot/exts/info/code_snippets.py line 244
async def on_message(self, message: discord.Message) -> None:```
Thx! ❤️🔥
always
await client.load_extension(f"cogs.{file[:-3]}")
Hi, I got an error saying that client has no attribute named command and I don't know what I did wrong but isn't @client.command supposed to work? this is my code ```python
import discord
from discord.ext import commands
#server_id = "922146486840590367"
def read_token():
with open("token.txt", "r") as f:
lines = f.readlines()
return lines[0].strip()
token = read_token()
bot = commands.Bot(command_prefix='?')
client = discord.Client()
@client.command()
async def ping(ctx):
await ctx.send("working")
client.run(token)
client should be an instance of the Bot class
how do I do that lol
with oop

wtf is that emoji
lol
didnt I already do that?

Bot is Client but better
every bot is a client
OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
I mean, Client doesnt support commands
hence the error
so I replace the decorator with bot.command()
bro
quick learner
hi.
yes
wut?
absolutelyn't
one more question...
hi?
when I run the command in the server it doesnt say anything
HI
hi
context
Hello
show code uwu
ew
hi
i need more context bro
show code.
you run the client, not the bot
import discord
from discord.ext import commands
#server_id = "922146486840590367"
def read_token():
with open("token.txt", "r") as f:
lines = f.readlines()
return lines[0].strip()
token = read_token()
bot = commands.Bot(command_prefix='?')
client = discord.Client()
@bot.command()
async def ping(ctx):
await ctx.send("working")
client.run(token)```
guys the fuck, he has
bot.run
OMG
I CANT UNSEE IT NOW
im sorry lol
cuz why not
I am a disgrace
ey ey we are jk chil
smh
staph
discord light mode is for boomers
no
I use discord light theme
but u aint one uwh
xenoren stop

okok
xenoren you need to stop
ok
!ot 
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
nerd
!it 
!t ?
mhm
dies
ok
I'm in
yall nerds use high contrast 
we are loosing Ashley mayday
god
ah
it looks disgusting
lmfao
!ot
ok sry
No, I used an invisible character \
stop cap
the cool down is per channel its probably on cooldown
lol it is
uhh ok whatever u guys say
how do i put something in the bots about me
through the developer portal
I did but it dosen't change it
frig I'm dumb
imagine not knowing the full path to every literal class
....
!d discord.ext.commands.Bot.status
property status```
[`Status`](https://discordpy.readthedocs.io/en/master/api.html#discord.Status "discord.Status"): The status being used upon logging on to Discord.
and attr
Any way to flags like “-user @pallid meadow” instead of “user: @pallid meadow” for example
I am using disnake btw but the implementation is identical to all of the other forks
wdym?
uhm that's why the docs is written .-.
ok you are joking
so we can ignore people by invoking a command with the right argument
Nvm, found out you can prefix flags
does anyone know how to make bot delete their message in nextcord slash command?
why to delete though, you can keep them ephemeral
you can use the delete method on the Message object returned when you send it, idk if that will work
u have permissions?
you cant delete them
the bot can delete its own messages without permissions smh
how i know it was bots own message
read the question
it's a message sent by a webhook
all of the interaction responses are webhooks
what

NoneType object has no attribute delete
interaction.response.any_method returns None.
cope
why?
wait did you mean attr or method?
what does any_method suggest 😔
Well I should have been more specific
"A method which sends a response returns None"
I thought you meant something tbh
@slate swan can ya help
help with?
So
I made a auto mod in which if a user swears it says youre not allowed to swear so,is there a way to delete the response from the bot after 5 seconds? @slate swan
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
So how should I do it
Cuz I use await ctx.channel.send
delete_after=10 (deletes after 10 seconds)
await ctx.send("blah blah",delete_after=seconds)
Ohk thx
If this is for gtao can we discuss when I get off this absolute train wreck of a train journey so we can organise it nicely :p
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\fun.py", line 20, in <module>
class fun(commands.Cog):
File "C:\Users\culan\OneDrive\Desktop\echo slash\cogs\fun.py", line 69, in fun
async def search(self, interaction: discord.Interaction, query):
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 991, in decorator
return Command(
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 383, in __init__
self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 275, in _extract_parameters_from_callback
raise TypeError(f'annotation for {parameter.name} must be given')
TypeError: annotation for query must be given
>>> ``` ```py
@app_commands.command(name='poll',
description="Creates a poll.")
async def poll(self, interaction: discord.Interaction, args):
if not len(args) > 0 :
None
else :
questionSondage = "".join(args)
dictEmbed = {
"title": ":bar_chart: Poll",
"description": \
f"""
{questionSondage}
"""
}
sondageMessage = await interaction.response.send_message(embed = discord.Embed.from_dict(dictEmbed))
await sondageMessage.add_reaction("\U0001f44d")
await sondageMessage.add_reaction("\U0001f44e")```how can i fix this i have 4 command giveing this error
uhm i'm not sure that we can help you, youtube policy is very aggressive
Don't see anything wrong with it
Typehint args to str or whatever data type you want it to be
untill he has something related to a music bot or something that breaks some laws
it duz not brake it becus it will only serch
lol you have 3 more commands related to this error
so it needs to be strings?
could be a workaround to this rule
I am trying to change my nickname with this bot but it says that it doesnt have perms but I gave it a role that has a admin and everything this is the error ```Ignoring exception in command change_nick:
Traceback (most recent call last):
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/joelj/PycharmProjects/UndBot/BotMain.py", line 41, in change_nick
await member.edit(nick=arg2)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\member.py", line 681, in edit
await http.edit_member(guild_id, self.id, reason=reason, **payload)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\joelj\anaconda3\envs\undbot\lib\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: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions``` this is my code
import discord
from discord.ext import commands
import time
#server_id = "922146486840590367"
def read_token():
with open("token.txt", "r") as f:
lines = f.readlines()
return lines[0].strip()
token = read_token()
bot = commands.Bot(command_prefix='?')
time_seconds = 0
@bot.command()
async def nuke(ctx, arg1="", arg2=30):
if arg2 > 60:
await ctx.send("Lets keep it under 60 seconds for my sake :)")
else:
if "@" in arg1:
await ctx.send(f"""A Nuke has been Launched Towards {arg1} and will destroy *everything they love* in {arg2} seconds""")
time_seconds = arg2
start = time.time()
time.clock()
elapsed = 1
while elapsed < (time_seconds):
elapsed = time.time() - (start+-1)
time.sleep(1)
await ctx.send(f"""{arg1} has been reduced to *atoms*, **double kill**, *annihilation*, *extinction*, ***rampage*** """)
else:
await ctx.send("Invalid Usage: ?nuke <@user> <seconds>")
@bot.command()
async def change_nick(ctx, member: discord.Member, arg2):
if arg2 != "":
await member.edit(nick=arg2)
else:
await ctx.send("Invalid Usage: /change_nick <@user> <nickname>")
bot.run(token)
Error is pretty clear. Your bot is missing permissions
I gave it this role
how to make a level system uwu
is there anything else I need to do?
be cool like me
sigh
Is the role above the highest role of the person you're trying to change the nickname of?
so if i steal your code you wont complain?
I mean there is only me on the server
and I am owner
great
Don't think it can change the owners nickname
invite me then try it
go ahead
Get an alt in the server
ok thx u
send me an invite ill be ur tester
no thx
so rude
Give XP in an on_message event and store it in a database
i did that didnt work gave up
Okay
is it cause i cogged it?
cogged it?
cog
what about it
is it cause i put it on a cog
probably not
i mean the code is 3 years old
well did you load the cog?
it should've i got no errors
How do I host my discord bot 24/7
but when i send a message it just dosent show in db
a vps
show the cog
What vps you suggest
take a look at this you have allot wrong in the cog https://tutorial.vcokltfre.dev/tutorial/05-cogs/
Cogs are a very important part of discord.py which allow you to organise your commands into groups - not to be confused with actual command groups, which will be explained later in the tutorial.
where do you live
Canada
how
it works fine for my commands
How do I send api data from console to a json file?
- events arent a thing in cogs
- no need for a bot instance
theres so much other things to talk about as well lmao
Try uptime
so i have to put that all in main?
what
Like mixedCase class name 🗿
in my main as events dont exist in cogs
theres a thing called listeners
!d discord.ext.commands.Cog.listener
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
so if i change event to listen?
?
You need to change a lot of things
breh
hes speaking the truth lol
like wut
want me to point it all out?!?!
im so confused its incredible
just look at the tutorial i sent

Hi everyone im making a music bot but i keep on running into this error
🗿
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url,download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegPCMAudio.from_probe(url2,**FFMPEG_OPTIONS)
vc.play(source)
honestly my head is going insane
this is my code
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
hey guys
The error is no attribute called FFmpeg
my bot not working
taht tut is for commands not listeners tho
raise ClientException(f"{executable} was not found.") from Nonediscord.errors.ClientException: ffmpeg was not found.
error
We cannot help you
someone help pls
@outer parcel youre making music command?
Not in this server
ye
hmm
vps's shouldnt be based off of where someone lives, more so where they want the servers to be
....you do know that was unnecessary
guys my bot not working like it should
can someone help guide me on how to make a paginator with buttons and each page has 5 fields and values depending on what I select from my DB
if that makes sense
jkj
just use discord.ui
that's pretty vague
guys my bot not working like it shows that it its online but no command work
are you handling on_message event?
ik but most people like their servers to be based on where they live
i have made a help command similar to your specs
it would make no difference
yes like 4 of them
the tutorial you sent dosent work
hey myxi
its ment for commands not listeners
you can have only one though. You might be talking about checks
hey its been a long time since I came here
but i ran with 4
yeah
nono on message
what was the decorator that you used?
why wont my cog work
show relevant code?
how if theyre using there own currency some vps dont accept other cur
you dont need 4 different on_message global events for that.
hmm
Congrats, you totally won the award for the BEST code ever!
XD thank you thank you
task: <Task pending name='disnake: app_command_preparation' coro=<InteractionBotBase._prepare_application_commands() running at C:\Users\tenuk\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\interaction_bot_base.py:849> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x0000022E7F8BDF70>()]>>```
What's this?
you would use listen
im noob man
you can only have one event but multiple listens
Idk, uncaught error?
you can use .lower() so you don't have to make a bunch of if statements
https://paste.pythondiscord.com/nomarelahi why cog no work?
@sullen shoal can you help me here?
show full code
use @bot.listen()
if x.startswith(...):
...
elif x.startswith(...):
...
else:
...
You can chain all of them like that inside one function and delete others
no need of code
!d discord.ext.commands.Cog.listener is what you should use
classmethod listener(name=...)```
A decorator that marks a function as a listener.
This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
hmm
where?
cause the tutorial sent does cmds
will it solve my issue?
in your events...
if you implement it the right way, yes
ohok
so replae all bot.events with bot.listen
Y’all would uptime robot work for hosting a bot
no its supposed to be commands.Cog.listener() did you read what i sent and docs?
ive heard its horribly slow
what u sent dosent make sense
well it does if you actually read it
I’ll give it a try i guess
i know its long an all but atleast read it
its used to show uptime of a website, those are not hosting service
it still hosts tho
because you can doesnt mean you should
it doesnt, you might be talking about using replit with it
i am
replit is hosting it. not the uptime website
so this@commands.Cog.listener()
async def on_member_join(member):
with open('users.json', 'r') as f:
user = json.load(f)
await update_data(users, member)```
something like this?
Yesn't
your code is blocking and the library is asynchronous as it should be
hehhh
and please dont use json as a database, its not meant to be used for that
it was a tut from 3 years ago ._.
youtube discord bot tutorials from top youtubers are trash and I wish those get deleted as soon as possible
Then what am i ment to do 😭
What database should I use for my economy system?
you learn python, OOP and use of decorators properly
whats a good DB then
Sqlite is an option
Is sqllite easy to learn or does it take time?
you just gotta need the programmer-like thinking skills of an average programmer to learn the intermediate stuff in 2-3 days or so
otherwise, it might take some more days
You would be learning SQL and it's extremely easy
I learnt the basics in a couple of days
why is coding difficult
its not
It's like learning a whole new language except it's even more complicated
i mean coding also includes html, if thats not easy then idk what is
its really not.
exactly and i cant even learn spanish
It is
learning an actual language is much harder
no its not
It's not
Well actually it depends
If your native language was English and you're trying to learn Chinese I would say it's harder
my command prefix is -p how can i make it so even if its more than one whitespace it will still run the command
Example of what im trying to say:
-p help
when you gotta open their grammer book then you would know the pain of learning an irl language
But if your native language was English and you're trying to learn a language like French it's easier
coding is logic whereas learning a language requires you to learn some 40k words, how to conjugate, pronouns, all sorts of shit
Coding is technically logic but it's much harder to learn in practice
its hard in the beginning, but, after you understand the concept, you just need to know some english keywords and some bit of syntax that shouldnt take much time, the other work is just knowing different functions and stuff of the built-in libs of that programming language, i would call it vocabulary of that programming language or some shit
strip_after_prefix=True in commands.Bot
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "D:\Discord BOT\main.py", line 46, in on_message
await update_Data(users, message.author)
UnboundLocalError: local variable 'update_Data' referenced before assignment```
help
Code?
same one
Is it possible to cancel the command used before, with another command?
depends on what the command does
async def on_member_join(member):
with open('users.json', 'r') as f:
user = json.load(f)
await update_data(users, member)
with open('users.json', 'w') as f:
json.dump(users, f)```
just sending some messages in a embed
so its in a loop of sending messages?
no it just sends multiple embeds after another telling a story
how much time does the command need to execute then?
someone help..
you want to cancel further execution of the command instance right?
how do i do dis?
i think about 36 seconds in total to finish
!e
def my_func():
my_inner_func()
def my_inner_func():
print("a")
my_func()
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 7, in <module>
003 | File "<string>", line 2, in my_func
004 | UnboundLocalError: local variable 'my_inner_func' referenced before assignment
someone help!
@terse blade see the issue?
no i dont
Try looking at it hard
wow, all of the accounts here really are just self-botted to copy and send every error they find
set an attribute to your Bot instance
ctx.bot.canceled = False
instead of sending them yourself, make a list of strings containing each message. then iterate through the list and on each iteration, check if bot.canceled is True, if it is, then return else send the current element
Be more respectful, please
Also if you have any evidence of this, please make a report to @novel apex .
he's stacked on evidence
Huh
!e py def some_function(x): print(double(x)) def double(val): return val * 2
@quaint epoch :warning: Your eval job has completed with return code 0.
[No output]
oh i forgot to run it lol
!e py def some_function(x): print(double(x)) def double(val): return val * 2 some_function()
@quaint epoch :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | TypeError: some_function() missing 1 required positional argument: 'x'
wow maybe i'm a bot
!e py def some_function(x): print(double(x)) def double(val): return val * 2 some_function(1)
@quaint epoch :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | File "<string>", line 2, in some_function
004 | UnboundLocalError: local variable 'double' referenced before assignment
?
yeah this the error @terse blade , read it good and well
#bot-commands
you're right
dont ping me pls
we're trying to help
thanks
I don't know why its reading top to bottom tho
python works that way
you can't change that
so whats the error
your function update_data is probably further down the code, so you have to move it up to the top
You're calling the function before defining it
Just like my example showed
anyone ping me if you know how to do this -
It's a timestamp
!d disnake.utils.format_dt
disnake.utils.format_dt(dt, /, style='f')```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)"), [`int`](https://docs.python.org/3/library/functions.html#int "(in Python v3.10)") or [`float`](https://docs.python.org/3/library/functions.html#float "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
<t:17282727>
<t:17282727>
.bm
im so confused on where i put it
you might want to consider learning basic python
i put it before everything and it still happens
Define it before you use it
!e
def my_func():
my_inner_func()
def my_inner_func():
print("a")
my_func()
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 7, in <module>
003 | File "<string>", line 2, in my_func
004 | UnboundLocalError: local variable 'my_inner_func' referenced before assignment
wait
!e
def my_func():
def my_inner_func():
print("a")
my_inner_func()
my_func()
@final iron :white_check_mark: Your eval job has completed with return code 0.
a
this isnt really helping him
🤷♂️
it was the wrong error
What else can I do
async def on_message(message):
with open('users.json', 'r') as f:
user = json.load(f)
await update_Data(users, message.author)
await add_experience(users, message.author, arg)
await level_up(users, message.author, message.channel)
with open('users.json', 'w') as f:
json.dump(users, f)
async def update_Data(users, user):
if not user.id in users:
users[user.id] = {}
users[user.id]['experience'] = 0
users[user.id]['level'] = 1
async def add_experience(users, user, exp):
users[user.id]['experience'] + exp
async def level_up(users, user, channel):
experience = users[user.id]['experience']
lvl_start = users[user.id]['level']
lvl_end = int(experience ** (1/4))
if lvl_start < lvl_end:
await client.send_message(channel, '{} has leveled up to {}' .format(user.mention, lvl_end))
users[user.id]['level'] = lvl_end```
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "D:\Discord BOT\main.py", line 44, in on_message
await update_Data(users, message.author)
UnboundLocalError: local variable 'update_Data' referenced before assignment
damn
read ->
UnboundLocalError: local variable 'update_Data' referenced before assignment
You're still calling it before defining it
ive never encountered this error
" referenced before assignment" should tell u enough
so i put it higher or lower
Just define the function before you call it
im so lost 🤦♂️
cause you dont try learn python and just take copy pasta codes
i even search now on await update_Data in this discord, i can see plenty have same script.
i dont copy and pasta but ok
ok u sure?
?
it isnt but ok
Is he Calling a function before the instance of where it is written?
so you just named examctly same variables and all? wow thats a huge miracle
ikr!!
Why not make use of a guard statement instead?
async def on_message(msg):
if msg.author.bot:
return
with open("users.json") as f:
users = json.load(f)
...
Edit: @wicked lily
But all have given u answer n helped u
👆
@rugged steepleits a print of searched on this server... to show that @terse blade sais he didnt copy pasta but its exactly same code.
they all prob asked same questions too lol
taking python so seriously 💀

stop pissing urself man its hella funny
We just like to help n support others to willingly wanna learn python n not just copy pasta n ask for help everytime their copied code dosnt work.
i dont copy and pasta
Traceback (most recent call last):
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 998, in call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\commands.py", line 481, in _invoke_with_namespace
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'profile' raised an exception: AttributeError: 'Interaction' object has no attribute 'send'```
anyone know whats happened
myixu farted
@terse bladeand you know poeple has answered u lol.
didnt ask
didnt
K
does anyone know whats wrong with this
#bot-commands
It has no send attribute
@final iron comeone bro error said .send() not exists for interaction 😛
!d disnake.Interaction
class disnake.Interaction```
A base class representing a user-initiated Discord interaction.
An interaction happens when a user performs an action that the client needs to be notified of. Current examples are application commands and components.
New in version 2.0.
what is this disnake library?
fork discord.py
:o
!d disnake.Interaction.response
Returns an object responsible for handling responding to the interaction.
A response can only be done once. If secondary messages need to be sent, consider using followup instead.
@slate swan ^
and has far better implementation of slash command and other stuff than discord.py in my honest opinion
If it comes highly recommended i'll have to swap over.
Oh it has slash commands? Discord doesn't have those yet.
I mean the discord library
!d disnake.Interaction.send
await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
If the interaction hasn’t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
Note
This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_message "disnake.Interaction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if you’re sending a followup message.
discord.py has slash commands
it does now
They're using discord, not disnake
Cool, I'll look into it.
Then again, you should have a look at the syntax first
json.dump(users, f)
NameError: name 'users' is not defined
What should I define a user as?
ops
kek...
get outta here
dpy's implementation is complicated, and not final (it's not on stable)
thats something you should know as youre the sole owner of that piece of code
its a variable - but not defined... but maybe it should be a string like "users.json" but what ever basic python
@manic wingaint this kinda too much? huh
Where do i put my description on the command on slash command
he's been asking the same type of question for the past 30 minutes and then acting as if he doesnt care
just ignore him
Which lib are you using
and dosnt even understand the answers... but continues ask other simple stuff that i would google to figure out when learning python
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "D:\Discord BOT\main.py", line 49, in on_message
json.dump(users, f)
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 179, in dump
for chunk in iterable:
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type module is not JSON serializable```
What does this mean
no, it means the json he passed is not serializable. meaning you cant pass an object.
@terse bladecode?
In disnake,
@bot.slash_command(description="This is the description")
async def command():
...
# OR
@bot.slash_command()
async def command():
"""This is the description using docstrings."""```
t
It contains it but then why i send a message it just clears the file
dpy 2.0
@terse bladesend code
cant do much with 1 line
"""single line docstrings should be like this"""
"""```
Check the readme Danny posted. It has a lot of examples
I thought u didnt copy the code - so if u could write all that code you should definetly now those basic stuffs - lier.
Didn't notice I did that, mb
@final ironwheres that
it dosent make sense why is it just clearing the file
cause u dont know python at all, and it writes to the file {} or something
the discord.py docs arent for unstable release
@terse bladesend the code
!d discord.app_commands.CommandTree.command
command(*, name=..., description=..., guild=..., guilds=...)```
Creates an application command directly under this tree.
im slow in the head thats all
@slate swan I would assume the description kwarg
@terse bladeam gonna block u - even got advised to ignore u.
good for you have a blessed life 👍
I see it's pretty active in here so I claimed #help-chocolate for what I was typing up for here
async def give(ctx, a: int, member: discord.Member=None):
users = await chung_data()
user = member or ctx.author
wallet_amt = users[str(user.id)]["Wallet"]
users[str(member.id)]["Wallet"] += a
users[str(ctx.author.id)]["Wallet"] -= a
with open("chungbank.json", "w") as f:
json.dump(users, f)
embed = discord.Embed(title = f"given {a} leancoins")
embed.add_field(name = f"{user} now has", value = f"{wallet_amt} leancoins")
await ctx.send(embed = embed)``` heres my code so basically when i give coins to another person i can still give a million even if i have zero and it showes that i now have -1 million, i want the command to not be useable for users who have no coins
Obligatory but I strongly recommend you to use a database or you end up in what I like to call “JSON hell” with str() and many [] which is basically asking for a KeyError
What's the best way to handle listening for events in a particular voice channel say joins/leaves etc?
@final ironWhere at tho
@tree.command()
async def mine(interaction: discord.Interaction):
In the decorator
@tree.command()???
That is the decorator
C:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer>C:/Users/turne.DESKTOP-8B1DN4C/AppData/Local/Programs/Python/Python39/python.exe c:/Users/turne.DESKTOP-8B1DN4C/OneDrive/Desktop/Dogeminer/main.py
Traceback (most recent call last):
File "c:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer\main.py", line 35, in <module>
@tree.command(describe = "HI")
TypeError: command() got an unexpected keyword argument 'describe'
@tree.command(describe = "HI")
There's no describe kwarg
maybe you're looking for description instead?
All of the kwargs you can use are here
hey, i am making a ?roll command but it dont work because my link "are not valid argument" ! Can someone help me ?
import discord
import os
import random
from discord.utils import get
from discord.ext import commands
default_intents = discord.Intents.default()
default_intents.members = True
bot = commands.Bot(command_prefix="?")
@bot.command(name="roll")
async def rating(ctx):
variable_list = [
'https://ibb.co/XZpqkTq',
'https://ibb.co/XtsCbGg',
'https://ibb.co/vX5SbWB',
'https://ibb.co/9ZRKDq0',
'https://ibb.co/n7nMj7F',
'https://ibb.co/k9K96fQ',
]
embed = discord.Embed(
colour=0xc81f9f,
title="Dé",
description=(random.choice(variable_list)),
file=discord.File((random.choice(variable_list)))
)
embed.set_footer(text=f"{ctx.message.guild.name}")
await ctx.send(embed=embed)
bot.run("mytoken")
Send the full traceback
are those links returning media file?
file=discord.File((random.choice(variable_list)))```
yup
any specific type? image? video?
image ^^'
you can use Embed.set_image to do it easily
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
in description= ?
embed is an instance of discord.Embed
embed.set_image(...)
both of them will newly choose a random item from the list. You have to store it as a variable then pass it to both of these
u would need to download em or read em as byte and put that into File()
theres not need of file kwarg if you use set_image btw
^
ok thx im gonna try!
yeah set_image would do what u want smoothest simplest
@sullen shoalsmart thinking 😉
😉
😳
Ignoring exception in command tree:
Traceback (most recent call last):
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 875, in wrapper
await self.call(interaction)
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 955, in call
raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'mine' not found
PRO```
why did this happen after i added a description
How do invite tracking bots work if there is a 1000 invite limit (meaning only 1000 members can be tracked)
1 perm invite
It's not one invite per user, it looks at all the invite join counts before and after a member joins, sees which has changed and reports it
C:\Users\turne.DESKTOP-8B1DN4C\OneDrive\Desktop\Dogeminer>C:/Users/turne.DESKTOP-8B1DN4C/AppData/Local/Programs/Python/Python39/python.exe c:/Users/turne.DESKTOP-8B1DN4C/OneDrive/Desktop/Dogeminer/main.py
Ignoring exception in command tree:
Traceback (most recent call last):
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 875, in wrapper
await self.call(interaction)
File "C:\Users\turne.DESKTOP-8B1DN4C\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 955, in call
raise CommandNotFound(name, parents)
discord.app_commands.errors.CommandNotFound: Application command 'mine' not found
i changed description#=#
@slate swan so you're able to see who invited who with just 1 invite?
no
No
You can see all of the invites and who created them, after a member joins you see which invite increased its join count, then you get the person who created the invite and that's who invited the member
too lazy, and json is easier
I doubt that
i havent had any problems yet
Yet but needless overcomplication
using db is actually easier than shitty (in this case) json
But to solve your original issue you'd want to check if the user's current amount is greater than or equal to the amount they want to give
Especially with something like SQLite
right I know that. But there is still a 1000 invite limit. so 1000 invites can be created right?
yep
yeah
meaning <= 1000 users who created that invite
huh?
each member can create their own invite
which is then associated with them, since they've created it
Yes..?
if someone joins using that invite, then you can see that they have joined using that invite
and can get the user who created that invite and do whatever
Well you'd have to write your own logic but yes
maybe i am failing to understand. If you have 1 perm invite link, how can that be associated to multiple users?
only 1 person has created that perm invite
It's not associated with multiple users
Stop thinking of invites as associated with users that will help you understand
its associated with whoever made it

wipe out the client var

