#discord-bots
1 messages · Page 635 of 1
you've passed only 2 parameters, there need to be 3
so it must have made ctx into a value
Pass message
help pls
You have to put something into message argument
so what should ctx be
Bruh
Remove self
as i put 2 values
from?
You're not in a cog
oh
and there is ctx
@bot.command()
thx
async def ()
and other places too
Pass message
brain burn time lmao
i have
Show what you did
@radiant horizon why don't you just do
user = bot.get_user(id)
await user.send(message)
The most traumatising time was when I was helping a hysterical person
wait
He went crazy and started screaming at me
Inside that command
let me try
bro calm down i wasnt screaming at you
And said NO LINE 27!!!!!!!!!1!1!1!1!1!!1!!
No not you
show your whole code.
oh ok
Another person
Of the command
class HelpDropdown(nextcord.ui.Select):
def __init__(self,bot,ctx):
self.ctx=ctx
self.bot=bot
options = [
nextcord.SelectOption(label=f"", description="Chose to see General Help", emoji=self.bot.get_emoji(889924503528943717)),
nextcord.SelectOption(label=f"", description="Chose to see Moderation Help", emoji=self.bot.get_emoji(889924486391029811)),
nextcord.SelectOption(label=f"", description="Chose to see Entertainment Help", emoji=self.bot.get_emoji(889931893708054600)),
nextcord.SelectOption(label=f"", description="Chose to see Music Help", emoji=self.bot.get_emoji(889923020313997344)),
]
super().__init__(placeholder='Select section', min_values=1, max_values=1, options=options)
async def callback(self, interaction: nextcord.Interaction):
eGeneral = nextcord.Embed()
eModer= nextcord.Embed()
eFun = nextcord.Embed()
eMusic = nextcord.Embed()
if self.values[0]=='General Help':
await interaction.response.send_message(embed=eGeneral,ephemeral=True)
elif self.values[0]=='Moderation Help':
await interaction.response.send_message(embed=eModer,ephemeral=True)
elif self.values[0]=='Entertainment Help':
await interaction.response.send_message(embed=eFun,ephemeral=True)
elif self.values[0]=='Music Help':
await interaction.response.send_message(embed=eMusic,ephemeral=True)
class HelpDropdownView(nextcord.ui.View):
def __init__(self,bot,ctx):
super().__init__()
self.add_item(HelpDropdown(bot,ctx))
@bot.command()
async def помощь(ctx):
await ctx.send(view=HelpDropdownView(ctx))
Ohhh nextcord
ye
I prefer dpy
I prefer disnake
Do you like ducks?
cringe 😂
Mean
Nice
You don’t get my joke, do you?
Ye
I never really understood humour anyways
My humour is cracked
im getting an error
What's the id?
735938469393727578
show code
or maybe you didnt pass all the arguments
Oh ya its str
ok
Convert to int
ok
well that was quick
bot.get_user(int(id))
I have a lesson in a few
so?
actually i am making help cmd
Try run it
try this
the most used word for helpers: "try", "show full code", "show error message", "learn simple python"
@radiant horizon
yes?
I was testing the id
???
how can i add multiple buttons with nextcord?
discord.Role
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
could you show me an example
You just exposed your token
Regenerate it and delete that message
that wont work
repl.it is public
people can still see
Anyone can help how to get invite link of the my discord bot?
You have to get the role object and just use attribute members, it will return the members list
OAUTH
use ENV Vars
ok
Its test bot so i dont care
🤔 i get it but just show me an example because im not using async def(ctx, discord.Role)
so im making a staff list
yes, go to url generator, and see the bottom of the page after setting permissions
basically i want it to update each time someone new becomes staff
Okay
Me and my bot is there only
because rn i had to use ids to list
ok
@radiant horizon can you help me?
and it's kinda painful so is there any way
@velvet tinsel lul
lmaooo
with what?
@radiant horizon this code
whats the problem
I am sending help cmd with buttons but buttons are not there @radiant horizon
bro use discord.ui
it's official.
check discord.py github then go to examples then views
then there's example of dropdowns and buttons
Ok
How to fix this
don't know but i can def say git clone official repo of discord.py
reinstall discord.py
and get the latest version
Cmd
Oh
pip install -U git+https://github.com/Rapptz/discord.py
Two guys joined my replit who are they
must have git installed on your device
bro dont post replit invite , anyone who joins can acess your bot token.
U sent me the link b4, u can kick me out or something
Also yes u put the token in main file, u should probably regenerate it
Its test bot
thanks for the bot btw
Np
Well, id still regenerate it
Did u steal the token 😂
maybe
Lmao u can make it say “im watching you” on random times
Token regen
ok
?
Checking on button click does not work, person is blacklisted but can still create tickets
What are u even trying to do
Check if the participant's ID is on the black list, then write to him that he cannot create tickets
Which function
how do i edit buttons with nextcord?
What library are u using?
When you click on @ on_click.matching_id ('1_button') you need to check if there is a person in the blacklist
change style disabled state and other stuff of button
@rare saddle
yes
dislash
Does nextcord have ui.View?
and ui.Button
Does it have ui.Button?
What - ui.Button?
Class u can inherit to customise buttons
Is dislash a fork?
what does black1 return?
Dict
Got it, but everything is fine with the buttons, I just need a working check
Ignoring exception in command warn:
Traceback (most recent call last):
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\PC\Desktop\Dadudeł Bot\Dadudeł Bot.py", line 270, in warn
await member.warn(reason=reason)
AttributeError: 'Member' object has no attribute 'warn'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\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: AttributeError: 'Member' object has no attribute 'warn'
Nvm, it probably returns none
im aware , im asking about the data it returns not the data type
i got this when i use my warn command
Should return data about guild
I think
It should return the id of the member who is on the blacklist.
I dont think that will work tho
Code?
idk why i got this
ok so black1['member'] would be returning the id of the member right?
This is how a document looks
It should return a list of ints
the next line you have return member.id in ...... is the issue
!e py if 12 in 12 : pass
@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: argument of type 'int' is not iterable
wait
Screen shot pls
ok
What to do in this case?
!paste would be better
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.
member id and the data you compare are both ints , in can be used with iterables
It’ s easier to read from ss on my phone
oh you're on phone
Yes
this is ss of my warn command
That is, create a cycle?
member.warn aint a thing
1 more question , is black1['member'] a single id or list of ids ?
if its a single id , just do if member.id in [black1['member'] ]
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
you dont need to
Click the link and read
.
black1['member'] - this is a list of IDs of people who were added to the blacklist
@slate swan It’ s their ss from b4
there's nothing called member.warn except if it is a custom thing
so what should i do
if member.id in [black1['member'] ] should fix it
What do u expect member.warn to do?
oh i see , they just checked in between integers
Just send the user a msg that they have been warned and store the details in a db
Yes
warnings are nothin inbuild to discord, they are just features of bot @slate swan
i just wonna make it warn user nothing more
^
So this is if the ID is one
Use member.send
It will send them a dm
by warning a member, what do you except it to do
@slate swan
Prolly that's what you want to do
yea , and since you use find_one it always stays a single id right
member: discord.Member
They just wanna shoot em a dm
but i dont wonna sent it to dm's user
what then?
Where do u wanna send it?
And if there are several people on the blacklist, then what?
on the channel where i use the command
sorry i read blackl as black1 . just replace 1 with l lol
Then do ctx.send
There is no reason why someone would want to warn but not store in db
its functional in that case too
That is bit weird but they are free to do it
but where to put it cuz i dont wonna make more mistakes
Yeah their wish totally
They didnt have anything db related in the code so I was guessing they just wanna warn them w/o storing anything
¯\_(ツ)_/¯
Well they thought discord will store it for them lol
Tell me exactly what do you want the bot to do when someone uses warn command
remove if , use return
Cuz they used discord.warn
Ohhhhhh
I thought that was them tryna dm the user
lol they are a bit really weird
Does anyone know how to get a users local time as a timestamp in an embed?
just give message like @slate swan got warned resson: using bad words
datetime.datetime.now() or datetime.datetime.utcnow()
!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.
oh
Anyway, a ticket is being created
i know that
i want it to be a users timestamp
not like specifically utc
I don't think you can get a specific member datetime
something that'll convert to the users local time?
I said it for a users timestamp
It's not of utc
Do you wanna store it anywhere?
Try it then speak
You can
really?
i dont think so i just wonna make it in the simplet way
Ignore me in that case*
Check that doc
yep, I will!
Just send a message to the channel then
okay so, i know that timestamp is a embed kwarg, but what's the value?
Docs sir
ok so what should i do it
but with changeble resson
Wdym?
you want to change a reason after?
i mean if admin use +warn @slate swan can use resson like bad words or something else and the bot in the messages send a resson
Yes, replace str with reason
oh
Str is any string u want to send, u can make it reason @slate swan
If you have reason argument just put that in
@bot.command(aliases=['Warn'])
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, reason=None):
await member.warn(reason=reason)
await ctx.send(f'''"{member}" *został ostrzeżony "{ctx.author}" *powód ostrzeżennia "{reason}"''') so what i need to change here? cuz i dont wonna make stupid mistakes
yeah saw that but sorry but i actually don't understand, what's the value of the timestamp kwarg?
datetime
Remove member.warn and it should work
oh
@bot.command(aliases=['Warn'])
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, reason=None):
await ctx.send(f'''"{member}" *został ostrzeżony "{ctx.author}" *powód ostrzeżennia "{reason}"''') like this?
Run it
okay
yeah but what instance of it?
@commands.has_permissions comes above @bot.command
U can put any datetime
i did that.. i put utcnow()
.
U se pytz for timezones
it works
Nice
damn you just said datetime lol
Read the docs for pytz
do did you got it to work?
U use it with datetime
No
you can use datetime.datetime.now() to get the local time
A ticket is created when my id is blacklisted
Put “if id in blacklists: return” b4 creating ticket
Doesn't work, ticket is being created
Then something is wrong with ur check if member is blacklisted
Send code where u check if member is blacklisted
I think there is something wrong with this
so?
Yes, try that
what new features should I make? (yes asking it again)
does not work
Send whole function
A feature to shut someone up without them knowing it
Ask moderators and admins of servers
Mute cmd
they don't like answering
meaning a mute command?
Return member.id in black1
Either my jokes are becoming lamer or people are becoming more serious nowadays ;-;
Already tried it, doesn't work
Just created ticket number 7
hai
Hello, how I can send date like this in a embed field? https://hagfbahtgghsfhtrhgdsh.xyz/🎳🐗🏰💈
whats a ticket
datetime
Attach debugger and put a breakpoint inside blacklist func
!d datetime
Source code: Lib/datetime.py
The datetime module supplies classes for manipulating dates and times.
While date and time arithmetic is supported, the focus of the implementation is on efficient attribute extraction for output formatting and manipulation.
I'm becoming more serious on these questions I guess ¯_(ツ)_/¯
How, because user.created_at already returns datetime object
The participant's appeal to the server administration = modmail
why can't I reply to messages ;-;
Then u can do datetime.day datetime.month etc
member.created_at.day
Etc
It’ s how u do it
Read the docs of datetime
U can parse numbers to months
may i know what is wrong in here?, i don't really understand that much
here's my full code : https://www.codepile.net/pile/qGVAngXb
and here's the error
Traceback (most recent call last):
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "E:\Codes\Discord-Karaoke-Handler\cogs\karaoke.py", line 7, in <module>
class Karaoke(commands.Cog):
File "E:\Codes\Discord-Karaoke-Handler\cogs\karaoke.py", line 265, in Karaoke
async def _lock(self, ctx):
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 1432, in decorator
raise TypeError('Callback is already a command.')
TypeError: Callback is already a command.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\Codes\Discord-Karaoke-Handler\bot.py", line 63, in <module>
bot = init()
File "E:\Codes\Discord-Karaoke-Handler\bot.py", line 25, in init
bot.load_extension(f'cogs.{extension}')
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\gcpla\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.karaoke' raised an error: TypeError: Callback is already a command.
{{ description }}
U already have a command with the same name
aight thanks
may i know where is the same name? i mean which line
would it be somehow easy to implement Modmail bot?
I have made a attempt of doing one but it fked up a bit
is it possible to multiply the argument to add data in database?
i am trying to make a coinflip command
so if the user uses like
!coinflip 100
and use
c.execute(f'UPDATE data SET balanec =balance 2x{argument}```
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\haramware\linkvertise bypasser\bypasses\2.py", line 23, in <module>
bot.run('my token')
File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 631, in run
return future.result()
File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 610, in runner
await self.start(*args, **kwargs)
File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 573, in start
await self.login(*args)
File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 424, in login
await self.http.static_login(token.strip())
File "C:\Users\mal\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 353, in static_login
raise LoginFailure('Improper token has been passed.') from exc
this is the full code
@bot.command(invoke_without_command=True)
async def coinflip(ctx,*,argument: str):
await ctx.send('bet ammount?')
conn = sqlite3.connect('test.sql')
c = conn.cursor()
ip = random.randint(0, 1)
if ip == 0:
player = ctx.author
c.execute(f'UPDATE data SET balance = balance+{argument}+{argument} WHERE ID = {player.id}')
print('it was heads')
elif ip == 1:
player = ctx.author
c.execute(f"UPDATE data SET balance = balance+{argument}+{argument} WHERE ID - {player.id}")
print('it was tails')
await ctx.send(f'you fliped a coin and won {argument}')```
i am trying to add 2x in the balance as well as in the ctx.send
my token was replaced with my bot token
i tried regenerating but it still doesn't work
Ok
You have the wrong token
i don't
Get it from bot
i have
You probably used the secret number thing
Is it a string?
yes
?
Client.run()?
i am trying to make a coinflip command
and want to make a function which ads 2x the bet amount a.k.a argument can you please tell me how can I do that?
i did bot.run() but i defined bot: bot = commands.Bot(command_prefix='-')
Well you’ll have to pass a vet argument
did you regenerate before copying?
no but i did it after copyying

vet?
*bet
And you ran it again?
you copied token and then regenrate?
yes
Basically what I said
Then it won’t work
whats a bet argument?
coinflip(ctx, amount)
what do u mean?
After you regenerate it you have to copy it again
go on discord bot developer click regenrate and then copy
I don’t know if you’re messing or what
same error
🤷♂️
hey i have problem
Obviously
i know lmao
huh?
i downloaded postdl its a spotify packge
music bot?
and when i try to type spotdl -h in cmd nothing show
nope python app
Yea. Also, the bot is open sourced
wait you trying to make a discord bot or a python application?
python app
then you should see #❓|how-to-get-help
and i will turn it to android when i finish it and check that works in pc
this channel is only for helps related to discord.py library or discord bot making
yeah i know but i said maybe some ppl here that have msuic bots can help with spotify dl
ohh
i have 0 knowledge in that good luck
I’m here
What is that supposed to do?
spotdll -h will show you all the help you need
and you can do spotdl -link [your song link]
and it will download it but nothing work of this
I'm currently trying to set it up to find out how it actually works
Cool
Ok
Pip install it?
i did and it says installed
no im trying to check it from cmd it doesnt need to be imported
Well it probably won’t work in your cmd
Your error weird af
Whats the problem 
If your trying to check if a file is downloaded just try to download it again and it will say requirements are already satisfied
why ? thats the problem
Just install it in your
yes thats what it says
IDE
This is not a python related problem I think
Sometimes module commands won’t work in terminal
kk
Hmm. it seems to be quite easy to copy modmail
But implementation to make it work inside my own bot without the need of too hard work
is someone here
No

like can somebody help me with that help with ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one.
install ffprobe and ffmpeg, it can't find it
{"863091076617601085": {"wallet": 889900, "bank": 50000, "bag": [{"item": "watch", "amount": 0}, {"item": "phone", "amount": 1}, {"item": "laptop", "amount": 1}]}
if I have a json like that ^, how would I find the "amount"?
For like laptop
pls
😭
so all the items are tied to 863091076617601085?
what is the name of main dict?
that’s the file.
what contains this info, what key
You just index it while reading to the file
or just that
users[str(user.id)]["bag"]["laptop"]["amount"] > 0 I tried this
oh wait
I found the code for an index
for thing in users[str(user.id)]["bag"]:
n = thing["item"]
if n == item_name:
i guess this would work
index = 0
t = None
and just loop through
no you’d just index it like you with any other iterable ever
You almost had it the first time
[][][]
[][][]?
This basically.
and why won't it work?
so for an embed im using the Hex 880000 which is a dark red colour but when in discord it shows up as a cyan colour
How are you using it ?
Looks fine to me.
Hi everyone
@client.command()
async def rob(message, member: discord.Member):
member_data = load_member_data(message.author.id)
User_data = load_member_data(member.id)
This is my script but how do i retrieve the other user id
I can’t really tell right now tbh. Mobile issues.
member.id
So you want the id of the person they are robbing.
yes
?
i need id to acces the other players bank value
yea then member.id
Help to create a bot
where do i put member.id
the problem is as soon as i type this command the database crashes
idek why
my database script
json is not db
yes
Well show both
What do you mean show both
Show the exception under thag.
seems like a normal decorator wont work with dpy commands, how am I supposed to make a custom decorator?
very descriptive error
What is data equal to
can you show your custom decorator?
!d discord.abc.Messageable.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
right... sorry 😅
You will have to serialize each message to JSON using your own method
What is the data variable itself equal to? This class?
It is just this so far, ```py
def restrict_to_user(f):
@wraps(f)
async def inner(*args, **kwargs):
print(args)
print(kwargs)
return await f(*args, **kwargs)
return inner
data is equal to this class
you can make a custom check
!customcheck
Custom Command Checks in discord.py
Often you may find the need to use checks that don't exist by default in discord.py. Fortunately, discord.py provides discord.ext.commands.check which allows you to create you own checks like this:
from discord.ext.commands import check, Context
def in_any_channel(*channels):
async def predicate(ctx: Context):
return ctx.channel.id in channels
return check(predicate)
This check is to check whether the invoked command is in a given set of channels. The inner function, named predicate here, is used to perform the actual check on the command, and check logic should go in this function. It must be an async function, and always provides a single commands.Context argument which you can use to create check logic. This check function should return a boolean value indicating whether the check passed (return True) or failed (return False).
The check can now be used like any other commands check as a decorator of a command, such as this:
@bot.command(name="ping")
@in_any_channel(728343273562701984)
async def ping(ctx: Context):
...
This would lock the ping command to only be used in the channel 728343273562701984. If this check function fails it will raise a CheckFailure exception, which can be handled in your error handler.
keeps saying thee token is invalid
so it's basically a decorator but a check that returns a True/False?
Yes
async def check_this(user, item_name):
users = await get_bank_data()
item_name = item_name.lower()
index = 0
t = None
for thing in users[str(user.id)]["bag"]:
n = thing["item"]
if n == item_name:
amount = thing["amount"]
if amount == 0:
return [False, 2]
users[str(user.id)]["bag"][index]["amount"] = amount
t = 1
break
index += 1
if t == None:
return [False, 3]
i use this to check my json, and I made a variable res = await check_this(ctx.author, "laptop"), and I made sure my "laptop" amount was 1. I made an if/else statement to check if it returns 2, and if it did, to say "you dont own this item". But when I ran the code, it said "you dont own this item" when I the amount of laptop is 1. what is the problem?
ah, that is exactly what I'm looking for! Thank you 😄
wait no it's not
If it returns False that will raise commands.CheckFailure
good to know
You have to implement __getstate__/__setstate__ to be able to pickle a custom object iirc
why
what do you mean
this is the first time I asked a question in 2 weeks
!d discord.ext.commands.check
i have problem with this how i fix this?
You sure?
@velvet tinsel what about this 🤨
to be able to deserialize/serialize a custom class with pickle, there are two "magic methods" you need to implement.
Magic methods are things that start with __ and end with __ usually, and you can see how __init__ is an example of a magic method which initializes an object.
In this case you would implement __getstate__ and __setstate__
webhook doesn't exist
stop
please
😭
Lmao
do you know the reason to my problem? Or should I claim a help channel
at least it's doing something
it used to just be like "no"
What happened?
im confused on how i implement it
I understand the deserializing and serializing
wait i'm re-checking it
you would define the __getstate__ and __setstate__ functions which take the instance itself (self) and another argument maybe that I forget
but I'm actually not sure about the reason why it's complaining about a weakref
ok thx
@client.command()
async def java(ctx):
embed = discord.Embed(
description = "Click on the button and get the Java role.",
color = 0x8FFFFF
)
msg = await ctx.send(
embed=embed,
components = [
Button(style=ButtonStyle.green, label="Java", emoji="✅")
],
)
def check(res):
return ctx.author == res.user and res.channel == ctx.channel
try:
res = await client.wait_for("button_click", check=check, timeout=15)
except asyncio.exceptions.TimeoutError:
tembed = discord.Embed(title="Timeout!", color=discord.Color.red())
await msg.edit(
embed=tembed,
components = [
Button(style=ButtonStyle.red, label="Timeout!", disabled=True)
],
)
await asyncio.sleep(5)
await msg.delete()
return
if res.component.label == "Java":
member = ctx.author
mrole = discord.utils.find(
lambda r: r.name == "Java", ctx.message.guild.roles
)
role = get(member.guild.roles, name="Java")
if mrole in member.roles:
await res.respond(content="You already have that role!")
await asyncio.sleep(0.5)
await msg.delete()
return
else:
await member.add_roles(role)
await res.respond(content=f"I gave you the `{role}` role!")
await asyncio.sleep(0.5)
await msg.delete()
return
else:
return
This interaction failed! why it is like that when I click on the button?
Where am I passing a value to inner? I don't think I'm doing that, right? https://paste.pythondiscord.com/ruwogimoso.sql
def restrict_to_user(user: int):
async def inner():
async def predicate(ctx: Context):
return ctx.author.id == user
return check(predicate)
return inner
this is weird
Im new to python so where would i define the function
Yep
can u pass lists in @ornate cliffissions.is_user?
yep
bruh
getstate = loading
setstate = save
https://www.toptal.com/developers/hastebin/ixodapahog.py
why does it send "you don't own this item!" when I do ;use laptop?
ty ill do that and come back
Why do u have 3 defs tho?
don't you need need player id also as an argument
my code is messy af I know
object.__getstate__()```
Classes can further influence how their instances are pickled; if the class defines the method [`__getstate__()`](https://docs.python.org/3/library/pickle.html#object.__getstate__ "object.__getstate__"), it is called and the returned object is pickled as the contents for the instance, instead of the contents of the instance’s dictionary. If the [`__getstate__()`](https://docs.python.org/3/library/pickle.html#object.__getstate__ "object.__getstate__") method is absent, the instance’s [`__dict__`](https://docs.python.org/3/library/stdtypes.html#object.__dict__ "object.__dict__") is pickled as usual.
Oh
uuh... It was because I once was making a similar decorator where I had to pass smth in weird way like that
do i leave like this then
I got it working!
Cool
Yep
But I think the reason why it's failing is because since you're pickling the class itself there are some things that can't be pickled in the instance
Keep it where it is rn
please?
What's the error?
#help-croissant please
Could you screenshot it since you mentioned it's a big error?
I dmed it to you
!paste works as well for large amount of stuff
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.
My DMs are buggy so it's not letting me open them
Hey @outer parcel!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Oh
disnake is the preferred lib now?
Yah
Never heard of it
I have heard disnake is a better choice
ty
It looks like you got ratelimited by making too many requests
So what should i change
Damn

I'm not sure about your entire code but usually you get ratelimited if you made too many requests (like calling functions too fast if theyre dpy functions)
What is a method of fixing this
Waiting. And fixing whatever is causing you to get ratelimited.
Probably making delays but it depends
Im using repl here so can i boost my repl
Yes who doesnt love waiting
I would also recommend not using repl.it to host your bot. As they share IP addresses with other machines and since API bans are based on IP you can see how that is bad
Edpy is hot garbage
Fits this description just perfectly
No one can see my IP
You share a ip lmao
In replit you share ips withother users which if the ip gets banned you will be banned too
Discord obviously can as that's how they API ban. And repl.it shares IPs with its other machines meaning if someone got API banned on discord and you are using the shared machine you also get API Banned
so what coding software should i use
You should use
i paid for replit upgrade features :/
Atom?
Uhh
im confused in what you mean
Tyler knows the solution to my problem
But I don’t
I mean the code works
But like there’s a weird error with my if else statement
It’s saying that I didn’t do something when I entered the correct thing
😭🤷♂️ well
I don’t actually. that’s why I haven’t said anything. Me no like to read big code on mobile
Same gives me a stroke
Ok
all I got to say is. Make sure you're indexing what you want properly.
I did
It works
But
The big if statement brokken
The one that checks if I said laptop
Okimii don’t bully
Pls
@client.command()
async def java(ctx):
embed = discord.Embed(
description = "Click on the button and get the Java role.",
color = 0x8FFFFF
)
msg = await ctx.send(
embed=embed,
components = [
Button(style=ButtonStyle.green, label="Java", emoji="✅")
],
)
def check(res):
return ctx.author == res.user and res.channel == ctx.channel
try:
res = await client.wait_for("button_click", check=check, timeout=15)
except asyncio.exceptions.TimeoutError:
tembed = discord.Embed(title="Timeout!", color=discord.Color.red())
await msg.edit(
embed=tembed,
components = [
Button(style=ButtonStyle.red, label="Timeout!", disabled=True)
],
)
await asyncio.sleep(5)
await msg.delete()
return
if res.component.label == "Java":
member = ctx.author
mrole = discord.utils.find(
lambda r: r.name == "Java", ctx.message.guild.roles
)
role = get(member.guild.roles, name="Java")
if mrole in member.roles:
await res.respond(content="You already have that role!")
await asyncio.sleep(0.5)
await msg.delete()
return
else:
await member.add_roles(role)
await res.respond(content=f"I gave you the `{role}` role!")
await asyncio.sleep(0.5)
await msg.delete()
return
else:
return
This interaction failed! why it is like that when I click on the button?

Im just gonna say it why did you name your bot instance client
Not my fault
I hope

https://stackoverflow.com/questions/70143860/nextcord-button-is-not-showing
Someone help me please lmao
Yes and still no one replied
Is there a way I can check how many ppl joined in the last 24 hours?
I guess loop through guild.members?
!d discord.Member.joined_at
An aware datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.
Should I just do an event like this?
user_count = 0
channel = #blablabla
@bot.event
async def on_member_join():
user_count += 1
async def daily_task():
await channel.send(user_count)
await asyncio.sleep(24*60*60)
user_count = 0```
......?
You think that would work better
Yea ig
how do i set a custom activity?
!d discord.Client.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter.
ty
Hi,
I'm trying to make a discord bot , i already connect it to discord and it work but i want to hide the token of the bot so i made a file named "config" and i made my code , but it's don't work and i have this message error , and if i start a debug it's work perfectly
Someone can help me pls ?
You need to name your file .env and put it in your bots main directory
.env file should contain:
TOKEN=yourTOKENhere
```your code should look something like:
```py
import os, discord, dotenv
from discord.ext import commands
from dotenv import load_dotenv
bot = commands.Bot(command_prefix="!")
load_dotenv()
bot.run(os.getenv("TOKEN"))
okay 'im going to try
also make sure you have the correct dotenv installed with pip.
the install command should look like:
python3 -m pip install python-dotenv
uhh
oHHH
Im so stupid i used a config.json file not a .env 😂
cuz i dont put the actuall token to the public
you can, most people opt for that. I think the .env is preferred with python but im sure there are multiple ways.
my setup is so bad to host a bot
i at first used a .txt file
REALLY?
is it your first bot?
Nope
oof 😂
||I use this currently||
I think my only python project atm is a API wrapper
ahh
it does have its advantages
how would i execute code when the bot is stopped?
turn it back on
nvm i didn't explain that properly
lmao
you could place something under the bot.run so when the bot stops running it executes the code. If its a status message to discord you will most likely need to make a request using aiohttp or probably requests since its not directly in the bots code.
not sure if that would work really, but just a thought
def user_playlist_tracks()
doesnt this look cool im so proud of myself @brittle ingot
how can i call python to run the user_playlist_tracks ?
is it inside a class?
nope
i did it without any py import
i mean i can't specifically say because you only provide the functions constructor.
it dosen't work
things
how can i call python to run the function thats what i mean
this is the full code
results = sp.user_playlist_tracks(username,playlist_id=playlist)
tracks = results['items']
while results['next']:
results = sp.next(results)
tracks.extend(results['items'])
print(tracks)
def user_playlist_tracks(self, user, playlist_id = None, fields=None,
limit=100, offset=0):
''' Get full details of the tracks of a playlist owned by a user.
Parameters:
- user - the id of the user
- playlist_id - the id of the playlist
- fields - which fields to return
- limit - the maximum number of tracks to return
- offset - the index of the first track to return
'''
plid = self._get_id('playlist', playlist_id)
return self._get("users/%s/playlists/%s/tracks" % (user, plid),
limit=limit, offset=offset, fields=fields)```
does anyone know how can I edit a embed in an ephemeral message?
just call user_playlist_tracks() and fill in the functions parameters in the ()
how i can call it ?
1 sec
you cant edit ephemeral messages i don't believe.
i mean like when i run the code everything work but the function doesnt work idk why
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Christmas Movies!"))
await bot.change_presence(status=discord.Status.dnd)``` this doesnt work
the dnd thing does
but not watching
you call it by literally typing user_playlist_tracks() and fill in the parameters
i didnt understand you you mean i remove the function and make it without def ?
hold on
py msg = await ctx.send(embed = embed ,components= [row_of_buttons , columns_of_buttons] , ephemeral=True) here is the embed , when I try to edit this like this ```py
await msg.edit(embed = emb_add_req , components = [row_of_buttons , columns_of_buttons,
SelectMenu(
custom_id="add_req_menue",
placeholder="Select a requirement type",
max_values=1,
options=[
SelectOption("Account Older",'1', "Must be a certain amount of days old"),
SelectOption("Member Older", "2" , "Must be a member for a certain amount of days"),
SelectOption("Role", "3" , "Member must have the specified role"),
SelectOption("Not Role" ,"4","Member must not have the specific role"),
SelectOption("Messages" , "5" , "Must have sent the specified amount of messages"),
SelectOption("Badge" , "6" , "Member must have the specified badge"),
SelectOption("Tag" , "7" , "Member must have the specified operator"),
SelectOption("Voice Duration" , "8" , "Have been in VC for a certain amount of minutes"),
SelectOption("Status" , "9", "Member must have the specific status(es)"),
SelectOption("Bio" , "10" , "Member must have this in their custom status"),
SelectOption("Name" , "11" , "Member must have this in their name"),
SelectOption("Activity" , "12" , "Member must meet a specified activity threshold")])])````
I mean who doesn’t have command logging
btw theres no module named hentai
might wanna fix that
it shows an error
LMAO
that message not found
That is an extremely old screenshot. And I fixed that errors months ago.
no you need the function. Here ill give you an example:
def foo():
return "bar"
response = foo()
print(response)
the output would be:
bar
ohhh i got it thanks alot
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
response = foo()
is you calling the function
It only shows the loaded things if i tell it too lmao
just print(foo())
No need for a var assignment
@client.command()
async def java(ctx):
embed = discord.Embed(
description = "Click on the button and get the Java role.",
color = 0x8FFFFF
)
msg = await ctx.send(
embed=embed,
components = [
Button(style=ButtonStyle.green, label="Java", emoji="✅")
],
)
def check(res):
return ctx.author == res.user and res.channel == ctx.channel
try:
res = await client.wait_for("button_click", check=check, timeout=15)
except asyncio.exceptions.TimeoutError:
tembed = discord.Embed(title="Timeout!", color=discord.Color.red())
await msg.edit(
embed=tembed,
components = [
Button(style=ButtonStyle.red, label="Timeout!", disabled=True)
],
)
await asyncio.sleep(5)
await msg.delete()
return
if res.component.label == "Java":
member = ctx.author
mrole = discord.utils.find(
lambda r: r.name == "Java", ctx.message.guild.roles
)
role = get(member.guild.roles, name="Java")
if mrole in member.roles:
await res.respond(content="You already have that role!")
await asyncio.sleep(0.5)
await msg.delete()
return
else:
await member.add_roles(role)
await res.respond(content=f"I gave you the `{role}` role!")
await asyncio.sleep(0.5)
await msg.delete()
return
else:
return
This interaction failed! why it is like that when I click on the button?
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Christmas Movies!"))
await bot.change_presence(status=discord.Status.dnd)``` the only thing that works is the dnd thing
my bots christmas themed btw :)
What should i do?
ss
ohh , I have also encountered that error ```py
@client.event
async def on_dropdown(inter: MessageInteraction):
try:
await inter.respond()
except:
pass
why would you have pass
just use this at starting of your code
because it just need an interaction to pass
NEVERMIND
no it just passes
yup
You usually want to raise the error in except or handle it some way
here is the fix
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Christmas Movies!"))
await bot.change_presence(status=discord.Status.dnd)```
yup thats what I was doing
the do not disturb thing is the only thing that works
i want it to say watching christmas movies
try:
await interaction.respond()
except:
pass```
you can also use something like this
wait a sec
done
Bare try/except :/
bro im so slow
wht?
where do you change the presence?
can you help me with this?
uhh
on_ready or in your bots constructor?
come on bruhh 😂
you know the bot constructor has activity and status kwargs
doesnt it work either way
nope
cmonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
custom wait until ready
it doesnt
The issue with on_ready is discord is usually sending update requests with guild information and chunking to your bot on_ready and changing presence interrupts that process which discord hates. Essentially in retaliation they may disconnect
you want me to put it up here
You can't send an ephemeral message if it's not responding to an interaction, and you also can't answer to the same interaction twice.
what
yeah either in the () of your bot constructor or by simply putting:
bot.activity = ...whatever
bot.status = ...whatever
He wasn't replying to your issue I believe
i want to change the status 😂
Is there a way to implement overloads for commands?
Like will this work
@bot.command(name='xd')
@overload
async def somecmd(ctx, user: discord.User): pass
@overload
async def somecmd(ctx, channel: discord.TextChannel): pass```
nice pfp im guessing you made it yourself
You need to define the Exception
yeah
looks great man
thanks though I just pasted a background and a text box with a nice font lol
yes that's your bot constructor
yes or put right under it:
bot.activity = ...whatever activity
bot.status = ... whatever status
yes a )
Ok its at the end
status and activity are two seperate kwargs
what
you are including status in your activityType
There is not really ovloading in python, you can just Union the function though
any one can help me with spotipy here ?
whats spotipy
from typing import Union
@bot.command(name='xd')
async def somecmd(ctx, arg: Union[discord.User, discord.TextChannel]): pass
ik what u mean
OH
SPOTI
PY I GET IT LMAO
@brittle ingot yo
now it wont work
idk what to change
bot.change_presence(status=discord.Status.idle,activity=discord.Activity(type=discord.ActivityType.watching, name="something VICIOUS."))
im doing it up here
that's a method
lol
ye
he is trying to set presence in bot constructor
ic
I just changed the presence inside an wait_until_ready
!d discord.ext.commands.Bot.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
just do:
bot.status = discord.Status.dnd
bot.activity = discord.Activity(name="Your Status", type=discord.watching)
or something
brb
uhh please helpp i ve alreadyy pip installed discord
isn't setting presence a coro?
Yes
BOOM LETS GO BABT
IT WORKED
why u downloading embed agains
lul
import mess lol
what?
@clear rapids No module named 'MessageInteraction'
massacre
no wait whats the purple one called
whats that
i forget what its called
which liberary are you using?
the purple vscode
yeah please help
Your imports are all over the place
not if you are doing it in the constructor, as far as i know.
?
haha i know
arrange it
urs is purple
change_presence is a coro 
You know you can do this? ```py
from typing import (
Union,
Any,
Optional
)
bro whats the purple vscode called
Blue = Visual Studio Code
Purple = Visual Studio
OK
OHGGG
XD
why not use the blue?
ikr y naut blue
only the true og used visual studio..
oof
isnt it more usefull that using visual studio
you have to use the interaction based on the library you are using , I'm using dislash.py . for example if you are using discord.py just read about interaction events in its docs and apply that
Disnake.py here 
literally so cool
noice
a few days ago i was going to literally go without a help commad cuz i tried making a weird cog by myself becuase the cog wasnt getting recognized
or yesterday
uh help :/
hmm?
help on what...
with the error i told you
@reef shellclever nickname
.
lol
it's pip install discord.py, but i recommend disnake.py
i have already pip installed it
no s @reef shell 🤪
.
cant say certain words in here cuz i almost got banned once
You can use those words like shit but not towards anyone. Or at inappropriate times.
You can use slangs/ swear ig 
unless you use them to insult someone
OH
ye
Can i get the exact command you type in cmd?
pip install discord.py