#discord-bots
1 messages Β· Page 998 of 1
wait
worked, thanks
so, getting a channel/whatever is proved useless isnt t?
youre the only usefull guy here
Yes
most of the times, yes
I agree, The Almighty Hunter
so...rest of us are useless, π... alright got it, thanks
u made my day... uff
same, its good to recall the truth every once in a while
but in case you want to "not" make useless requests you can use get_x s to check if that channel exists or not
~~at least someone can feel my main of being useless ~~
yeah
Dude stop it. He's just saying this cz I'm here most of the time and have helped him successfully many times in the past
ammm @slate swan
it says it has a mistake on this line:
async def ping(ctx: commands.Context):
whoosed moment
but it doesnt-
U r missing a closing bracket in the former lines
Same for you, @slate swan
okay sissy
u just got whoosed bro... :'/
anyways, ok :")
where?
can u resend it?
lmao
Idk your code, sooo
@lofty tide paste yr code
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="ip", intents=discord.Intents.default())
@bot.command()
async def ping(ctx: commands.Context):
await ctx.send("HI")
@bot.listen("on_ready")
async def on_ready_ip():
print("online")
bot.run("my token")
!code for next time...
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="ip", intents=discord.Intents.default())
@bot.command()
async def ping(ctx: commands.Context):
await ctx.send("HI")
@bot.listen("on_ready")
async def on_ready_ip():
print("online")
bot.run("my token")
@lofty tide mind showing the error?
checking
sidenote: intents=discord.Intents.default() this is useless since the intents are already defaulted to the same
It's a required arg in 2.0
oh, makes sense
still showing error on this line
sarth
but why would they use .default in 2.0 without .message_content? π
What's the error
show error please
are u making a bot for some server
it says "bad input"
Ah, nvm
Show whole error
im working on a new public project for a friend
!traceback read the embed below
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
nicee
wdym
Sameee
The website (the whole project) is almost complete
ohhh nice, what is it about?
is it the same you were working on a few months back?
Let's move this to #ot2-never-nesterβs-nightmare
ok
Yea bro
wdym wdym show the whole error
hey so im making a bot and im having a problem basically my bot is printing the IDs of everyone with a certain role and from that im trying to assign a variable to every id but everything i have tried so far does not work as everyone's id in this group acts like its all a single value
wdym show the whole error @maiden fable
k ty
The whole Bad input thing
read this @lofty tide ^^
didnt know it was possible though to assign a varriable as a value in a dictionary
i dont understand that
thats the line
it just says that there`s a bad input thing in the ling
line*
do u know any python, if not i would recommend learning that before making a discord bot.
Making a discord bot as ur first project is shooting urself in the foot
Hey guys!
IΒ΄m working with pyCharm to make a discord bot (I started a few weeks ago, so sorry if I make a silly mistake). But earlier everything worked and now I get this error message:
Traceback (most recent call last): File "/Users...", line 3, in <module> from discord_slash import SlashCommand File "/Users...", line 9, in <module> from .client import SlashCommand # noqa: F401 File "/Users...", line 12, in <module> from . import context, error, http, model File "/Users...", line 10, in <module> from . import error, http, model File "/Users...", line 12, in <module> from .dpy_overrides import ComponentMessage File "/Users...", line 4, in <module> from discord import AllowedMentions, File, InvalidArgument, abc, http, utils ImportError: cannot import name 'InvalidArgument' from 'discord' (/Users...)
Does anybody know, how to solve it? I tried to delete everything (of course I saved it), so that there is only the: import discord from discord.ext import commands bot.run("TOKEN")
As soon as I want to import the Slash Commands, there is this error message. So is there somebody, who know to solve it?
i just wanna do somthing simple like auto-respond
like if i write "whats the ip?" the bot writes "the ip is play.tryserver.net"
Reinstall dpy
i litteraly give u whole cmd
uh?
I tried that, but the message is still there
pip uninstall discord.py
pip install discord.py
should i give him whole a- z code
Sure
alr then
Thank you, now it works, I think I have written "uninstall" wrong π
import discord
from discord.ext import commands
intents= discord.Intents.all()
bot = commands.bot(command_prefix="!",intents=intents)
@bot.listen()
async def on_message(m):
if m.content.lower() == "whats the ip":
await m.channel.send("ip is the play.tryserver.net")
bot.run("token")
``` do
just use bot.listen() so you wont have to process_commands
ye i was typing in dc so
it says "bad input" in intents = #idk
@lofty tide just ctrl + v all the code
try now i edited
yeah a saw
whats the difference between .listen and .event
it says bad input in async def on_message(m):
uh
show full error
lmfao what
π³
lmao why of all examples
@bot.command(name='hydrorico')
async def hydrorico(ctx, arg: int):
userid = str(ctx.author.id)
if userid == '757508305256972338':
matches = db.prefix(arg)
del db[matches]
await ctx.send(f'**{matches}** deleted from db')
else:
await ctx.send('**ACCESS DENIED**')
gg
bro
i replaced the token with "my token" so u wont see
KEKW
id space ur stuff out
its intended btw
help him im done
add ()
listen here kiddo
@bot.listen()
dont make discord bot when u havent learn all the basics
ur going to end up making a bot that u dont understand why is it working at all
error
lmao
lamo
no need to make a command - everyone knows already
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.bot(command_prefix = '!', intents = intents)
@bot.listen()
async def on_message(m):
if m.content.lower() == 'whats the ip':
await m.channel.send('the ip is, play.tryserver.net')
bot.run('TOKEN')
?
u dont need command for that just do
await ctx.send('100%')
KEKW
who wants to read he dont know python
ahahahahahahahaha
so what actually goes wrong
lololol
π₯
import random
@bot.command()
async def percent(ctx):
await ctx.reply(f"{random.randint(0, 100)}% gay")
ikr
100%
will that work???
yeah i think
cause its a message :D
as long as bot is defined
num1 = random.randint(0, 100
then blahblah num1%gae
!e
import random
print(random.randint(0, 100))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
54
!e
import random
print(random.randint(0, 100))
make it shorter by doing it in a single line
uhhhhhh that doesnt work
error?
no need to be esoteric ;/
yep
no, whats the error
async def on_message(m):
we all are simple python coders
i cant foresee the error in ur console π€£
what
oh
!e print("{import('random').randint(0,100)}%") # not estoric :c
the function is the error somehow
it says thats the error
!e print(import("random").randint(0, 100))
@supple thorn :white_check_mark: Your eval job has completed with return code 0.
62
print us the whole copy
@slate swan :white_check_mark: Your eval job has completed with return code 0.
{__import__('random').randint(0,100)}%
ur extracting the wrong part of error
SARTH IS HERE
ohhhh no, i forgot the f
kek
JESUS
help him
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.bot(command_prefix = '!', intents = intents)
@bot.listen()
async def on_message(m):
if m.content.lower() == 'whats the ip':
await m.channel.send('the ip is, play.tryserver.net')
bot.run('here is the bots token')
and me after this kekw
skev is good in #esoteric-python
import discord
from discord.ext import commands
intents = discord.Intents.all()
bot = commands.bot(command_prefix = '!', intents = intents)
@bot.listen()
async def on_message(m):
if m.content.lower() == 'whats the ip':
await m.channel.send('the ip is, play.tryserver.net')
bot.run('here is the bots token')
i helped u to colour it
ty
!e
globals()["__builtins__"].__import__("random").randint(0, 100)
how did you invoke the command?
!e
print(globals()["__builtins__"].__import__("random").randint(0, 100))
@dusky pine :white_check_mark: Your eval job has completed with return code 0.
5
uh
uh?
what if he says no
gg
um
prefix + command name
@bot.event
async def on_message(msg : discord.Message):
if msg.content == 'whats the ip':
await msg.channel.send('the ip is, play.tryserver.net')
await bot.process_commands(msg)```
...
id use this personally
no need
unnecessary variable and int to string conversionπ
i think its that:
if m.content.lower() == 'whats the ip':
await m.channel.send('the ip is, play.tryserver.net')
it is
that will surely raise an error
@bot.command(name='hydrorico')
async def hydrorico(ctx, arg: int):
if ctx.author.id == 757508305256972338:
matches = db.prefix(arg)
del db[matches]
await ctx.send(f'**{matches}** deleted from db')
else:
await ctx.send('**ACCESS DENIED**')
```like this?
but its not the part
the thing inside if is the problem
how
#ctx
why tf u typehint msg
lol
:/
just go (ctx)
ig
no
cause their bot is a discord.Client, and it does not have a process_commands method
gg
pepo nowadays still use discord.client? π€£
hunter told me to change to bot
to make life easier
life is not easy ;<
make life easier != life is easy
indeed
it would be better to compare if the id is not equal here instead of using if else both ```py
async def command(ctx , arg: int):
if ctx.author.id != the id:
return await ctx.send("you can't do this")
normal code here
what error do you get actually?
typehinting is always good, it allows you to access the properties and methods of the object right from your ide
not just in discord.py, but in general python too
what if the coder dont know python
replit..
imagine typehinting without knowing python
π
gived
def foo(arg: bool="2"):
...
lmao
the error is actually coming from your error handled, may i see what line 1733 ( oof huge file) is?
shessssssh
lol
ok
elif isinstance(error, KeyError):
await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
does the bot have permission to send messages in that channel?
sure
wait what's db.prefix?
matches = db.prefix(arg)
del db[matches]
await ctx.send(f'**{matches}** deleted from db')
```this is the part that gets error
no better option
lmao
i cant let my pc run 247
how is ur bot 24/7
gg
lmao π ppl use repl db?
π and im not going to open that cursed website to check it
ye for some reason
oo hii several ppl
HIHIHI
!pip aiosqlite
=.=
alright its working @slate swan
what did you change?
show code and full traceback
that's still not complete traceback
i think matches might be a list so i added
for match in matches:
del db[match]
```BIG BRAIN
i think so
lol
replit uses json i think
POV: you didnt think about migrating from a repl
tbh idk whats the difference between all those db out there
i never used repl :")
there are soooooooo many
replit's db is so so bad, i cant frame the hate in words
and the stupid error handler is not working
sql databases uses relative database system, ie. tables so you have rows and columns there
i see.. i'm grateful for not using it then lmao
oo
nosql databases like mongodb use json files to save data
ngl, i feel SQL >>> nosql :")
yeah, sql dbs or nice json-based dbs are uwu
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
seccd = round(error.cooldown.get_retry_after())
mincd = 0
hrcd = 0
rseccd = 0
rmincd = 0
if seccd > 59:
rseccd = int(seccd % 60)
mincd = int((seccd - rseccd) / 60)
if mincd > 59:
rmincd = int(mincd % 60)
hrcd = int((mincd - rmincd) / 60)
else:
rseccd = seccd
await ctx.send(f'''
Dont spam :/
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
elif isinstance(error, commands.CommandNotFound):
await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
elif isinstance(error, KeyError):
await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
else:
raise error
```the keyError handler isnt working
π
i like that part , "uwu" π
guys
no database >
that's my personal opinion tho :")
just interested, why?
π depends but ok
@loud junco can u pls create a bot and try that code and send it when its work?
@command.error
im coding an autotyper for discord so like its not a bot. i want to add a function when if someone sends STOP then it should quit() i need some help
its so much easier
?
or someone else
noonesaidjsonisadatabase
because u just have to do indexing? lmao
wdym send it when it works
lemme try
im coding an autotyper for discord so like its not a bot instead its connected to an account . i want to add a function when if someone sends STOP then it should quit() i need some help
instead of using the error handler, you can just use try except within the command function itself
why depend π someone gave a nice idea to use arduino and make the machine write data on paper :)
nonono
but we all are aware of how many newbies use json as their db
@bot.event
async def on_message():
if message.content.lower() == "stop":
cancel = True
for that keyerror.part
thats the last thing i will do
and in the autotyper bit
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
we cant help, aplogies
π oh yeah i remember, even i was there
add if cancel == False:
you need the command name
lmao
thanks to youtube tutorials
like
im doing that for alllllll the command out there
lmao true
cant its not a bot
there's no other choice tho...
for every command i think its @command.error
@regal pulsar what he/she was doing was correct, don't misguide him/her if u don't know what he/she was tryna do
i might be wrong
ae wtf @loud junco tell your gender bruh
bot.error?
what
json uwu, I'm using it for my bot
self bot?
uwu?
json uwu =.=
thats against tos
whats that suppose to mean
π€‘ im using pickle, not even kidding
so i cant help sadly
uwu db
your GENDER is JSON LMAOOO
no comments
i personally identify as shrek/shreks
that's not complete traceback bro...
send it all
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
indentation error π , syntax error
scroll a lil bit
lmfao
u dumb those are var
uwu = 1
json = 1
π
I swear I dont wanna survive in this hellish paradise anymore
error404
π u dumb u forgot to put : and indentation here: #discord-bots message
ik
im saying that it returns True
you have to use the @bot.event decorator here
owo, just wanna know.. if not really then what other possibility is there? π€
404: Not Found means you didn't get a response for your request
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
seccd = round(error.cooldown.get_retry_after())
mincd = 0
hrcd = 0
rseccd = 0
rmincd = 0
if seccd > 59:
rseccd = int(seccd % 60)
mincd = int((seccd - rseccd) / 60)
if mincd > 59:
rmincd = int(mincd % 60)
hrcd = int((mincd - rmincd) / 60)
else:
rseccd = seccd
await ctx.send(f'''
Dont spam :/
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
elif isinstance(error, commands.CommandNotFound):
await ctx.send(f'**{ctx.author.name}**, this command doesnt exist, check your spellling maybe??')
elif isinstance(error, KeyError):
await ctx.send(f'**{ctx.author.name}**, your account is either not created yet or is not in the latest version. Try `rpm start`')
else:
raise error
im giving up this keyerror handler
:'/ alright
its been days and its not fixed
i win
you can even use listen
he isnt in a cog
i don't argue, eito is a good guy :")
its not necessaey
lmao
u can use without cog
:>
yeah but
thanks
very good boy
oh wait
just use try except in the comamnd itself...
thats the only way
π oh ....
nvm :/
ikr :>
u dont
....
i cant even type properly anymore, I'll just go study
im here from around 5 hours
get a life :")
oh yeah
oh u also study?
but it works before this
disappointed?
behold
after i reworked rpm start it just wont work anymore
no
hellish
editing giveaway.py
do you "that" much time?
lol its running in back
wait what?
class Test:
def __init__(self):
pass
def delete(self):
del self
you sure that the error was ever raised?
this wont work but you get what i mean
uhm... your 2nd & 3rd line.. one of them is sure useless :")
don't you guys use the auto Idling presence
lmfao
whats that?
ive been on dnd for 3 years
OHH WAITT, nah it doesn't happen not anymore
I mean, this is the wrong channel
ill never change it
well
add a print statement before ctx.send there to see if it gets triggered
yesyes
okok
but it wont print i think
if it prints then the error wont spam my console
but i ttry
nope it doesnt print anything
@slate swan
;-;
yeah thats what im saying that would never get triggered inside the on_command_error, you would have to use try / except blocks
in every single one?
;-; i hate repetitive work
that would be better to use since KeyError can come from may other points too
?
nothing

Hi can someone help me please?
only when you mention your problem
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 91, in on_raw_reaction_remove
for role_id, msg_id, emoji in client.reaction_roles:
AttributeError: 'Bot' object has no attribute 'reaction_roles'```
async def on_raw_reaction_remove(payload):
for role_id, msg_id, emoji in client.reaction_roles:
if msg_id == payload.message_id and emoji == str(payload.emoji.name.encode("utf-8")):
guild = client.get_guild(payload.guild_id)
await guild.get_member(payload.user_id).remove_roles(guild.get_role(role_id))
return```
Bot does not have a reaction_roles attribute
until you're assigning an attribute yourself
But I made me my bot where the member would need to click on the reaction emoji to get a reaction role to see the rest of my server channels
So
what do you expect client.reaction_roles to be
it's not a real discord.py feature, nor is it a discord api feature
first you have to check if the message being reacted/unreacted to is a reaction roles message
then you could possibly extract the role out of that
Ok how would i do that?
is there a way to check when a channel is created?
on_channel_create event
ty
How would i do that?
huh
i made a script long time ago @jade tartan but dont give you a role just reply to you in dm
i can send it to you and you can edit it
Β―_(γ)_/Β―
is there a way to check if theres nothing on a list (ex. nothing on a db yet)
Ok
Like the list is empty?
yes
if not your_list
oh thank you sm
empty lists are falsy
@bot.command(aliases=['download', 'DOWNLOAD'])
@commands.has_permissions(administrator=True)
async def download(ctx, link=None, *, title=None, desc='React to download'):
if not link or not title:
embed=discord.Embed(title='How to use the command', color=discord.Color.red())
await ctx.channel.send(embed=embed)
return
else:
embed=discord.Embed(title=f'{title}', description=f'{desc}', color=discord.Colour.red())
message = await ctx.channel.send(embed=embed)
await message.add_reaction('β
')
def check(reaction, user):
if user.id != bot.user.id:
return user and str(reaction.emoji) == 'β
'
while True:
reaction, user = await bot.wait_for('reaction_add', check=check)
dow=discord.Embed(title=f'{title}', description=f'Here is your {title} download link\n[Download click here]({link})', color=discord.Colour.green())
dow.set_footer(text='γ»γ»')
await user.send(embed=dow)
channel=bot.get_channel(769990892894945332)
await channel.send(f'{user.name} downloaded send')```
there's a typo in line 6
wha
not really
ctx.channel.send and ctx.send are both equivalent
Lmao
wait, im on phone
"how tu use"
I think i use too much python lmfao
they mean how "to" use
xD
you meant line 5 lol
When i started to count the lines i started at 0 for some reason
I always start from 2 π
smh yeahhh
there's a typo on word 4 lol
yeah
funny, bro, i died laughing
Fuck i thought eito was just trying to catfish people with that avatar
Nah nvm I worked it out
would be fun to see
well he's ash atm
Just like kayya
lmao
Kek
I have a question would python let us add tags to our code? If that make sense
tags?
Tags?
comments?
Comments?
price tags?
Tags. Meaning to add or remove tags
Name tags?
As in roles
What kind of tags
nice explanation
Like tags the one that Carl bot has
Wdyn roles
Bro what
What are tags that carl bot uses
carl has wha-
π³
?roleadd @user @role like this?
int(message.content)
uh this will return bole right
Like wdym
That's mentions
Hang on Iβll show u a ss
the integer value of the message if it can
message.content.isdigit() returns a bool
ok thanks :D
discord.py's converter can convert tags too though
Wouldn't that error
What
I'm having a stroke
ye
Depends if it's a string
never used isdigit() thats why
what do you not understand? :/
message content is always a string
This is what I mean by tags
The unedited one
ah ok, i repeated a word twice, sorry
Oh yeah depends if it's a letter
you'd need a database for this
use the on_message event and check through your db?
And a dashboard
fb?
Facebook?
I dont have a dashboard yet
Am confused
unnecessary dependency
he is asking fb?
ig he seen db as fb
Yeah
But a good one if you can do it
Ig you read my mind
π
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
when you store your bot's data on facebook instead of a database :chad:
ot?
Not unless that's what people use your bot for
Lmao data gets randomly stolen
Or reported
a nice dashbaord would be uwu though, nice idea
lol
uh how do i exit a function? i forgot
the privacy policy of the applications is gonna be funny
So am creating a role tag id have to go through db?
dashboards are just meh until you have a bot with vast usage
return
π¦
giveaway
it keeps going offline without me doing it π
At least it responded to you tho
lmao
Any way ama go add other cmds to my own python bot see ya
π
hm, not really
guys how i can tell my bot to send the member joined server a private DM
on member join event
!d discord.on_member_join gives you a member, you can use member.send
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
!d
global
7.12. The global statement
global_stmt ::= "global" identifier ("," identifier)*
``` The [`global`](https://docs.python.org/3/reference/simple_stmts.html#global) statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without `global`, although free variables may refer to globals without being declared global.
Names listed in a [`global`](https://docs.python.org/3/reference/simple_stmts.html#global) statement must not be used in the same code block textually preceding that `global` statement.
Names listed in a [`global`](https://docs.python.org/3/reference/simple_stmts.html#global) statement must not be defined as formal parameters, or as targets in [`with`](https://docs.python.org/3/reference/compound_stmts.html#with) statements or [`except`](https://docs.python.org/3/reference/compound_stmts.html#except) clauses, or in a [`for`](https://docs.python.org/3/reference/compound_stmts.html#for) target list, [`class`](https://docs.python.org/3/reference/compound_stmts.html#class) definition, function definition, [`import`](https://docs.python.org/3/reference/simple_stmts.html#import) statement, or variable annotation.
and the last line, yes it needs member intents to work
Slash command not work
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
slash = SlashCommand(bot)
@slash.slash(name="test")
async def _test(ctx: SlashContext):
embed = discord.Embed(title="embed test")
await ctx.send(content="test", embeds=[embed])
use dpy 2
correct
@slate swan @boreal ravine should have passed mathematics at least :)
||thats all I could expect from two thirteen-year-olds||
lol
lmao
π brh?
im bad at maths u know :<
they teach you about decimals when you're 7 or 8 already
also discord 2.0 is a str
str?
ye if u do
str can be anything :D
...
what.....
π
@bot.command()
async def giftcode(ctx):
await ctx.channel.send("NhαΊ₯n vΓ o Δα» xem code: ",components = [Button(label="Xem gift code.")])
interaction = await bot.wait_for("button_click", check= lambda i: i.component.label.startswith("Click", timeout=15.0))
await interaction.respond("Gift code")```
Its throwing an error
Can anyone help
so I have this little mockup of a tag formatter. what I want to do is
a. identify when one of my tags is in the string
b. if one of my tags is in the string, identify which tag it is (used to determine what to do with the values stored in keep
c: find any times that :number: is found in the string, I'm using split for this atm but there's probs better ways
d. once i've found one of these :number: extract number from it and append number to my keep list
e. replace any tags in the string with the value from the tags dict
f. print the final string (or do something with it since this is for a discord bot
note: I'm going to iterate over every number in keep to try to resolve it to member, guild, role or channel, it might be better if keep is a dict so i can have separate keys for each type and just make the second list under each key however this will involve identifying which tag was used in the string
keep = []
tags = {
"{user_name}": "(name tag)",
"{user_id}": "1234",
}
text_b = "Hello World user_name:941314754851524639: It's almost my birthday user_id"
split_b = text_b.split(":")
b = ""
for string in split_b:
# Need to check if any of the items in the list are ints (these will be the ID's like 941314754851524639
if int(string) is True:
keep.append(int(string))
else: continue
b = b + " " + string
for tag, val in tags.items():
out_b = b.replace(tag, val)
print(f"split_b: {split_b}")
print(f"string_b: {b}")
print(f"out_b: {out_b}")
print(f"keep: {keep}")
!e
class foo:
def __str__(self):
pass
o = foo()
print(str(o))
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | TypeError: __str__ returned non-string (type NoneType)
@commands.command(name='resume', help="Resumes music")
@commands.has_permissions(manage_guild=True)
async def _resume(self, ctx: commands.Context):
"""Resumes a currently paused song."""
if not ctx.voice_state.is_playing or ctx.voice_state.voice.is_paused():
ctx.voice_state.voice.resume()
await ctx.message.add_reaction(':play_pause:')```
i want the command to function only when i react
The error message is "Command raised an exception: TypeError: startswith() takes no keyword arguments"
do common sense exists?
use `
3x
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
bruh
those red blood red lines
how do i make it happen
but nice try enter, you're good man
someone just post same thing and someone said we cant help with that
i don't want help with music stuff
how do i make the bot respond to a command only when someone reacts to it
nah i have completed music related coding
which lib ur using for music?
yotubedl
!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)
huh
why
ytdl is illegal
π
scary
gets frightened
i hope u know that your deleted messsages must be getting logged in some channel set-up by staff here
just telling :")
ofc i know
!src log
Unable to convert 'log' to valid command, tag, or Cog.
there is no rule that u cant delete msg π€·ββοΈ
so you're ready to show it to staff but not to us :'/ sad
would be fun when the message is never found in the internal cache of the bot, what a sweet coincidenc
i dont abuse so no problem
π i can only imagine
lmaoo i do that & sitll don't delete :")
i mean, only at relevant places :")
..
i mean target abuse
nvm
MODS ONLY FOR TESTING PURPOSE NO HARM TO ANYONE
!of @slate swan :")
Off-topic channels
There are three off-topic channels:
β’ #ot0-psvmβs-eternal-disapproval
β’ #ot1-perplexing-regexing
β’ #ot2-never-nesterβs-nightmare
The channel names change every night at midnight UTC and are often fun meta references to jokes or conversations that happened on the server.
See our off-topic etiquette page for more guidance on how the channels should be used.
LMAO
writing fuck isnt against the rules and ot
^ +1
(at least when not directed towards someone)
LMAO
how long will it take fr my bot to get banned lmao
can u see that u in the ss
bruh
what?
api auto catch if ur using that
and ban
π when did @unkempt canyon switch to dpy 2.0
it usually happens when youtube takes some action... just like that indicident that happened with groovy & rythm.. tho many bot still use it & nothing i shappening to them..
@velvet haven you wont get banned unless someone reports your application for doing so
^ +1
ill do
okay nobody cares
ah
you almost got me
I'll pretend to be scared to save you from further humiliation
dont worry im a good boy :D
bot/__main__.py line 62
case_insensitive=True,```
ye
yo
im using ytdl then
in my private bot :O
for music in dc
bruh
just pay less attention to Sparky's "evil and scary" messages for now
ye thank you
couple weeks ago
π
in an error handler cog, how can i get the name of the required argument when commands.MissingRequiredArgument is raised
Why won't this work π and just returns an empty list?
[record['key'] for record in all_records if 967356333336690688 in record['users']]
this is the data
[{'key': '967356333336690688', 'users': [925079016174682200]}]
stop shitposting
I'm not shitposting.....I really cant figure out why it aint working...
the id is a string
the id is not the same
what ryuga said
is gonna make me cry
i'd appreciate some help on my really stupid question
how do i access the missing param in missingrequiredargument from an errorhandler cog
!e
print(967356333336690688==967356333336690688)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
True
its same
pardon?
they're different
i mean key
nvmd
u know im bad at list compre i understand late
all good
https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.MissingRequiredArgument
the error has a .param attribute which gives you an inspect.Parameter object, and the python docs for those show that it has a .name attribute you can use to get the parameter's name
π€¨
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: list indices must be integers or slices, not str
they are iterating over the variable all_records, the record['users'] you saw was just part of their comprehension condition
!e
all_records = [{"key": 12345678, "users": [12345678, 12345678]}]
print([record['key'] for record in all_records])
wait
so like, error.param.name?
@slate swan :white_check_mark: Your eval job has completed with return code 0.
[12345678]
yeah....
yea that should be right
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['967356333336690688']
well, that doesn't work
when i do print(error.param.name), nothing gets printed
hm yeah, i know that works, but it doesnt really seem to work when I replace the id with author.id
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send("You're missing a required parameter.")
raise error
print(str(error.param.name)) #---> this doesn't print anything.
it is π
show code and data
well yeah, if you raise the error again, your function stops running past that point
yeah gonna burn some of my own brain
i didn't know raise error would end the function, tyvm
can anyone help me with this error
'discord.ext.commands.bot' has no attribute 'wait_for'
self,reaction, user = await bot.wait_for("reaction_add", timeout=60, check=check) on this line
the error comes
what shud i change?
bot = commands.Bot
I think its self.bot?
ah
Client.wait_for() missing 1 required positional argument: 'event'
now i get this error
!d discord.ext.commands.Bot.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
TypeError: Client.wait_for() missing 1 required positional argument: 'event'```
i think u need to remove self ? Idk
It should be reaction, user = ?
π€
it stilll deosnt work without it
im doing it in a cog
u could use await self.bot.wait_for

@slate swan @paper sluice thanks for the effort of trying to help, turns out my database is fucked up and is storing wrong values for no reason
AttributeError: 'Rules' object has no attribute 'bot'```
Why so many errors lol
ππ
sus-db
add this in py def __init__(self, bot): self.bot = bot
class Welcome(discord.ui.View):
def __init__(self, member):
self.member = member
super().__init__(timeout=300)
@discord.ui.button(label="Welcome", custom_id="welcome")
async def callback(self, interaction,button):
await interaction.response.send_message(f'**{interaction.user.name}** has welcomed **{self.member.name}**')
How can i make it such that people can click only once?
I feel like i lost some brain cellsππ
disable the button after first click
AttributeError: 'Rules' object has no attribute 'bot'```
button.disabled = True
no no not disable, it works for others but not for the user who clicked once
ah do an interaction check
what to do in the check lol
if interaction.user == author...
thats my question
just out of curiosity:
is it possible to run the same code on two bots by having multiple bot.run(token) in the code?
hello... is there any free hosting server that we can use to host our discord bot, so it can stay online 24/7??
Make a db? Or something else. if the author clicked on the button. Their id will append to the db list. And check if the author's id in the list
ehh?
yes, you can, You can run task loops or smth, idr
class Welcome(discord.ui.View):
def __init__(self, member):
self.member = member
super().__init__(timeout=300)
@discord.ui.button(label="Welcome", custom_id="welcome")
async def callback(self, interaction,button):
if interaction.user == self.member:
await interaction.response.send_message(f'**{interaction.user.name}** has welcomed **{self.member.name}**')
assuming that self.member is the member u want to be able to use the buttons
I think they want other ppl (guild members) to click on the buttons
class YesNoButton(ui.View):
def __init__(self, *, timeout: float = 180, intended_user: disnake.user.User = None):
super().__init__(timeout = timeout)
self.intended_user = intended_user
self.choice = None
@ui.button(label="yes", style=ButtonStyle.green)
async def _yes(self, button: Button, inter: MessageInteraction):
if self.intended_user:
if inter.author != self.intended_user:
return
self.choice = True
self.stop()
@ui.button(label="no", style=ButtonStyle.danger)
async def _no(self, button: Button, inter: MessageInteraction):
if self.intended_user:
if inter.author != self.intended_user:
return
self.choice = False
self.stop()
inside cog:
btn_confirm = YesNoButton()
if amount <= database[inter.author.id].money:
await inter.send(embed = em_confirm, view = btn_confirm)
await btn_confirm.wait()
if btn_confirm.choice:
# user clicked yes
else:
# user clicked no
why do that, you could instead pass the token as a command line argument to your app, and then spawn multiple consoles
im confusion
ye?
What does ephemeral mean in discord components
a private message
this
dont mind the command
and?
How do I change the button's color in discord_components
is this a command you made for tracking/stalking people with their messages? π
ah shit-
you need to use ButtonStyles
don't use that library though, use discord.py master or a fork
hm yeah, basically looks for the message for any change or if it is removed and dms the people whoever put it on track π
Can you like show me the syntax
!d discord.ButtonStyle
class discord.ButtonStyle```
Represents the style of the button component.
New in version 2.0.
why black color embed
Button(style=ButtonStyle.red)
#available colours - red/blue/green/grey
btw ur bot was ded?
grey :(
Thanks
imagine just codes
because its set to the colour of the top role of the author, and I dont have any role on my bot test server
no no, i mean smth like this
did I let it?
its a button with emoji?
ohh cool
?
I mean the check
that a user can click only once
i am confused how to do that
what a bot, that ask for welcome
wym?
It just throws this error: NameError: name 'ButtonStyle' is not defined
import
from discord import ButtonStyle
import it from the library
are u coding on replit?
no?
not u
Yep
ohh
I have a question, how do I kinda like make the bot send a message in a specific channel, next time when I turn off the bot and run again, I dont want it to resend that message again, are there any ways to check if the message's already exist
database
use a db for that purpose
for example:
when you send the message, change the value of "sent" to True. and the next time make your bot check the value of the record and it is set to True, then the message has already been sent, and if its False, you will have to make your bot send it
or you could iterate through the channel's history (find the specific message id) though i dont recommend it
Thanks
def timer(self):
while True:
with open("noob.json") as f:
logs2 = json.load(f)
for keys in logs2.keys():
a = logs2[keys]
if a[0] >= datetime.now():
print("end")
fine?
nextcord and discord?
2 is better than 1
what
π
@paper sluice
i want to mention the user with that role
show ur code
use member.mention
it isnt working
show code
**Members with** {role.mention}: {role.members}```
iterate through role.members
e.g. [mem.mention for mem in role.members] or 'No members have this role'
uh ye
for role in member.roles ?
use list compre
ohk
i just sent it
this
nvmd
@heavy folio is this fine
..
what the hell is that
a timer for giveaway cmd
Hey,
I just saw someone used custom emojis in a dropdown, but their bot is coded in JavaScript, I tried to use custom emojis in a dropdown menu also, but it raised the error unknown emoji.
- i wouldnt use json as a db
- tias
what did you try
I've tried to copy paste the emoji name & ID (like you normally use custom emojis with a bot) and defining it as a variable, both didn't work
tias?
try it and see
code
wait no
i got it
!d str.join
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
e.g. , .join(iterable)
@commands.command()
@commands.bot_has_permissions(embed_links=True)
async def test(self, ctx):
testemoji = ""
await ctx.reply("Test", components=[Select(
placeholder="Select something",
options=[
SelectOption(label="Test", value="1", emoji=testemoji),
SelectOption(label="Infos", value="2", emoji="")],
custom_id="m")])
Those are the both things i tried
This is the error:
https://i.imgur.com/Huey3id.png
Welp, normal emojis do work that's the thing
does the bot have access to the emoji?
Yeah, it has admin perms
access to the server where the emoji belongs
It's the same server where I invoked the command
hmm
Is there a fetch_emoji function for guilds? Maybe that would work
!d discord.Guild.fetch_emoji
await fetch_emoji(emoji_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") from the guild.
Note
This method is an API call. For general usage, consider iterating over [`emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.emojis "discord.Guild.emojis") instead.
Changed in version 2.0: `emoji_id` parameter is now positional-only.
why not get
i fucked something up in my code and @commands.is_owner() doesn't seem to work in cogs
There is no response inside to my command
So this is my bot definition
class Bot(commands.AutoShardedBot):
def __init__(self):
allowed_mentions = discord.AllowedMentions(everyone=False,
roles=False,
users=True)
super().__init__(command_prefix=_prefix_callable, # A function i wrote
description="I am a robot",
pm_help=None,
help_command=PaginatedHelpCommand(),
help_attrs=dict(hidden=True),
chunk_guilds_at_startup=False,
heartbeat_timeout=150.0,
strip_after_prefix=False,
allowed_mentions=allowed_mentions,
intents=discord.Intents.all(),
enable_debug_events=True,
case_insensitive=True,
owner_id = 583174748478111745)
For example this isn't working
@commands.has_permissions(manage_messages=True)
@commands.command(hidden=True)
@commands.is_owner()
async def purge(self,ctx,limit:int):
await ctx.message.delete()
await ctx.channel.purge(limit=limit)
give msg reactions docs pls
Hm
!d disnake.Message.reactions
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
lmao
i just type for test and it worked
Works, I will use that, ty
I feel an urge to print the bot's cache once
nice
not carl's.....?
thousands of guilds and hundred thousands of member objects
iirc carl has a higher number of users than Mee6
plus Mee6 isnt anything compared to carl
hm
I had more commands than carl
My bot's cooler than Carl cuz it's mine
imagine
any unique feature?
Radio Silence


