#discord-bots
1 messages · Page 758 of 1
;-;

\u27a1 : BLACK RIGHTWARDS ARROW - ➡
\ufe0f : VARIATION SELECTOR-16 - ️
\u27a1\ufe0f
channel = await bot.fetch_channel(payload.channel_id) message = await channel.fetch_message(payload.message_id) reaction = discord.utils.get(message.reactions, emoji=payload.emoji.name) await reaction.remove(payload.member)
It works thanks again xD
the If Role == Unlock part, is just incase someone manually locked the channel before 1 min. Will that work?
@placid skiffinstead of miles of if-statements u can do it other ways.
import random
#self.embed_colour = ["blue", "blurple", "brand_green", "brand_red", "dark_blue", "dark_gold", "dark_grey",
# "dark_magenta", "dark_orange", "dark_purple", "dark_red", "dark_teal", "dark_theme",
# "darker_grey", "fuchsia", "gold", "green", "greyple", "light_grey",
# "lighter_grey", "magenta", "og_blurple",
# "orange", "purple", "red", "yellow", "teal"]
#
#async def choice_color(self):
# color = choice(self.embed_colour)
# if color == "blue":
# return Colour.blue()
# elif color == "blurple":
# return Colour.blurple()
# elif color == "brand_green":
# return Colour.brand_green()
# elif color == "dark_blue":
# return Colour.dark_blue()
# elif color == "dark_gold":
# return Colour.dark_gold()
# elif color == "dark_grey":
# return Colour.dark_grey()
# elif color == "dark_magenta":
# ...
embed_colour = {"brand_green": "0x57F287", "green": "0x2ecc71"}
def choice_color():
color = random.choice(list(embed_colour.values()))
return color
print(choice_color())
``` example or
```py
embed_colour = {"blurple": Colour.blurple(), "green": Colour.green()}
is it possible to get args in this way
?command <integer > <mention> <mention>....
Add multiple arguments
or you could use commands.Greedy or use the * symbol in the command, both do the same thing iirc
how to get the id of the mentions like this ?
for i in args[1:]:
i.mentions.id
please use ext.commands module 🙏
whats args[1:]?
all the arguments ..first one is interger rest all must be mentions
whats the type of args[1:]
async def whitelist(ctx,*,args):
for i in args[1:]:
print(i.mentions.id)
like this
What's wrong with my COGs?
@cobalt jacinth```py
def test2(*args):
print(args)
for i in args[1:]:
print(i)
test2(5, "hello", "world")
output:
`(5, 'hello', 'world')
hello
world
`
def test2(number, *args):
print(args)
for i in args:
print(i)
@cobalt jacinthhere pretty much ```py
@bot.command()
async def ping(ctx, number: int, *args: discord.Member):
for i in args:
print(i.id)
ahhh thanku
@cobalt jacinth```py
@bot.command()
async def ping2(ctx, number: int, users: commands.Greedy[discord.Member]):
for i in users:
print(i.id)
both does same
the warn command doesnt work, and nothing shows up in the console.
https://pastebin.com/CPF2g9Gs
i have all gateway intents enabled but i still get an error Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead
Okay so
Read the error
Hmm
the warn command doesnt work, and nothing shows up in the console.
https://pastebin.com/CPF2g9Gs
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.
Put it in here. Pastebin formatting is fucked on mobile
do you even know what your code does right now
and show me your file directory
👍
BTW, I wont be doing it now but is it possible to do this
Create an event or listener command where when someone does RPG miniboss @player1, @player2, @player3, we give just the mentioned players a role?

"listener command"?
ye
ok how do i make it so that 1 = '=' and 2 = '==' and 3 = '===' etc.
bc im doing this game with like for loops and blah blah
In what situation?
listen in normal file and listener in cogs
Hmm
I need to know which situation you're using it in
you dont use listeners for commands
theres literally an extension in discord.py for that
Yes, i meant like an on_message or on_ready
i didn't know how to say it
Alr, a piece of code either listen or event with on_message, where I can add a role to the pinged users
Is that better?
@bot.command()
async def pp(ctx, word=None):
if word == None:
await ctx.send(f'{ctx.message.author.mention}, You need to mention someone')
else:
rint = random.randint(1, 20)
await ctx.send(f'8{rint}D')
ok i want the numbers to equal '='
so like 1 = '=', 2 = '=='
This is why I needed a use-case
etc
Use string multiplication
@boreal ravine or @final iron
!e
import random
print(f"8{random.randint(1, 9) * '='}D")
Imma go to bed. GN
Writing shit on mobile is so hard
What I wrote was wrong
ok what if i did that
!e
import random
print(f"8{random.randint(1, 9) * '='}D")
@final iron :white_check_mark: Your eval job has completed with return code 0.
8=====D
There
thanks
how to make a unban script and if they entered a wrong username and tag it will say that its wrong?
!d discord.Member.unban
await unban(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
You can use this to unban a user
@commands.has_permissions(ban_members=True)
@client.slash_command(description="Unbans a user")
async def unban(ctx, id: int = None):
if id is None:
embed=disnake.Embed(color=0xb30000, title="User not found", description="Please enter the ID of the user you want to unban.")
await ctx.send(embed=embed)
else:
user = await client.fetch_user(id)
await ctx.guild.unban(user)
embed=disnake.Embed(color=0x00d60e, title=f"Successfully unbanned {user}", description=f"{user.name} has been successfully unbanned by {ctx.author.mention}")
I do this script and it says please enter a valid integer when i try to do it
Just typehint to discord.Member
wdym
member: discord.Member
next?
hello world
a member object is a user in the guild.
If you try to unban a discord.Member, it will only raise MemberNotFound
Oh yeah I forgor
how do i fix it
@commands.has_permissions(ban_members=True)
@client.slash_command(description="Unbans a user")
async def unban(ctx, id: int = None):
if id is None:
embed=disnake.Embed(color=0xb30000, title="User not found", description="Please enter the ID of the user you want to unban.")
await ctx.send(embed=embed)
else:
user = await client.fetch_user(id)
await ctx.guild.unban(user)
embed=disnake.Embed(color=0x00d60e, title=f"Successfully unbanned {user}", description=f"{user.name} has been successfully unbanned by {ctx.author.mention}")
bro forgor 💀
says this
instead of an id (int), i would do a user (disnake.Member)
he forgor 💀
unban a member?
that also won't work, binds
oh didnt see that
well for unban, you can use member name and discriminator but you won't want to remember every banned users name LMAO
Do this
async def unban(ctx, user : int):
user_to_unban = discord.Object(user)
await ctx.guild.unban(user_to_unban)
Do this but , int(user) inside discord.Object
if they enter a wrong user how to message that it is wrongZ?
handler the exception
you could do a try except block with the MemberNotFound exception?
?
@slate swan also you can DM a discord.Object right? using send
can i use else
Does it really raise that error?
you can make a bannedmember converter, and say if user is not BannedMember
idk was just putting that out there
I know, i use random cuz I haven't choose embeds color yet
Would discord.User work for the type of user?
yes
Probably not
I see
nah
Only for IDs
try:
entry = await ctx.guild.get_ban(user)
except discord.NotFound:
await user.send('You are not in the ban list')
return
await ctx.send(f'{user.name} is in the ban list')
You could do something like this i think
my unban uses member name and discriminator to unban, but then my ban is timed so it will automatically unban the user after the time
it is useless, a banned member could never use that xD
the first thing i saw was having to make an entire class
!d disnake.Activity.buttons
An list of dictionaries representing custom buttons shown in a rich presence. Each dictionary contains the following keys:
• label: A string representing the text shown on the button.
• url: A string representing the URL opened upon clicking the button.
New in version 2.0.
which i didn't want to do, given it seemed specific to one color
Best thing to do is build the custom class
It's simple if you look closer at the examples on disnake repo
yo
hm.... interesting
I have my custom class for creating the views with buttons quickly tho
._.
oh?
wait- how are buttons actually useful lol-
idk if disnake has this, but it would look something like this on nextcord
class Dropdown(nextcord.ui.Select):
def __init__(self, options: list[nextcord.SelectOption]):
super().__init__(placeholder="Choose", min_values=1, max_values=1, options=options)
async def callback(self, interaction: Interaction):
...
They are way better than reactions imo
ok rip
like that at least
pagination
oh my fault
In disnake it is a bit easier, for example this a view with confirm button
class ConfirmView(disnake.ui.View):
def __init__(self):
super().__init__()
self.result = None
@disnake.ui.button(label='Confirm', style=disnake.ButtonStyle.green)
async def confirm_button(self, *_): #dont mind I just ignore these args usually
self.result = True
self.stop()
Then you can do this where you need the view
view = ConfirmView()
await ctx.send(..., view=view)
await view.wait()
#and then we can get the result
print(view.result)```
You could simplify this by a lot tho
mhmm
@severe rampart maybe this will help as well
Someone who has a meme command that they want to share?
how can i make smth work in only one server? (a guild)
I read it should be smth like @commands.guild_only() But this doesnt work for me?
guild_only makes the command only available in guilds and not in dms
oh
how could i make it so that it only changes the prefix in the guild the command is sent?
@Bot.command()
async def changeprefix(ctx, *, newprefix):
Bot.command_prefix = str(newprefix)
await ctx.send('changed the prefix to ' + '"' + newprefix + '"')
context.guild
where do i need to put that?
probably want to use a database for this
whats the view and embed
view = View()
view.add_item(button1)
view.add_item(button2)
view.add_item(button3)
view.add_item(button4)
view.add_item(button5)
await ctx.send(embed=em, view=view)```
the problem is the view
embed is fine
yesterday it worked
and now i get this
what lib u using
i tried to host my bot in visual studio code and i have from flask import Flask and it says ModuleNotFoundError: No module named 'flask'
what discord api lib
what should i do?
discord.py, nextcord, disnake?
@tasks.loop(seconds = 10)
async def giveawaytask(self):
for key in self.giveawaychan.keys():
guild = self.bot.get_guild(int(key))
print(guild.id)
self.giveawaychan.pop(guild.id)```
its prints the guild.id still says Keyerror for last line
diod you install flask
idk where to check my lib..
if i import it it says unused import
sorry
well, the error speaks for itself
also, don't edit a list while you're looping through it
Scroll to the top of your file and send a picture
that just means you haven't usedit in the code yet
Let's see your imports
^
a lot
No
ok
bruh
i cant seem to figure out the error. if it can print the key why is it giving the key error. my json looks like this
oh discord
yes
you're passing an int and your keys are strings
solved
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def main():
return "Rocket Beta#3167 is alive"
def run():
app.run(host="0.0.0.0", port=8080)
def keep_alive():
server = Thread(target=run)
server.start()```
the weird thing is that view worked perfect all the days before and rn i start it and it doesnt work, as if theres been an update or sum
if __name__ == '__main__':
run()
thank you
i add this?
thats how you usually start a flask app
only if you know what it does
ok ,no
it makes sure you don't accidentally run a script
pls help
How are we supposed to help with no information
@bot.event
async def on_member_update(before = discord.Member , after = discord.Member):
guild = after.guild
role = guild.get_role(932629790878482522)
activity_string = after.before.activity.name
string_to_check = ". gg / void"
if string_to_check in activity_string:
await before.add_roles(role)
print("works")
Typehints use : not =
lol
kk
So ... on_member_update(before: discord.Member, after: discord.Member):
still doesn’t work
@bot.event
async def on_member_update(before : discord.Member , after : discord ):
guild = after.guild
role = guild.get_role(932629790878482522)
activity_string = after.before.activity.name
string_to_check = ". gg / void"
if string_to_check in activity_string:
await before.add_roles(role)
print("works")
No documentation found for the requested symbol.
!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").
yo can someone help me
for some reason i can’t invite my discord bot
in the url generator
i have also tried discord perms calculator
hellooo. I have this code ```python
name = str(config['servername'])
em = nextcord.Embed(title=':green_circle: Server Is Online!', description="", color=orange)
em.set_author(name=name)
em.add_field(name = 'Online Playes:', value= str(events['clients'])+"/"+str(events['sv_maxclients']), inline = True)
em.add_field(name = 'Server Ip:', value= f"{ip}:{port}", inline = True)
await ctx.send(embed=em)
It works just fine, but i want to make it that every 1 min it updates the message to refresh the online members. Do you have any ideas how?
!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").
i did
where should i put this in my code?
Click on the link, there are a few examples
the warn command doesnt work, and nothing shows up in the console. https://paste.pythondiscord.com/sesafowuxe.py
!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.
Use this
It's fine
sorry.
Don't worry about it
In line number 23, u r returning the whole dict
Its not a large issue
class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.
When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.
For example, in the following code:
```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
``` An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
warns[str(member.id)]```?
Interesting
Yes. U r returning the whole dict instead of just that in the next line...
oh
seeing this message, I feel like I know about each and every section of the dpy docs lol
You know too much
Literally never heard about that converter
I know too much, still I don't know anything
do i remove it?
return it instead
wdym?
return warns[str(member.id)]
instead of return warns
since u wanna check for a single person, and not get each and every warn
@fervent shard You might want to invest some time in to learning a proper database
or just use discdb indeed
🤨
like this instead?
def save_warn(ctx, member: discord.Member):
with open('warns.json', 'r') as f:
warns = json.load(f)
warns[str(member.id)] += 1
with open('warns.json', 'w') as f:
json.dump(warns, f)
def remove_warn(ctx, member: discord.Member, amount: int):
with open('warns.json', 'r') as f:
warns = json.load(f)
warns[str(member.id)] -= amount
with open('warns.json', 'w') as f:
json.dump(warns, f)
def warns_check(member: discord.Member):
with open('warns.json', 'r') as f:
warns = json.load(f)
warns[str(member.id)]
return warns[str(member.id)]```
I prefer u learn MongoDB
discdb?
remove the 2nd last line
check my github
Its on my profile
And examples
I don't really update it much, since 99% of people just be like: Your idea is shit and stuff, soooo
I wouldn't say its shit but its unnecessary
No offense but using normal databases isn't much of a hassle
It was just a challenge given to me, a long ago when I was new to this server
It might be unnecessary but why quit the project?
It's something nice to show off
And who knows, maybe people will use it some day
hm, i ran the command but it doesnt send the embeds or do anything
it was like: I challenge u to make it a proper module in 30 min
And I did it in 15-20 minutes or smth haha
Still cool that you made a package
Well I still reply to any issues/PRs made haha
Thanks 🫂
no errors in the console either
Hmm mind pasting yr command code?
Time to make an issue to add more examples
*Damn something is really wrong about my WiFi
I actually think you desperately need more examples though
@bot.command()
@commands.has_permissions(manage_roles=True)
async def warn(ctx, member: discord.Member, *, reason=None):
save_warn(ctx, member)
if member == ctx.author:
em2 = discord.Embed(description=f"**you** cannot `mute` yourself", colour=discord.Color.red())
await ctx.send(embed=em2)
else:
em=discord.Embed(description=f"{member.mention} has been `warned` for {reason}", colour=discord.Colour.green())
em1=discord.Embed(description=f"{member.mention}, you have been `warned` for {reason}", colour=discord.Colour.green())
await member.send(embed=em1)
await ctx.send(embed=em)```
how do you get timestamps in the footer of an embed that adjust them to the time? Like if an embed is sent today, it will say today at [time] but it if it is sent yesterday it will say yesterday at [time].
Is this normal behavior of datetime.datetime,utcnow()?
I don't really understand it
My answer: Make a PR yourself :DDD
I should have given a small usage example in the readme
Yeah
Its a discord thing
so datetime.datetime.utcnow() does that?
I guess??? You can use any timezone BTW
you just pass in any timestamp inside that , discord updates it according to itself
anything wrong?
yea, just like unix timestamps
Ah sorry, forgot about it... Lemme see
dw, take ur time!
Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
how do i send the perms the bot is missing when this error occurs?
already told ya , u need to use @bot_has_permissions checks
or you wont be able to handle that error
!d discord.ext.commands.MissingPermissions.missing_permissions
The required permissions that are missing.
and how u invoking the cmd?
like using it?
on whom?
Yea
i do "{prefix}warn {member} {reason}"
can this be used in an error handler or do i have to use it for each command?
So like !warn @maiden fable You are weird
error handler will work
yes
on_command_error
example:
?warn @fervent shard bc i want to
@waxen granite read this
try adding debug prints
prints?
Print random things on every other line, to see which lines are getting called
so for each cmd then?
so like print ('hiiiiii')
most common thing people print are numbers
every other line
if isinstance(error, commands.BotMissingPermissions):
return await ctx.send(f"I do not have permission to do that.\nThis may be due to either I am missing perms to do it or the member's perms are higher than mine.")
i have done this in on_command_error before but this doesnt work
yea , the check is a must for each command ,
you can have a global error handler which checks if error is an instance or commands.BotMissingPermissions example : py @bot.command() @bot_has_permissions(send_messages=True , embed_links=True) async def cmd(... and in the error handler ```py
@bot.event
async def on_command_error(ctx , error):
if isinstance(error , commands.BotMissingPermissions):
its commands.MissingPermissions
the error is different
hierachy related errors can be handled only using try except imo
missingperms is for commandInvoker not having perms, and BotMissingperms is for bot missing perms, i want help regarding the latter.
you can also do specific command specific error stuff
@command()
async def kick():
...
@kick.error
async def kick_error(ctx, exc):
...
cause no checks check the other user's hierachy
okay
no
@fervent shard found the problem?
nope
Show yr latest code with the print statements
so, bot constructor in sublass or no. what is best?
thats not true. Discord will only give you a 403 if the bot itself is lower than the person you're trying to kick. If you try to kick someone thats above you but is below the bot; there will be no exception thrown. It will go through with the kick.
it was about raising the error when bot does not have perms to do something because of hierachy
bot_has_permission()
i prefer subclassing it
I thought you were talking about general hierarchy.
why does view=view not work anymore?
Because you haven't defined the view variable 🤷
Well I can tell for a fact that it still works and exists.
You are running discord.py 1.7.3 and not 2.0, make sure you install that version.
does anyone know how to upload your bot to google cloud?
uh hey... so i'm making a discord bot,
@ethan.command()
@commands.has_role("newcomers")
async def login(et, arg, user: discord.Member):
^ (the line of code that's causing the issue)
and I need the discord.Member part to see what roles the discord user has...
But it returns this error:
Missing arguments: user is a required argument that is missing.
have I done something wrong?
user: dicord.Member = None? idk
no, that wouldn't work
basically ur not specifying the user
discord.Member IS specifying the user
its specifying the author of the command
I think
cant u just arg.author?
send the whole code
okay
below that
@ethan.command()
@commands.has_role("newcomers")
async def login(et, arg, user: discord.Member):
if arg == "76455":
code = "76455"
# CODE ROLE IS REMOVED BECAUSE THERE IS PROFANITIES.
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.server.roles)
if role in user.roles:
await ethan.say("{} already has this role.".format(user))
else:
# await ethan.add_roles(user, role)
# await ethan.remove_roles(user, "newcomer")
await et.send("test")
if arg == "80427":
code = "80427"
# CODE ROLE IS REMOVED BECAUSE THERE IS PROFANITIES.
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.server.roles)
if role in user.roles:
await ethan.say("{} already has this role.".format(user))
else:
await ethan.add_roles(user, role)
await ethan.remove_roles(user, "newcomer")
if arg == "56354":
code = "56354"
# CODE ROLE IS REMOVED BECAUSE THERE IS PROFANITIES.
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.server.roles)
if role in user.roles:
await ethan.say("{} already has this role.".format(user))
else:
await ethan.add_roles(user, role)
await ethan.remove_roles(user, "newcomer")
if arg == "97036":
code = "97036"
# CODE ROLE IS REMOVED BECAUSE THERE IS PROFANITIES.
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.server.roles)
if role in user.roles:
await ethan.say("{} already has this role.".format(user))
else:
await ethan.add_roles(user, role)
await ethan.remove_roles(user, "newcomer")
the arg and code things are just examples for rn
what is et and what is arg?
et substitutes for ctx
Ever heard of f-strings?
yes-
Then use them
@ethan.command()
@commands.has_role("newcomers")
async def login(et,arg, member: discord.Member):
maybe try this
are you trying to get the user that sent the message?

and f strings are ugly imo
U need to provide it a member
i think ctx.author does the trick, although idk ive just been fixing bugs the whole week
excuse me
i still dont get why view=view doesnt work anymore ):
im using python 3.10.1
does anyone know?
and i imported a lot of things
no srry
dpy, not py
just update discord.py with pip
first go in your terminal
and run pip list
look for discord.py
and next to it is ur version
if its not version 2 and it says 1.7.3
then run
iirc it's pip --upgrade
pip --upgrade discord.py
yes
Your command uses outdated stuff @analog barn
should i do that ot?
There should be some page in docs which lists the updated stuff, will help in migration
so i dont do pip --upgrade discord.py?
do it anyway
pip install --upgrade discord.py
what is outdated in the code? maybe I may know the updated version but just can't see what's outdated rn
server is called guild now
got it
it's Member.remove_roles now
okay
await ethan.add_roles(member, role)
await ethan.remove_roles(member, "newcomer")
these are fine right
@grim oar thiswas after urs
It's updated already
but then why doesnt view=view work
):
view = View()
view.add_item(button1)
view.add_item(button2)
view.add_item(button3)
view.add_item(button4)
view.add_item(button5)
await ctx.send(embed=em, view=view)```
maybe because the one on pypi doesn't have a view impl, idk, install from github in that case
it worked yeserday and i didnt change anything
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
what?
As I already said before.
^
doesnt this say 2.0
Go on https://github.com/Rapptz/discord.py and go to the installation section. Then do what is said to get the version 2.0
what is the updated version of this?
await ethan.add_roles(member, role)
await ethan.remove_roles(member, "newcomer")
To install the development version, do the following:
...
Following that will lead to the version 2.0 being installed.
Yes, you have to.
what do i need to use instead? is it -
nrvm
it still doesnt work
@slate swan
Remove the $
.
i did
And do you have vit installed?
member.remove_roles(role )
okay
im still getting the Missing arguments: member is a required argument that is missing.
discord.commands is not a thing
when i get rid of it it fixes that but the original problem is still there
Hmm?
Hello.
I am trying to make an event where an embed updates when someone reacts to the message and adds their username to the list. Effectively if i react with a tick - it will add my name to "Attending" and if i react with a cross it adds it to "Not attending" - ive been trying a while and i just don't know how to make this work. I'm not sure how to edit an embed either.
!d get_message
!d discord.on_raw_reaction_add
No documentation found for the requested symbol.
discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
^
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
heyy. i have this but it doenst send the message after 2 sec```python
@tasks.loop(seconds=5.0)
async def print(ctx):
await ctx.send("lol")
await asyncio.sleep(2)
@j1mk0l.command()
async def info(ctx):
j1mk0l.loop.create_task(print(ctx))
Because you have it set to send it every 5 seconds

i have to send the command every time after 5 sec?
No
Then put in seconds=2 and remove the sleep
still. it sends it one time and then no more
I'm not sure if you can start a task like that inside a command
Try starting it in the __init__ if you're in a cog or anywhere if you're in your main file
Is there a Spotify api or smth, cause I want to make a cmd where you could look at different playlists and see what songs are in them
@j1mk0l.command(pass_context=True)
async def update_member_count(ctx):
await ctx.send(ctx.guild.member_count)
channel = nextcord.utils.get(ctx.guild.channels, id=933001079648555008)
await channel.edit(name = f'Member Count: {ctx.guild.member_count}')
@tasks.loop(minutes=1)
async def update_member_count2(ctx):
await update_member_count(ctx)
there should be iirc
doent update
I literally died
Is there a way to know what perms the bot will need for executing a cmd?
Why don't you just make the update_member_count into a task
like this?? j1mk0l.loop.create_task(update_member_count(ctx))
I've managed to get my issue solved from earlier, but presents a new error.
@ethan.command()
@commands.has_role("newcomers")
async def login(et,arg,user: discord.Member=None):
if arg == "76455":
# REDACTED FOR PROFANITY
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.guild.roles)
if role in user.roles:
await et.send(f"You already have role: `{CODE_ROLE}`, and thus it has not been presented to you.")
else:
await user.add_roles(role)
await user.remove_roles("newcomer")
if arg == "80427":
# REDACTED FOR PROFANITY
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.guild.roles)
if role in user.roles:
await et.send(f"You already have role: `{CODE_ROLE}`, and thus it has not been presented to you.")
else:
await user.add_roles(role)
await user.remove_roles("newcomer")
if arg == "56354":
# REDACTED FOR PROFANITY
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.guild.roles)
if role in user.roles:
await et.send(f"You already have role: `{CODE_ROLE}`, and thus it has not been presented to you.")
else:
await user.add_roles(role)
await user.remove_roles("newcomer")
if arg == "97036":
# REDACTED FOR PROFANITY
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.guild.roles)
if role in user.roles:
await et.send(f"You already have role: `{CODE_ROLE}`, and thus it has not been presented to you.")
else:
await user.add_roles(role)
await user.remove_roles("newcomer")
redacted for profanity includes: code_role, which is the role name, and code, which is, well, the code.
arg is an example until i can get this fixed.
No I mean
@tasks.loop(minutes=1)
async def update_member_count(ctx):
#stuff
Is anyone able to help? or maybe someone has seen what is causing the error in my code?
Whatever u are trying to give the role to is a NoneType
What is et?
et is supposed to substitute for ctx
Why don't u just use ctx?
because i always use et
Good evening
Good evening
Could u send the redacted stuff?
But like what if the problem is in that
i was told to set it to that
I thought so too
but i was told to put that
because i need the discord.User object to get the users roles
thats the default value seems like you didnt add it
you should call the command with the member
!e
a = None
print(a.split(" "))
@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 | AttributeError: 'NoneType' object has no attribute 'split'
see it raises a nonetype error^
the code is supposed to listen for a specific message thats put in the args after .login
so i can't just call the command with me mentioning the member
because .login (arg) @member is ugly
What do you want the cmd to look like?
and what are you trying to do?
and .login (arg) is what im going for
i have this error:
TypeError: list indices must be integers or slices, not str
i am using embed.to_dict() to turn my embed into a dictionary, so that I can reuse the details to create a new embed. Although it appears that with the fields i have, it has created a dictionary inside of a dictionary. When trying to treat it as such, i get the error.
The line:
name = content['fields']['name']
The dict:
{'fields': [{'name': 'Attending', 'value': 'Nobody Attending', 'inline': True}], 'type': 'rich', 'description': "Start Time: 7:00 \n\n End Time: 14:00.", 'title': 'test:'}
Well how is it supposed to know what user to add it to
that's what im trying to figure out
you can index the list with a string it must be an integer
I want it to get the message author's roles
so it can check if a specific role is there or not, then if it isn't it would add the role
then use the author attr
@slate swan so i need to use an int?
to index the list yes
message.author.role ?
since ctx is et in this case
again- i know-
then why ask?


you have no message 
Lol
commands have context
trolling
Ctx and message are similar but not same
ctx: commands.Context
yeah
if role in et.author.roles:
await et.send(f"You already have role: `{CODE_ROLE}`, and thus it has not been presented to you.")
else:
await user.add_roles(role)
await user.remove_roles("newcomer")
so here's the thing


et.author.add_roles would not
it's not showing up as a valid function
author returns a member
Don't share screenshot lol
you cant compare a str to a int
Is user supposed to be an optional argument
@ethan.command()
@commands.has_role("newcomers")
async def login(et,arg):
if arg == "76455":
# redacted cuz nsfw
role = discord.utils.find(lambda r: r.name == f'{CODE_ROLE}', et.message.guild.roles)
if role in et.author.roles:
await et.send(f"You already have role: `{CODE_ROLE}`, and thus it has not been presented to you.")
else:
await et.author.add_roles(role)
await et.author.remove_roles("newcomer")
from discord.ext import commands
from prsaw import RandomStuff
bot = commands.Bot(command_prefix=">")
rs = RandomStuff(async_mode = True)
@bot.event
async def on_message(message):
if message.channel.id == 933060166121832478:
if bot.user == message.auther:
return
await bot.process_commands(message)
response = await rs.get_ai_response(message.content)
await message.reply(response)
TOKEN = "******************************************"
bot.run(TOKEN)
can anyone tell me what im doing wrong?
!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.
!e
if "a" == 1:
print("works")
else:
print("doesnt work")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
doesnt work
oH

today is not my day
You should learn python properly first 
from prsaw import RandomStuff
bot = commands.Bot(command_prefix=">")
rs = RandomStuff(async_mode = True)
@bot.event
async def on_message(message):
if message.channel.id == 933060166121832478:
if bot.user == message.auther:
return
await bot.process_commands(message)
response = await rs.get_ai_response(message.content)
await message.reply(response)
TOKEN = ""
bot.run(TOKEN)```
can anyone help me? with launching this and getting it to work
well hold on
please dont say that here
command_prefix = when_mentioned_or()

Where does he compare it to? arg is not typehinted
it is triggering when i send everyone
can anyone help me with launching my bot?
idk what hes trying to do honestly
Error?
i did
It's the same thing
I would typehint and compare it to a number anyway
well i can send log
Send the traceback
message.author*
this doesn't remove roles.
can your bot remove a role?
You parse Role object, not a string
That's your error @rugged laurel
so it has to be an object not a string
A role object precisely
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
it has all permissions it can get
Hey @rugged laurel!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
good
helloo. I have this command and i want to loop it that it edit the message everyo 20 sec. How can i do that? ```python
@j1mk0l.command()
async def edit(ctx, msg_id: int = None, channel: nextcord.TextChannel = None):
if not msg_id:
channel = j1mk0l.get_channel(932989135004786688)
msg_id = 933043619399610438
elif not channel:
channel = ctx.channel
name = str(config['servername'])
em = nextcord.Embed(title=':green_circle: Server Is Online!', description="", color=orange)
em.set_author(name=name)
em.add_field(name = 'Online Playes:', value= str(events['clients'])+"/"+str(events['sv_maxclients']), inline = True)
em.add_field(name = 'Server Ip:', value= f"{ip}:{port}", inline = True)
msg = await channel.fetch_message(msg_id)
await msg.edit(embed=em)
await asyncio.sleep(20)
get the msg id
Simple for loop?
Also you don't need elif there
Was wondering if I should consider ddos protection for a bot?
No not really
so waht should i do??
Yeah ddos protection is more like for sites
Also i guess u should not use another elif cond. U should use "and", so like that
if message.channel.id == int("id") and bot.user == message.author:
return
depends
if i know wrong, warn me
I mean the for loop is the basics of python.. do you know it well
I haven't seen/heard anyone attempting to ddos a discord bot, that's most probably them just trying to ddos the server instead
they dont ddos the bot but the server or vps its in
my project really has me stumped. Im trying to have an environment where there is an embed that the bot sends out. Users can react to that embed and it adds them to an "attending" list. However each time the on_reaction_add event occurs, the dictionary does not update.
Snippet of the code: https://pastehub.net/e7070ecfba5
That's what I said
just dont send to anyone your bots ip. that should be enough
Yea I meant for the vps mb
ok i will try that
Like I am considering to buy gg vps
well thats kinda on you if that sussy vps doesnt have ddos protection
Then definitely consider opting for DDoS protection for your server
If it's not a big project you can just setup a firewall lol
Ah f don't have enough money for it ;-; .. do you guys pay extra for ddos protection?
some vps do have a ddos protection plan which you do have to pay for
(infact a service provider should have DDoS protection for their hosting as a must)
!d discord.ext.commands.task
No documentation found for the requested symbol.
It's in tasks subpckg
@spring vergei can recommend vultr or digitalocean, i used digitalocean before but am more with vultr atm, 5$ for a month, enough for one or few bots

im still getting the same erro
Yeah, there are different plans but it depends on the host.
error*
and has ddos protection
Galaxygate is even cheaper with 1 gbps down
my project really has me stumped. Im trying to have an environment where there is an embed that the bot sends out. Users can react to that embed and it adds them to an "attending" list. However each time the on_reaction_add event occurs, the dictionary does not update.
Snippet of the code: https://pastehub.net/e7070ecfba5
ggs plans are good aswell
its always some problem importing libraries
@rugged laurelwhats the errors?
restart your ide
.
you simply cannot import such a thing
i tried using ide to run but that doesnt run the file that just opens terminal
^
!e
from typing import NoReturn```
@vale wing :warning: Your eval job has completed with return code 0.
[No output]
Works
@vale wing so it costed u 6 dollars with ddos protection included?
No I didn't include ddos
😳
galaxygate 💪

Ohk
🙂
ImportError: cannot import name 'NoReturn'```
@cerulean scaffoldcause the attending is cleared each time a new reaction is added, u need to move that list to like global or inside a class and use self.attended = [] self.attended.append(user) kinda
still got the error
i prob will never get ddos prot cuz of the amount of requests im sending to it xD
No idea what is wrong with it
@rugged laurel What are you trying to do?
!e
print('NoReturn' == 'NoReturn')
@vale wing :white_check_mark: Your eval job has completed with return code 0.
True
make a discord ai chatbot
Wait is ddos protection included in 5$?
atleast for now
and whats the no return thing for?
i love how you say ai
lol
@honest vessel im only really just getting into learning python as its something we've picked up at my school, so i've not done classes, only basic procedures/functions. You are saying to add those who have reacted to attending to a list, and then make that list be what is displayed?
i say what im trying to do, not what im succesfull at doing currently
I remember how I created e girl AI chatbot (that was very weird)
👏 Learn 👏 classes 👏
Can i make a command for see how many messages from an user in that server?
ai again
i have
ai doesnt make it fancy
tried hundreds of different classes
not you, the xina guy
rolley why do you need the typing library anyways?
Can i make a command for this?
morning yall
ah ok, what i mean is to have a global variable outside the function, so it can be accessed n modified throu a function
I'd prefer not to confuse myself with classes when im still in a relatively early stage of learning.
Sexyness
Ill try this. Thank you
but like
classes are pretty easy to understand
Well afaik discord API doesn't support searching for messages and getting their amount
its like i cant run any python file
when you can learn classes and async
!global
When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.
Instead of writing
def update_score():
global score, roll
score = score + roll
update_score()
do this instead
def update_score(score, roll):
return score + roll
score = update_score(score, roll)
For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.
classes are very nice
i also tried to download a python chatbot that was already made and it didnt work either
Hello
@rugged laurel What is your goal
idk why i cant run
@vale wing Is it fine if I dm again regarding gg
What tf does typing library even do 💀
Ah okay thx
It is better for documentation, other people reading your code and converters.
you could fetch all the messages in the channels in a server, check their content and then count that
making an ai bot that uses different libraries and algorythms to play games and text people almost like an actual person yet just virtual
Gives types
And get ratelimited 👍
classes can be confused first look, but when u get it - its awesome @cerulean scaffold i would recommend doing simple classses and play around, like a class Person: make functions that can edit data of persons etc
it could work tho
Morning panda
just a bit slower
what could?
smth else
Usually the bot that is made for stats just stores the data since it was invited
k
i did
Still the best siries for classes https://www.youtube.com/watch?v=ZDa-Z5JzLYM&list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc
In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...
i have tried all different chatbot apis
and?
I know that we are going to be taught them in the coming months, as its on our syllabus, just not yet. Will probably take a look round just to get some baseline understanding at least
what doesnt work
ive visited almost every yt video on the topic
and it says theres no errors
but when i try to run i always get error
didnt knew bots were so hard to make
they arent
^
what error
ik
chatbots are easier than Discord bots
well when using tensorflow or any other
yes
It’s hard if you just go into discord.py without even knowing python
its always error importing
couple of months... classes are maybe a 2 hour thing to learn, 4 to master. if not less
Import the module
what error
your just calling for a massive stroke
class Person:
def __init__(self, Name, Age):
self.name = Name
self.age = Age
def changename(self, Name):
# sets new name
self.name = Name
# Add a person
person1 = Person("Bob", 101)
person1.changename("Bob Hund") #changes name
``` you can learn n play around with classes with stuff like this n see how shit works together @cerulean scaffold keep it simple,
error saying it cant find the referred module
yet i imported it
ew PascalCase
@wicked quest we have other things on the syllabus we are still learning, and that is when my teacher is going to teach it. That has no effect on the difference in time it would take to learn, but alright.
Show the error
from typing import NoReturn
ImportError: cannot import name 'NoReturn'
mostly this
i hang out in the help channel sometimes helping people, trust me like 40% of the time they are complete noobs who used a tutorial from 2019, then went on stackoverflow posts from 2018 and then came to the server
thats how classes should be named
Look at his variables
ew
i mean you could learn everything at home in 2-3 days and then just impress everyone 😎
welp im gonna make an api wrapper see ya guys
Yea.. I don’t see the point of trying to use discord.py when you don’t even know python Beacuse discord.py is just a extension of python tbh
@cloud dawn:D yeah am not so much pep8
enjoy 💀
pep8
ye
@slate swantoo sloooow brotha!
not for the discord api but thx
no u
api wrappers seem boring to make
hmm indention error?
although i woudnt know
im just making them for my future mostly
its prob pretty fun
@cloud dawndef i spammed space, thing was just the visual
!e ```py
class Person:
def init(self, Name, Age):
self.name = Name
self.age = Age
def changename(self, Name):
# sets new name
self.name = Name
Add a person
person1 = Person("Bob", 101)
person1.changename("Bob Hund") #changes name
print(person1.name)
@cloud dawn :x: Your eval job has completed with return code 1.
001 | File "<string>", line 6
002 | def changename(self, Name):
003 | ^
004 | IndentationError: unindent does not match any outer indentation level
i would do it but i dont have an idea on what to make the wrapper for
lmfao
lmao
i could have made it in paint
just search and api that searches for an api like me
bet
multi word names without underspace, parameters with capitalisation 
what
big brain init
muhahaha terrorist
ikr
where do you get ideas for api wrappers
i would make one but everything is already made 🥱
i guess u care more about pep8 if others are going to view ur codes 👼🏻
Doesn't mean they are good.
^
Documentation and Test Consoles for over 1400 Public APIs
tell me a bad api wrapper

but that already exists 💀
why would you copy an api
press the damn link
your done, your done
fine god damnit
its a website that searches for apis mr
rapid-api too
Huge pp for who coded this.
im just making a private api wrapper to learn mostly
ok guys
ok god
give me an api wrapper idea, something that doesnt exist
shrek api😉
and that would be useful
searches cute pics of shrek
https://paste.pythondiscord.com/sejaluluje.http can anyone help with my error?
leaked pics of onlyfans api
i tried an old tutorial
😉
why would anyone need an api to fetch all the images of shrek?
why not
god bless that pc
amen
This Discord bot code looks funny
🤨 why is tdl http
it might not be discord bot yet but thats bc for it to be integrated as a discord bot it needs to be run first to generator the trainer files
for some reason
Why aren't you using keras?
Tensorflow 😳
i could try
WHAT IS THIS 😭
but then i would have to reedit the entire script
i made traceback and script in the same file
if thats what you mean
ML is fun to learn :)
never
There are no questions :(
yeah but
but i need to run it first
The main thing you want to do is AI and that's #data-science-and-ml
to see what my error running is
Thought about using a module like this, let user rate the accuracy to then do a DNN
i could be making an python script to connect with js frontend but i wont ask for help in javascript related discord server
like
whats the logic in that
!pypi discord-.js
you are making an ai and you ask for help in discord bots
and post code that contains 0 trace of anything discord related
from discordjs import Client
from javascript import console
client = Client()
client.on("ready", lambda:
console.log("Bot is ready")
)
async def msg(message):
if message.content.startswith("!ping"):
await message.channel.send("pong")
client.on("message", msg)
client.login('Token')
``` your welcome
WHAT 😭
Anyone got a cog that would kick members if they join too quickly one after another ? I can't code it rn but i need it, because my server has been targeted by some fatherless child
ew
With specific invite?
no
use john wick bot
if its that urgent
nah..just if they join too quickly. I mean 3-4 members per minute
We don't suggest other bots here, kinda defeats the purpose of coding.
So interval of around 15 sec?
my man literary said he doesnt want to code it
my head is falling of my shoulders..i have covid. i can't code it..i want to but i can't
i think better would be a massban for accounts that joined in near time
i was asking if someone had this in their bot and i could borrow it
its harder to make new bots than rejoin if only kicked
hey friend, lets join the server on the same time for fun.
okay, bet.
gets banned instantly
not automaticly, more of a command for mods
That's the reason why also to check the account age.
i think i will just give them a sus role or something
lmao
the bots can be old tho... who knows for how long he used them
kick ❌
ban ❌
mute ❌
give sus role ✅
Umm...
is
is same with "=="???
no
what are differences?
think is check objects and == check data like strings or interger
if i == 0:
if i is 0:
Are they different?
Ahh
Alright i understand now, tysm
Why not if not i:
but it can work with is and is not etc but
🤷♂️
if 1 !=0:
^
php be like ===
yes
nah we wanna feel n be diffrent 🙂 ==========
most lans i think have it since its standard operators
Lmao why u r speaking them
=== in php means if same object and same value
ah
😅
You can code Discord bots in php
Does ```py
member.guild.me.joined_at
tell me the time when a user joined?
that will tell when bot joined
!d disnake.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.
anything for py-cord ?
replace disnake with pycord
its same
pycord has no docs though.
why use pycords then?
For no reason?
I mean if no docs, pretty pain in ass aint it
