#discord-bots
1 messages · Page 567 of 1
I can host anything I want on it?
even sites?
sites too?
which one do I buy?
the one for 120 dollars?
I don't understand anything when it comes to raspberry pi
if you are ONLY going to do discord bots, dont go for the raspberry pi
I don't like amazon
yup
btw, how can I check if a guild has a role by its name
bruh are you really going to buy a pi4 only for a discord bot

hey any help guys
role_obj = discord.utils.get(guild.roles, name='role')
if isinstance(role,None) == False:
return "the role indeed exists"
should do the trick but idk if it's the best approach
?
i used this instead: ```py
@command(name="mute")
@has_permissions(manage_roles=True)
@bot_has_permissions(manage_roles=True)
async def mute(self, ctx):
roles = ctx.guild.roles[:0:-1]
if "muted" in roles:
await ctx.message.delete()
But I cant get it to working
it doesn't find muted in roles
Raspberry pi = mini pc
If your going for one just for a discord bot dont just use a vps its cheaper if not you could buy the rpi and run like a minecraft server or something
Rpi 4 is good
error?
no error, it just wont work
try printing the roles list
[<Role id=902282029171867729 name='ModMail'>, <Role id=901121411639296090 name='Owners'>, <Role id=902177890932756510 name='Admins'>, etc...
well there you go
I got it working like this instead:
[role.name for role in ctx.guild.roles[:0:-1]]
yeah
For a discord bot just no a vps is better and cheaper
i am having trouble renaming files - my code renames all the files in the directory the same thing instead of the one that just was downloaded
for file in os.listdir("./"):
name = file
print(f"Renamed File: {file}\n")
os.rename(file, fileName + ".txt")```
Rpi depends on internet speed and other stuff
async def mute(self, ctx, member: Member):
await ctx.message.delete()
guild_roles = [role.name for role in ctx.guild.roles[:0:-1]]
if not member:
await ctx.send(":x: You need to mention a member or provide an ID to execute this command!", delete_after=3)
Now this wont work 😦 it doesn't send the message
I might do some other fun stuff on the rpi 🙂 but how is it not cheaper? u buy it and u never have to pay again
how do i add a picture onto an embed?
e.g.
@bot.command(aliases=["embed", "embeds"])
async def embed(ctx):
embed=discord.Embed(title="embeds", description="This demonstrates how embeds are made", + url = *urlofpic*, color = 0xEEAA41)
embed.set_author(name="BOT NAME")
@slate swan do yk?
set_thumbnail
@bot.command()
async def help(ctx):
helpme = discord.Embed(title="",
color=0x5865F2)
helpme.set_thumbnail(url='...')
await ctx.send(embed=helpme)```
profile = self.bot.profile
profile["_id"] = ctx.author.id
profile["name"] = f"{ctx.author.name}#{ctx.author.discriminator}"
inv = self.bot.inv
inv["_id"] = ctx.author.id
island = self.bot.island
island["_id"] = ctx.author.id
invmats["_id"] = ctx.author.id
invmats = self.bot.invmats
invbox["_id"] = ctx.author.id
invbox = self.bot.invbox
File "/home/container/.local/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
await coro(args, kwargs)
File "/home/container/cogs/bot/events.py", line 26, in on_command_error
raise error
File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 167, in wrapped
ret = await coro(args, kwargs)
File "/home/container/cogs/players/play.py", line 24, in start
invmats["_id"] = ctx.author.id
TypeError: 'AsyncIOMotorCollection' object does not support item assignment
Anyone?
You have to pay for electricity and it will depend on your internet speed and if your doing something else with it thats fine but if your just going for a discord bot a vps is better you dont have to depend on your internet and depending on your vps you can get like a year or more for the price of a rpi
bruh, what? rpi runs on electricity? does it take much electricity?
doesnt it have batteries?
No it doesnt have batteries it goes directly to the wall
I think some do but idk
Its a mini pc what do you expect
Still would have to buy batteries if it did
how come i defined a data variable in the global scope but it isnt being detected?
global data
data = json.load(open("data.json"))
@bot.listen('on_message')
async def on_message(message):
await bot.wait_until_ready()
if message.channel.id == data['channel']:
the error is UnboundLocalError: local variable 'data' referenced before assignment
Yeah you could buy rechargeable but it still takes electricity
So dont
raspberry pi is good for small server bots/personal bots
@bot.command(aliases = ["AVATAR","Avatar"])
@commands.cooldown(1, 3, commands.BucketType.user)
async def avatar(ctx, member : discord.Member = None):
async with ctx.typing():
await asyncio.sleep(0.4)
if member == None:
member = ctx.author
if ctx.channel.id != 835236006713098304:
emb = discord.Embed(color=0x2f3136)
emb.add_field(name="Вызивать команды допускатеся здесь [#835236006713098304](/guild/267624335836053506/channel/835236006713098304/)", inline=True)
await ctx.send(embed=emb)
return
why doesn't the bot write anything?
you need to specify value for add_field
Thank you
i wanted the picture to be where it said ```embed = discord.Embed(title='STATEMENT', color = 0x000000
can someone help me with that?
huh?
i'm so confused
Explain
Same
guys, how to make the bot output that number of characters (like !) how much will fall out in random.randint ??
do you know how random.randint works?
For that u can also use random.choice()
i need choose between one ! and twenty !
For numericals randint is fine
then how to make the bot output that number of characters ?
which will fall in randit
By making a list and then sending a random amount? Is that what u mean?
didnt understan
I think he did
You explained it like he said
?
import random
x = ['!', '!!','!!!', '!!!!', '!!!!!', '!!!!!!']
print(random.choice(x))
This is one example
Np 👍
I think he meant he inputs the number of time he wants the bot to send the character
Oh so u need input
how to make the bot send from one to twenty characters (random) - i meant this
then randint
it just sends, u don't want it to send the amount that ur specifying?
you want the bot to send 20 of "!" in a single message for "!" 20 times?
nagh
DTS alreade helped
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
ok
just use randint
bruhhhhhhhhhh
"!" * random.randint(1,20)```
the picture that is sent as a thumbnail, i want it where it says embed = discord.Embed(title='STATEMENT', color = 0x000000
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
How can I edit the channel perms for a specific role?
await ctx.guild.create_role(name="muted", permissions=Permissions(send_messages=False, read_messages=True), mentionable=False)
await ctx.channel.set_permissions(name="muted", permissions=Permissions(send_messages=False, read_messages=True))
I tried this, but it wont add the "muted" role perms to the channel
I followed the docs
How do I put in my Discord application key into my code?
Would anyone know how i can convert hex into a embed colour?
no idea then, havent used that
Your token you mean?
Dont know what you mean
use permission overwrite and update your channel with it
Application Key
For what exactly
For my discord chat bot
What do you need it for i ment
Dont know why you need the application key tbh
I need help to put in code
Is "developer application key" even a thing never heard of it
He probably means the bot token
theres application id and then theres public key
theres nothing as "application key"
The public key is for a public bot right
Application id
idek whats its for
Same
Why tho
yea where do you want to put that
Wait hold on isn't an Api key = application id
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
overwrite.read_messages = True
await ctx.channel.set_permissions=discord.Permissions("member", overwrite=overwrite)
tried doing this too, it says overwrite has no attribute called send_messages
no
what part are you stuck on? just tell me that and ill guide u from there
Basically from the start. I need an api key for my bot
What are you trying to make?
You mean a token to run your bot.
ok, i think you mean you need the bot token to start the bot, am i correct?
I already have that
Then what do you mean
@bot.command()
async def embed(ctx):
embed = discord.Embed(title="Thi", color=0x5865F2)
embed.set_image(url = "img/number.png")
await ctx.send(embed=embed)
?
Yes it's bot.run('my token')
You dont need the application id or api key and i dont think you can get a api key
What are you trying to make?
3 people helping at the same time wont help him
A chat bot
url is supposed to start with https or http
look hold on
api key for a lib
wtf did not understand, I have a picture on my computer
!d discord.File for that then
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
if you dont want to use discord.File then you send the image in discord and then copy the link of that and put that as url
Yes, I know about it. but when you delete a message with a link, the image will also be deleted.
Isnt that how discord works
how do you expect the image to be there then?
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
dave
Yes hes using embed
ye i know, lol
You wanted to show him all the stuff from a embed didnt you
i'm a guy
I didnt point anything at you lmfao
I ment him by @slate swan
oh ye, that as in i needed directions
No i ment you used the commands to show him how to use the commands of a embed
in a way yes
imagine not adding me back
couldn't be me

Lmao
ok?
No he ment it at me
he also sent me a request

and as i always do it, i rejected it 🙂
Savage
help....
first line change that to bot.command()
huh?
I think your missing
bot = commands.Bot(" ",help_command =None)
how did you define your commands.Bot?
line 9 is client.command()
line 13 is bot.command()
yea, now read the error again for me
ok, change @bot.command() to @client.command()
ok
depends on the first few lines of code, it would either be bot = commands.Bot() or it would be client = commands.Bot()
line 13
In imports you can just do
from discord.ext import commands
dont need to import discord.ext
thank you :)
fixed?
dude, it literally says "bot" is not defined, so what would the other answer be? ofc it would be client
ye, so line 13 should be @client.command()
ye
is that what you wanted?
youtube isn't always going to be accurate
i'm using replit cause vscode messes up for me
role_list = []
if "muted" in [role.name for role in ctx.guild.roles[:0:-1]]:
for m_role in ctx.guild.roles[:0:-1]:
if m_role.name == "muted":
role_list.append(m_role.name)
role_list.append(str(m_role.id))
break
else:
await ctx.guild.create_role(name="muted", permissions=Permissions(send_messages=False, read_messages=True))
print("test2")
for new_role in ctx.guild.roles[:0:-1]:
if new_role == "muted":
role_list.append(new_role.name)
role_list.append(str(new_role.id))
print("test3")
print(str(role_list[1]))
await ctx.channel.set_permissions(ctx.guild.get_role(str(role_list[1])), send_messages=False, read_messages=True)
print("test4")
print(role_list)
I've been stuck on this one for a while, the code that starts from test3 all the way down to the print(role_list) isn't working, how come?
How does vscode mess you up lmao
discord.ext doesn't work for me
Wdym it doesn't work it doesnt import
you want the command to get the stats of servers? it basically has roles listed too
What are you talking about?
hi, i want to create some more commands for my bot but i don't know how to well
what's the main problem, you need roles to display?
use mee6's or use documentation
I asked my main issue, the code isn't running from and below "test3", there is no error
use another bot?
no clue, man
Idk if you need intents for roles but have you tried having members intents
whats ctx.guild.roles[:0:-1] doing?
no, steal commands
removes the everyone role and sorts the roles
well how do i steal there commands?
ah ok
such as purge
lmfao, im tired of saying that so i just dont say it
I don't think that is the issue tho, somehow the code where I debugged from print("test3") isn't ran at all
Dont know much havent done it before
new_role.name
mhm?
you're checking a role object with the name, not the roles name with the name
which line are you talking about
for new_role in ctx.guild.roles[:0:-1]:
if new_role == "muted":
role_list.append(new_role.name)
role_list.append(str(new_role.id))
that's exactly how it's suppoed to be
wait
!e
something = ["hi","hi2","hi3"]
for x in something:
if x == "hi":
print("worked")
else:
print("didnt work")
huh
ok nvm then
how do you steal them never done it before
!e ```py
myList = ["muted", "something"]
for element in myList:
if element == "muted":
print("muted")
else:
print("not_muted")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | muted
002 | not_muted
ok wait, im not wrong
lmao, yes the second print got printed because of the second iteration
u are, on the second iteration the else statement becomes true, that's why it printed it
if you look at this, its checking if the role name is "Owner", but the owner role is the third role in the role hierarchy
Can someone help me with creating commands I don't really understand how to make commands like purge or anything on those lines i just know how to send text back or give me a link to documentation
for new_role in ctx.guild.roles[:0:-1]:
if new_role == "muted":
role_list.append(new_role.name)
role_list.append(str(new_role.id))
what do u think this does? because this is where the issue is in my code
it checks for the each role in the guild (it removes the everyone role).
and if any of the iterations meets the if condition, it appends the role name and role id to my list.
ye you need to do new_role.name to get the name, what you're doing right now is you're checking if a discord.Role is == to muted
lol
np
guys, i made code with cooldown, but bot doesnt change anything in db
here code:
@commands.command(
name="daily",
aliases=["Daily"]
)
async def user_daily(self, ctx):
place_datetime = datetime.datetime.now()
local_collection = collection['coins']
data = local_collection.find_one({'id': ctx.author.id})
if not data:
data = {}
data['datetime'] = data.get('datetime', place_datetime - datetime.timedelta(days=1, seconds=60))
if (place_datetime - data['datetime']).days < 1:
await ctx.send(
f"You can only collect the reward once every 1 day! Come via `{int((place_datetime - data['datetime']).seconds / 3600)}` часов")
else:
local_collection.update_one({'id': ctx.author.id},
{'$inc': {'balance': 50}, '$set': {'datetime': place_datetime}})
await ctx.send(f"You took 50 coins! Come back in a day and pick up more!")
do you think you can help me or point me to docs?
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
!d discord.ext.commands.Bot.command
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command "discord.ext.commands.GroupMixin.add_command").
know how to do that but that is why i asked for docs because it is somewhere
another issue if u don't mind helping btw
if its a db problem ask in #databases
ye go ahead
!d discord.TextChannel.purge use this to purge messages and ctx.send() to send a message after it
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
ok
if you click the title of this embed it will redirect u to the docs @echo wasp
thanks so much do you know where i can find more commands?
do you mean more command ideas?
yes
await ctx.guild.create_role(name="muted", permissions=Permissions(send_messages=False, read_messages=True))
for new_role in ctx.guild.roles[:0:-1]:
if new_role.name == "muted":
role_list.append(new_role.name)
role_list.append(str(new_role.id))
print(str(role_list[1]))
await ctx.channel.set_permissions(ctx.guild.get_role(str(role_list[1])), send_messages=False, read_messages=True)
print("test")
print(role_list)
the prinst("test") and print(role_list) isn't ran, but the print above the await ctx.channel.set_permissions is. What might the issue be? Because it isn't setting any permissions in the channel either
reminder, welcome message, leave message, poll, verification system, ticket system
is there docs on that?
10-04 i'll start one if i need help i'll ask ya
ok
hold on
ctx.guild.get_role(str(role_list[1])) is role_list[1] returning the id?
umm for the command name do you just say purge for it or do you need to put a number?
ok nvm
d! embed
that wont matter
holy shit, the error is literally exposed lmfao im blind, the id is supposed to be an int not str
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
oh really? I remembered it being a str lol
get_role(role_id, /)```
Returns a role with the given ID.
dumb docs not telling me 😦
ty
uh, command name is purge, arguments for it is supposed to be an int which will be the amount of messages you want to delete
@client.event
async def on_message(message):
for 10 in message.mentions:
if(10==client.user):
embed = discord.Embed(description="command prefix: `,`\nfor help, use: `,help`\ninvite alone: `,invite`", color=color)
await message.channel.send(embed=embed)
else:
await client.process_commands(message)```
how could i make this not send the embed if the message has anything but mention
ok thanks that is the only part they didn't inclued in
!d discord.TextChannel.purge
for 10 in … is this even valid syntax?
it works
thats the docs for how to use .purge
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
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 added [`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.
can u help me with this one sasuke
you should name it something more descriptive
*roles is this a role id, role name, or what is it?
just ask, if im not here someone else will probably be willing to help
yeah i know but i just need help making it not send if the message contains more then a mention to the bot
Role object
i just check
if message.content in [f'<@!{client.user.id}>', f'<@{client.user.id}>']:
``` it works and it ignores the everyone ping
@slate swan
if you rtfd, you would’ve got it
if I knew what *roles was meaning I wouldn't have asked, would I?
the docs literally tell you that
I didn't know if it wanted a role.id or something else, I didn't understand what it "told" me
what? it literally said it takes in a Role object
*roles (abc.Snowflake) – An argument list of abc.Snowflake representing a Role to give to the member. oh i wonder what it takes
yup so it should come out like so ```py
@bot.command(name='purge')
async def purge(ctx):
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)
await ctx.channel.send('(numbers of messages) have been cleared')
i think you need to learn python first
I know the basics of it
I havent learned about snowflakes yet, I'll read about it
man
hi
i dont know about that
I did read the doc, I didn't understand what it wanted me to enter as arguments, which mean there is something I need to learn right? Now I'll go read about that so for next time I wont have to ask, why are you complaining?
because the docs are clear enough
some or not for me
remember i'm still new and not as experienced as you are
end of discussion? Thanks for the help
In this case it's really not about experience
Oh my god
When it clearly tells you what it needs
In what line does it clearly says what I need? *roles? I said I didn't understand what that meant, I said I'll have to learn about it then, why are you all complaining???? 😩
The command description only shows a part of what's actually in the docs, if you would've clicked the link you would've seen that it's telling you what that is

oh, you didn’t understand what list of Role meant?
😂
I also said:
*roles (abc.Snowflake) – An argument list of abc.Snowflake representing a Role to give to the member.
That I don't know about snowflakes
I did, but not if it wanted an ID or a Name etc..
It's basically a list of Role objects
"representing a Role", imaginary 3 words
no, pinging the role is what we want you to do
no he means pinging the role is correct lmao
Oh
u stupid?
!mute 488127753745596436 🔎
:incoming_envelope: :ok_hand: applied mute to @urban ivy until <t:1635545305:f> (59 minutes and 58 seconds).
lmao
Usually i saw just one being pinged instead of the role because I thought it'd be annoying for the mods to get all pinged but alr 
manz joined and got muted
😂 😂
really used an alt for saying that
We prefer it if you ping the entire role, otherwise that one mod you pinged may be busy.
mods signed up for the pings 😄 We get far more pings from our bot that from users reporting things
¯\_(ツ)_/¯
if its in dm's, no action can be taken
Well that was random 😂
i can always report to @novel apex tho, if the guy is from this server
Just block him or disable dms from server members
just block, its not that deep
did
ye lmao
thats a whole user bruv
its nick
tnxxx
user.nick
tnx
@kindred epoch
doing this, how i can make the id and the nickname in the same line and the join position etc in another line?
with inlines but idk how to use them correctly
Yes but then joined its in the first line
Set nickname field's inline to True and joined field's inline to False.
it looks like this
Well, that's what you want?
no, i want joined, join postion and registered in same line
and id nickname in another
and roles in another line
yes but how i can make the title
like the name=
if its with one field
you do it in the value
just bold the joined, join positon ...
i mean a new field for only a single line looks bad
no
but it can be more than one value?
how people make these??
lool
they used 4 fields, and used \n in the value
/n ?
ohhhh
Hi
so \n its to make like another line?
yes
ye
ohhh
you didn't know that
!e
print("\nHi")
@kindred epoch :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | Hi
nop
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
to help you out 
XD
you need to learn basic python
i know a little bit but that no xd
and the name of the things
that's bad
learned this a couple years ago
but i dont remember many things
need to learn again :C
By making them. 
😋
Also, ngl that looks super clean. And it seems that I'm definitely going to copy some of it.
jajajajaj
@reef shell @kindred epoch now it looks like this, thanks!
nice
You can add a right arrow at the start of each line to make it look better.
> Hello
Will be:
Hello
okayyy
Make sure there's a space between the arrow and the text.
Or just >>> at the start of the string, that'll apply it for each newline
>>> Hello
Hi
Will be:
Hello
Hi
.
For those of you curious of the possible formatting options
In addition
\_ \_ will create a "blank space" that is not absorbed by discord formatting (except in certain rare embed cases)
Eg
_ _
_ _ also works
How would I get a list of all the permission a user has
how do you make a welcome command
you can do roles?
On member join i think idk
@bot.event
async def on_member_join(member):
channel = bot.get_channel(903708574138658837)
embed = discord.Embed(title="Welcome, dear user.", color = 0x5865f2)
embed.add_field(name=f"{user}, we welcome you with warm hands.", value="read the rules!", inline=True)
embed.set_footer(text="Cursex")
await channel.send(embed=embed)
``` i wrote random things
I think idk never done it before
eee, annoying as hell, i hate this
🤷♂️
mann
yep, gn tho
Gn
how are commands on my bot working if i have message intents off
Its only for verified bots
Wat no?
yeah but i COULD enable it now because my bot is in under 100 servers
but how are they even working without it
Message intents aren't even rolled out yet
Sorry I mixed it up with message content intents
There is still no restrictions.
Verified bots can do as much as normal bots.
Is it possible to make a command that edits an already sent embed?
How do i edit an already existed webhook object using it's URL so i can rename it, change it's avatar, etc.
i need help, the bad word wont get removed from the json list
@client.command(aliases=["rbw", "removebw"], description="Add a bad word to the bad word list.")
@commands.has_permissions(manage_messages=True)
async def removebadword(ctx, badword):
with open("custom_word_list.json", 'r') as f:
rbw = json.load(f)
removebadwordlist = rbw[str(ctx.guild.id)]
removebadwordlist.pop(badword)
with open("custom_word_list.json", "w") as f:
json.dump(rbw, f, indent=4)
error?
is it in cache?
will work
if you have intents
not sure where your pulling user from if on member join takes member
nope, no errors
add a print in each line to see where it stops
should be an error
unless it does it
why json
hey guys, is it possible to detect a bot kick/ban? im having some sort of db preferences for each servers, so im just trying to remove it whenever the bot isnt in the server anymore. helps much appreciated, thanks!
Yes, define the .send that sends the embed, then instead of sending again use whatyoudefined.edit(embed=editedenbed)
!d discord.on_guild_leave
ah, that detects both? thanks, i gotta implement it now
That's not the thing its on_guild_remove
Wdym by both
Ye it is
Ye
Can I Dm a user who is not in mutual server of the bot ?
What’s the difference between SQLite and aiosqlite? Like which ones better
They're both the same but aiosqlite is for async environments (like dpy)
Nope
Is aiosqlite better to use then?
for dpy?
Yeah
yes then
how do u make a verify cmd?
i want them to do !verify
and it gives them a role
and the bot responds with @amber beacon has been verify
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
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 added [`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.
well you can add the roles when the user did the command
ok
Anyway to make this work and snipe images?
!d discord.Message.attachments
A list of attachments given to a message.
yes dude
I've been through that 300,000 times
I'm not quite understanding it, and I've been at it for nearly 2 hours, ready to smash my keyboard lmao
correct
wont this always make the list None?
yeah, so I tried changing it a few times, removing it, and I don't know, that's where I'm stumped, I fixed that issue with the basic snipe command, but not this one.
What basic snipe command
Not basic, original, poor choice of wording on my part.
well
your snipe command right now is gonna snipe the message content of the command
A list of attachments given to a message.
It's an attr of message
👀 you would be saving the image
yes
msg = await ctx.channel.send(f"`Now playing: {var3}` \n{url}")
await msg.add_reaction(u"\u23F8")
await msg.add_reaction(u"\uE23A")
try:
reaction, user = await client.wait_for("reaction_add", check=lambda reaction, user: user == ctx.author and reaction.emoji in [u"\u23F8", u"\uE23A"], timeout=90.0)
except asyncio.TimeoutError:
return await msg.clear_reactions()
else:
if reaction.emoji == u"\u23F8":
await ctx.voice_client.pause()
elif reaction.emoji == u"\uE23A":
await ctx.voice_client.resume()
When trying to run this I get many problems, first, only the first emoji is added to msg, second when a user adds a reaction nothing happens. Any help is appreciated.
Are there any error(s)?
no
\u0075 : LATIN SMALL LETTER U - u
\u0045 : LATIN CAPITAL LETTER E - E
\u0032 : DIGIT TWO - 2
\u0033 : DIGIT THREE - 3
\u0041 : LATIN CAPITAL LETTER A - A
\u0075\u0045\u0032\u0033\u0041
Hmm. Can I see the second emoji?
Also, can u try using the unicode version?
Like \👍
This website lists it as u"\uE23A"
:play:
Breh wait
\⏯️ U can use this
I think discord doesn't support the other play button emoji
▶
Ok that part works but that still doesnt explain why I'm not getting a response to a reaction from the user
How do I get one for pause
Just do \:emoji_name:
Yups
change it
Yeah i will
Do it now
Also, it is discord.Client not discord.client in the main file
This error didnt come up previously
i dont think its a problem with charachters thats causing no response to a reaction
Well if your referring to shard as in sharding its a way to make your bot multi threaded (iirc)
U gotta check for response of the API and try seeing the status code....?
I mean, it totally depends on the API how it acts whenever it goes down tbh
Okay
what else do i add?
hoow to make a prefix change command
@deep sorrel hoow to make a prefix change command
@deep sorrel hoow to make a prefix change command
bruh
!d discord.TextChannel.send ig
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
my webhook keeps adding the embed of the previous update(PS webhook is connected to my own application)
code
from discord_webhook import DiscordWebhook, DiscordEmbed
import os
web_url = os.environ['durl']
webhook = DiscordWebhook(url=web_url)
# create embed object for webhook
# you can set the color as a decimal (color=242424) or hex (color='03b2f8') number
def send(app, action):
embed = DiscordEmbed(title=app, description=action, color='03b2f8')
webhook.add_embed(embed)
webhook.execute()
@boreal ravine hoow to make a prefix change command
@boreal ravine hoow to make a prefix change command
how can i get a bot to list flags and device+status like this?
is dispy ded?
no
hi
google says its discontinued
It's good but there alternatives
!d discord.Member.public_flags
property public_flags```
Equivalent to [`User.public_flags`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.public_flags "discord.User.public_flags")
!d discord.Member.status
property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
ty
bruh
@maiden fable nvm
why not just use discord.py's webhook thing
i realized its against rules 😭
cuz im not using the package its not a discord bot its just that this part of my app is related to discord
👍
hi
What happens if i do this and it doesnt find anything in the checks? py UPDATE levels SET experience = ?,level = ? WHERE guild = 1 AND user = 2 (10, 1)
so
dispy is really discontinued?
ik it updates nothing but is there a way to see that it updated nothing?
Yes
ye
And other stuff like that
hey guys
how do we make time in discord
like 4 years ago
<t:1501251200:R>
help me please @tardy lagoon
how?
<t:1501251200:R>
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
<t:11111111111111111:R>
t:1618953630:d
<t:1618953630:d>
<t:1953630:d>
omg
4 years ago
lol
how to caluclate numbers!
You can use math library or just the normal +, /, - etc.
anyone got responses
yo
how to do menus fiscord
i need help
- show full error
- dont copy shit code
hmm
menus?
so what do i fix?
wait why are you indexing time at time_convert[time[-1]]
The correct question is why are you using that theme, makes my eyes water
^^^^
gaw?
i like it lmao
¯\_(ツ)_/¯
Godawful
ur opinion, idm
@latent dragon

So they get the last character in the string
You can index a string like you do with a list
i was just typing that
ah
you were?
yes
!e ```py
string = "1m"
print(string[-1])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
m
Try printing users
See what that prints
Because I'm pretty sure you have more than 1 awaitable in there
@latent dragon
ok
Ok nvm
I just tested it out and it works fine for me
Must be a random (the module) issue
No
Anyways, you could try a workaround by using randing and getting a random number from 0 to the len(users) - 1, and then index at that random number
Oh 😂
lmao it still has the same error
That's weird
Did you try this?
If you still get it then just print the users and len(users)
Do you have some global variable named users in your file
No
no
winner = users[random.randint(0, len(users) - 1)]
Print the users
how? i know little in py i specialize in js
len print(users)?
ok
Why are you making a discord bot if you don't know the basics wtf
make js bot lol?
Knowing how to print is the first thing you learn in any language
^^
discord.js has more features xD
It does?
ik but i made so many js bots i wanted to try something new yfm
@slate swan winner = users[random.randint(0, print(users) - 1)]?
Understandable, but learn the language first, you didn't even learn the basics
You are so far off omg
Just print(users), nothing more
wtf
you cant print something like that
Here I'll give you an example in js, maybe it'll make it more clear
console.log(users);
Is exactly the same as
print(users)
🤦♂️
xD
!e
class con:
def log(self, value):
print(value)
console = con()
console.log("users xD")
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
users xD
so lmk if this is right
Pyscript 😎
winner = print(users)
Javathon 😎
?
alr
You don't assign console.log to a variable in Javascript do you
lmaOO
no
Then why are you doing it now
imagine someone made a javascript IDE inside of python
who tf would do that
you
Idk but that's exactly what you just did
lmao alr
ok but i have this
await ctx.send(f"Congratulations! {winner.mention} has won the giveaway for **{prize}**")
thats javascript
If you're using vsc
oh
It's a vsc shortcut
I use it whenever I have to comment a lot of lines out
So instead of commenting each one individually I just select them and use ctrl+/ and it auto comments all of them
its not a error im saying the {winner.mention} is assigned to the winner = random.choice(users)
A comment is #
Yeah, comment everything out so you won't get an error
its not in my terminal
@client.command()
@commands.has_permissions(administrator=True)
async def giveaway(ctx, time=None, *, prize=None):
if time == None:
return await ctx.send('Please include a timer!')
elif prize == None:
return await ctx.send('Please include a prize!')
embed = discord.Embed(title='New Giveaway!', description=f'{ctx.author.mention} is giving away **{prize}**')
time_convert = {"s":1, "m":60, "h":3600, "d":86400}
gawtime = int(time[0]) * time_convert[time[-1]]
embed.set_footer(text=f'Giveaway ends is {time}')
gaw_msg = await ctx.send(embed = embed)
await gaw_msg.add_reaction("🎉")
await asyncio.sleep(gawtime)
new_gaw_msg = await ctx.channel.fetch_message(gaw_msg.id)
users = await new_gaw_msg.reactions[0].users().flatten()
users.pop(users.index(client.user))
print(users)
await ctx.send(f"Congratulations! {winner.mention} has won the giveaway for **{prize}**")```
Properly use codeblocks reading this is awful
Also how did you not get an indentation error, because unless discord fucked up your indentation, your print is two spaces behind the actual indent
it messed up m indentation
Are you invoking the command then
define winner
Yes because I told you to comment it out
Anyways it seems like the users print just fine as a list, which is weird because for some reason you get the index error when using random
Alr found your error, managed to reproduce it
alr
reproduce 😳
You get that error because the list is empty, so when using random.choice and it tries to index, it raises the IndexError
So after you pop the bot user from the users list, check if the len(users) is 0, if it is that means the list is empty and just return because there's no winner, no one reacted
😏
its 0
Ik
So by using an if statement, after checking that it's 0, add a return, since no one reacted (you could also send a message announcing that there's no winner and then add the return)
so like a if len(users) = 0 return await ctx.send('there is no winner')?
ok
do i go back to winners = random.choice(users)
or winner = users[random.randint(0, (users) - 1)]
First
the first one?
Yes
k
winners = random.choice(users)
if (users) == 0:
return await ctx.send('There is no winner')
?
No
You're gonna get the same error again
Put winners = ... below
Also it's len(users)
if (users) == 0:
return await ctx.send('There is no winner')
winners = random.choice len(users)```?
@boreal ravine you take it from here I'm done, going back to sleep 🚶♂️
Because it seems that I'm not making myself clear of what he's supposed to do 🤦♂️
"so i can paste it?" no, would be better if you'd learn some python, your knowledge of it is clearly 0
i need to see what ur telling me so i can see it
You also needed to see how to print something?? Really? 😂
im playing a game 🚶♂️
Atp this is just basic python 😂
Alr
And ur into a discord bot with that amount of basically no knowledge 🤡
this is the whole reason im in this server
Then make the bot in js 🙃
to learn more py
Chill hes basically saying dont go to discord.py without basic py knowledge
you dont show any signs you have done programming before even in another language
Do that first, before starting a discord bot
^^
i know 3 other langs but alr
Sorry he gets aggressive when he doesnt sleep🛌
hes using basic terminology you should be able to follow
If you would've done any kind of coding before this would've been a lot easier than it was
Its true what their saying
Tbh
i learn by seeing stuff with my eyes thats all im asking
questionable but 👍
u typing it out so i can see it would help me learn
Api reference before you come here
You wanna learn more python? Sure, but don't go into projects that require you to already know a good amount of python, also, even when I told you how to print and even gave you an equivalent to what print() looks like in js, you still did it completely wrong, showing that you don't know js either
ik js lmao
You mean you know what ctrl+c and ctrl+v does? Good for you 😂
👀
i just still dont understand print() cause it prints in terminal
i learned js 2 years ago but alr bud
And where does console.log output it? Somewhere else??
deadass lol
You said you've made discord bots in js, if you run your bot and have a console.log, where does it output the value?? Not in the console like print does? 😂
ik that
😂
I learnt js a month ago and I know how to print things 😎
Then how do you not understand print() when I literally gave you what print() is in js
I learnt js last week
Actually probably 2 weeks ago
pritn in js is console.log
Yes
print*
I haven't even learned it😎
like when u do node main.js
whats your point
😎
it runs off of client.once('ready', () => {
console.log('Akairo is online!');
Big brain
thats to run a file in the shell
That's the event, what's actually printing in the console is console.log
how to disable create threads permissions
You clearly don't know anything of js either
node main.js to run the bot u put that in the terminal
Go to role settings => create public threads => disable
Hm?
isn't there a run file button
Works in the shell too
ik
yes but u can do node main.js
i know
@latent dragon just say your a rookie theres nothing bad being a rookie 🤷♂️
i am asking in discord.py >:/ by bot
in py i am lmao
!d discord.Role.edit
await edit(*, name=..., permissions=..., colour=..., color=..., hoist=..., mentionable=..., position=..., reason=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the role.
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.
All fields are optional.
Changed in version 1.4: Can now pass `int` to `colour` keyword-only parameter.
Changed in version 2.0: Edits are no longer in-place, the newly edited role is returned instead.
^
i have over 30 working bots in js
Oh using code, edit the role's overwrites, idk if threads got added tho
Idk u can check in the permissions tab
thats why i wanted to learn some py
create_threads=False
ig
?
Most blatant lie I've ever heard, lemme guess, all they do is just send hello world in the chat 😂
lol
tf no
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.update "discord.Permissions.update").
Unless you copy-pasted all their code, I doubt they'd be able to do anything else 😂😂
yeah totally
Just like you did right now with the giveaway command 🤡
i bet u cant even do embed in js lmao
do embed?
obv
and for send msges in thread?
Your going on a killings spree lmao
im saying u dont know how to code a embed in djs
https://discordjs.guide/popular-topics/embeds.html#using-the-embed-constructor it has the same syntax for embeds though
ok ty :))
Hard violation
And I'm saying that I don't even need to, unlike you who probably copies it every time 😂😂
pls stop?
camelCasing funny
copies yh fs
wut
Me rn: 😮 🍿
what wut
yes
Telling us to stop the Off-topic convo
to you stop talking about djs bruh
Because I'll agree, all this fight is very Off-topic
good point
Do you need member intents for on_member_join ?
yes
Anything related to members correct?
Is it possible or a way to make the bot read the messages in a log channel and see if something specific has been sent in the channel?
Yes
Thx
@slate swan
on_message ig
check in on_message
on_message will trigger when someone types, I have a mute command, my bot sends information to the logs channel, and I want to make a new command that checks the users history and then the bot needs to go through everymessage the bot sent in the logs and get that information
Use channel.history
ah
okay ty
or save in database
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
It's gonna be very slow at some point tho, discord limitation, so better save it in a database instead