#discord-bots
1 messages Β· Page 644 of 1
Imagine using hours=0.5 instead of minutes=30 smh
Totally me
π
I meant about earlier
Never referred u
Ik I stopped
it has some really weird rules, the fact that it's doing bracket balancing makes me wonder if they are using regex at all
see how https://en.wikipedia.org) leaves out the ) but https://en.wikipedia.((org)) keeps everything in
I never did anything ig
^^^
!d str.endswith exists
str.endswith(suffix[, start[, end]])```
Return `True` if the string ends with the specified *suffix*, otherwise return `False`. *suffix* can also be a tuple of suffixes to look for. With optional *start*, test beginning at that position. With optional *end*, stop comparing at that position.
cebause the second url has (( inside it
You helped us in time of need, God, hereby I thank you
uh str.endswith can't tell me if the parentheses are balanced no?
I always try to ignore regex cz.... ||idk how to use it||
check if it ends with some specified domains
Didn't get balanced in Discord Mobile tho
||Totally like me||
it can tell me to leave out the ) in https://en.wikipedia.org/), it can't tell me to keep the )) in https://en.wikipedia./((org))
Hahaha
welp i guess this is futile then
same, if i ever have regex in my code it's 10000% copied from somewhere π
if it's not even consistent across platforms
Seems like a bug in either of the clients
Lmao same tbh. I just use regex builders but I always try to use str methods
same
regex looks ugly imo
i even dropped the idea of having a filter with regex, although i have to use regex for discord invites π β
nah it's beautiful and looks cool and complex because idk how to use it and it does magic π
regex looks ugly yes and so my philosophy is i just need to know how to write regex i don't need to know how to read even my own regex
why not use if str.startswith("discord.gg") And str.split
because there could also be https://
python devs focus on readability tho
discord.gg works without the https://
while i could also check that there'd be the issues to when they use spaces to ignore a filter that uses that
startswith() can take an iterable too
ik
huh
ik
but regex cool π
Here's a challenge: write a regex to detect Discord nitro scam websites
Imagine discord providing another message attr which would be message.links and message.invite_links π
i would use in statement instead
Should be easy tbh
here's my extremely beautiful and complex totally not copied from somewhere discord invite regex π '(?:https?://)?discord(?:(?:app)?\\.com/invite|\\.gg)/?[a-zA-Z0-9]+/?'
in as in match against a known list of websites?
yes
@slate swan just use str.split() and with a for loop, check if discord.gg is there in any of the words
uh where do i get such a list
if discord.nitro_scem in massage:
bot.choke()
i trust regex more tbh
There's almost everything a way to not use regex
π€£
because literally fuck regex if there's a list
what can regex do about it tho
yo how do I make the bot give someone a role when doing a command e.g. !giverole @unkempt zodiac - gives them a specified role predetermined
regex detects variations in the domain name, which is a known tactics by scammers
for example, spelling discord as dlscord
Eevee be like, let's add another list attr to any of the forks which would be a list of scam links
Imagine pinging
oh god
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
!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.
cz why not
get the role object using Guild.get_role(role_id) and then use Member.add_roles(your_role_object)
HI
And u gonna maintain and update that list? Then sure, lemme ask :D
Hello?
Everyone waiting for his question π
Thought so
so like replacing i with l and stuff like that, is there some special functionality for it or it is some spaghetti
whose?
The Epix Ray
IC
BTW I am thinking of learning JS hehe
@bot.command()
async def brackets(ctx, n:int):
with open("usersforteams.json", "r") as f:
users = json.load(f)
await ctx.send(random.choices(users, k = n))``` this didntwork
i am not here for a question just looking somoene i can help !
i got a key error of 0
wao, I was just going to do it ,-,
Ah cool
what parameters do I use
it goes a lot farther than replacing i with l
I m lrning it
Look into coffeescript, Python-like syntax and it compiles to JS
also i found this when i searched on github, https://github.com/HugoNotHere/Discord-scam-sites/blob/main/Sites.txt
seems to be enough
learn a static language
maaigot
Tho typescript is more popular
pog
..
k isnt even a thing in the send func
random.choices doesnt take two paramters ig
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
my bad then mobile view kinda sucks
how come I get an error when I use this code @bot.command() async def addrole(ctx): member = ctx.message.author role = get(member.server.roles, name="Test") await bot.add_roles(member, role)
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attrib
attribute 'server'
whats wrong then
i did it..
its guild, ur code is so outdated lmfao
hmm
key error of 0
guild.roles?
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 0
ctx.guild.roles not member.server.roles
!d discord.Guild.roles yes
property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guildβs roles in hierarchy order.
The first element of this list will be the lowest role in the hierarchy.
discord.utils.get()
Bruh whenever my phone vibrates from a notification, I feel like Discord mailed me about my bot ;-;
what did they do to it?
oof
his code works too though
Took HunAI in for verification
wha.....
ah
WhTs member.server tho
..
``` another error π
ctx.author.add_roles*
yall dont even read
!d KeyError
exception KeyError```
Raised when a mapping (dictionary) key is not found in the set of existing keys.
no one listens to us, we're invisible
use member.add_roles
I know that feeling, happening too many times since yesterday dw
!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.
More of, we are better off being ignored ngl
@prisma spoke json is empty?
nop
Seems like 0 isn't a key
I always speak facts hehe
the value of k inputted was 2
thats literally his code smh
Hmmmm
My friends gonna laugh too much when they see this message
you can't use random.choices on a dict
Yea that too
π
You need a list
I'll save you further humiliation and pretend I never said that
you need to give it a list
Good thing, Icy is asleep
then?
eg plz
what are you even trying to do
lol
do you not even know what a list in python is?
but you can use a random.choices() which choice one element from a list, this elements are equals to the key of the dictionary
nope, using it on a dict will raise you an error
[]
yes with dictionary
to use a dictionary you need a key
!e ```py
import random
my_dict = {'a': 1, 'b': 2}
print(random.choices(my_dict))
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | File "/usr/local/lib/python3.10/random.py", line 519, in choices
004 | return [population[floor(random() * n)] for i in _repeat(None, k)]
005 | File "/usr/local/lib/python3.10/random.py", line 519, in <listcomp>
006 | return [population[floor(random() * n)] for i in _repeat(None, k)]
007 | KeyError: 1
it needs a list/tuple
Yea
U can do dict.items tho
Idk I'mma better not say anything and get roasted here
to randomize the choice from the dictionary you need to create a list, which elements are equals to list, and randomize like this
good choice
how am i supposed to convert json to a list?
oh
if i want to get random inputs fromm json file then what do i do?
it's not json, what you have is a dict, json is just a way of storing a dict to a file
async def addrole(ctx):
member = ctx.message.author
role = get(member.guild.roles, id="915553473653801031")
await member.add_roles(member, role)
am I special or something
you could use create a list of the keys from your dict
same thing..
I get a "no role" error
didnt get u
remove member arg
!d discord.Guild.get_role exists bro
get_role(role_id, /)```
Returns a role with the given ID.
You can use guild.get_role
id outside the "
dont include quotes
and ids are integers
ctx.guild.get_role(id)
using list comp my_list = [k for k in my_dict]
ids are ints
ah
and then just random.choices(my_list, ...)
Best thing to do is guild.get_role(int("1234567890"))
or just give an int instead of a string 
uh
!e
import random
my_dict = {"value1": 1, "value2": 2}
my_keys = ["value1", "value2"]
print(my_dict[random.choice(my_keys)])
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
2
see?
basically what i said π
@sullen shoal #bot-commands
You can't assign values to constants like ints @sullen shoal
whats my_dict here?
Imagine wrong reply
your "json"
he deleted it
its a pain to code on mobile
Welp this just became chaotic, I'mma do something else
async def addrole(ctx):
member = ctx.message.author
role = get(guild.get_roles(915553473653801031)
await member.add_roles(member, role)
```Unknown Role
@prisma spoke no
waitno get
no
that's not a dict
use ur json object
name it something else though
json object..?
users is already ur json variable name
dict
yes
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'guild' is not defined
async def addrole(ctx):
member = ctx.message.author
role = guild.get_roles(915553473653801031)
await member.add_roles(member, role)```
making more sense..
ctx.guild
define it
I'm back = time for random questions
I meant ur json object, whatever it was
a = json.load(f)
json.load returns dict object
oh that
its get_role
Would not recommend
it's get_role
thanks
yes
Unknown Role
your id is wrong
role doesnt exist
^ that too
I passed None, but the role still exists in channel ```py
await ctx.channel.set_permissions(role, overwrite=None)
async def addrole(ctx):
member = ctx.message.author
role = discord.utils.get(member.guild.roles,id=915553473653801031)
await member.add_roles(member, role)``` Unknown role but the role is correct
my_list = [k for k in users]
@bot.command()
async def brackets(ctx, n:int):
await ctx.send(random.choices(my_list, k = n))```?
like i have checked
what's users
the json object
remove member in .add_roles
users = json.load(f)
my_list = [k for k in users]
@bot.command()
async def brackets(ctx, n:int):
await ctx.send(random.choices(my_list, k = n))```
its defined
yeah it should work
@bot.command()
async def addrole(ctx):
member = ctx.message.author
role = discord.utils.get(member.guild.roles,id=915553473653801031)
await member.add_roles(role) that?
yes
How can I delete role from channel? I tried this, but it still exists. ```py
await ctx.channel.set_permissions(role, overwrite=None)
the role still has permission values in there
weird, it should work
@commands.command()
async def get_permissions(self, ctx, role: disnake.Role):
a = ctx.channel.permissions_for(role)
print(a)
``` gave me a valid permission integer with same permissions for that role as before
weird 
@bot.command()
async def brackets(ctx, n:int):
await ctx.send(random.choices(my_list, k = n))``` i want to add certain limitations such as one choice shudnt be repeated
nope, that did not work
and that it shud display in a certain form like
choice 1 = (choicehere) vs (choice2here)
okay now i get no errors but it does nothing
@slate swan ..
that's what it does
nvm it does not
@bot.command()
async def addrole(ctx):
member = ctx.message.author
role = discord.utils.get(member.guild.roles,name="Verified")
await member.add_roles(role)
wait how do I make it so it gives the @strange crest user a role?
!d random.sample
random.sample(population, k, *, counts=None)```
Return a *k* length list of unique elements chosen from the population sequence or set. Used for random sampling without replacement.
Returns a new list containing elements from the population while leaving the original population unchanged. The resulting list is in selection order so that all sub-slices will also be valid random samples. This allows raffle winners (the sample) to be partitioned into grand prize and second place winners (the subslices).
Members of the population need not be [hashable](https://docs.python.org/3/glossary.html#term-hashable) or unique. If the population contains repeats, then each occurrence is a possible selection in the sample.
!e ```py
import random
my_list = [1, 2, 3, 4, 5, 6]
print(random.sample(my_list, 2))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
[4, 6]
async def addrole(ctx):
member = ctx.message.author
role = discord.utils.get(member.guild.roles,name="Verified")
await member.add_roles(role)```
wait how do I make it so it gives the @ ed user a role?
that only gives the role to the author
this wudnt repeat it wud it?
figured
@slate swan
yes it wouldn't
and how to format it?
.
wdym
like <computerchoiceonefromrandchoice> vs <compchoice2fromrandchoice>
it returns a list
so just index that list
i am trying to make my discord bot to update my database but its not updating
@bot.command()
async def start(ctx):
player = ctx.author
conn = sqlite3.connect('test.sql')
c = conn.cursor()
c.execute(f'UPDATE data SET start_used = start_used+{player.id} WHERE ID = {player.id}')
conn.commit()
if c.execute(f"SELECT * FROM data WHERE start_used={player.id}"):
return await ctx.reply("Command already used by this member.")
c.execute(f"INSERT INTO data VALUES ('{player.id}', 100, 0, 0, 0)")
conn.commit()
conn.close()
await ctx.send('you have started your journey with **100:nexus:** in your balance')```
there are 3 ids when i tried to run this command when a 4th id its saying "command already used by this member"
oh so like ```py
a = (random.sample(my_list, k= n))
b=a[0]
c=a[1]
await ctx.send(f"{b} vs {c}")
also why is there f string
and player.id is in quotes
ur format is wrong
i helped u earlier with that
check that msg
async def addrole(ctx):
member = ctx.message.member.mention
role = discord.utils.get(member.guild.roles,name="Verified")
await member.add_roles(role)``` "message" has no object attribute member
anyone can resolve?
ctx.author.mention
member = ctx.author
Code fixed
AttributeError: 'str' object has no attribute 'guild'
I thought you were muted
@bot.command()
async def addrole(ctx):
member = ctx.author.mention
role = discord.utils.get(member.guild.roles,name="Verified")
await member.add_roles(role)
ctx.author only
Nothing more, nothing less
No
i mean like as parameter
banned, also that was like a week ago
Thatβs mentioning the author π€¦ββοΈ
how?
@slate swan ?
That guy was an idiot anyways
Called someone an r. He kinda was
try it and see
ikr π
i thought you got muted for that
Put ur name as kratos
also if any mods see this i only agreed i wasn't the one who just said that don't ban me again π
oh wait i was there
Kraots is confusing
tf
nah
How do I make it give the role to the person I mention, not myself π
muted, then while i was muted banned
im thinking of the I pay for WINRAR dude
Uk python?
I passed None but the role permissions are same as before
what?
nah man
not much
?
set_permissions(member, send_message=False)
What do uk in python?
how were you banned?
i did get muted for that but after that i got banned too, while like 10m into my mute
It's not for role..?
set_permissions(role, send_message=False)
same thing
why were you banned?
I'm trying to remove it from channel completely
probably because i called somebody the r-slur
async def giverole(ctx, user: discord.Member, role: discord.Role): how do I make the role a specified role
?
!d discord.Member.add_roles || member.add_role(role), where member is an instance of discord.Member
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.
I am making a group of commands and I want to check if the user is subscribed or not. If subscribed, I want to allow them to use the sub-commands otherwise I will send them the link where they can subscribe.
The question is, how do I forbid a sub-command from being used?
e.i:
!mmo profile (mmo is parent, profile is child command).
How can I delete role from channel? I tried this, but it still exists. ```py
await ctx.channel.set_permissions(role, overwrite=None)
I'm trying to get rid of that role from current channel
the role still has permission values in there
hey quick question what does "const lib = require" mean?
Please tell me why the check does not work and the person who is on the blacklist can create reports?
hi guys
hello
Source code: Lib/code.py
The code module provides facilities to implement read-eval-print loops in Python. Two classes and convenience functions are included which can be used to build applications which provide an interactive interpreter prompt.
can you help me with something?
with what
code
coding
what does "const lib = require" mean?
BOT?
ye
idk this command
i want to check if a specific role is removed from any user in my server. Is there an event for that?
anything sir?
nah
o
E
u wanna see my codes?
errr
Hey @hazy agate!
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:
"hecker"....ok...
If I'm not mistaken, this is part of the js code
ye
Is that even python?
Java and javascript are two different things, I used to get them mixed up
am doing everything with py
That's JS
ooooooo
Yeah thatβs what I thought
apparently, someone said "Java is as different as JavaScript as ham is to hamster"
Hey @hazy agate!
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:
aaaaaaaaaaaaaaaa
Please tell me why the check does not work and the person who is on the blacklist can create reports?
Hey @hazy agate!
It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
did it π
on_member_update() https://discordpy.readthedocs.io/en/stable/api.html#discord.on_member_update
yes I found it now, thanks
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
When a user loses the Server Booster role. Will it count as a member update?
not yet, I fixed my code
Yes
yes it is but it isn't shown in the server audit-log
@slate swan if that doesn't work, you can use on_guild_update() and check this thing: https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.premium_subscriber_role
If before.premium_suscriber_role > after.premium_subscriber_role:.
what.
wait so what does it check exactly? I don't quiet understand it
It's a pseudo-code.
It checks the number of your server's boosts.
@potent light I basically want to check if a user is not a Serverbooster anymore and it logs it in a channel.
I have this atm but i don't know if it works
@bot.event
async def on_member_update(before, after):
role = blablbal
channel = blablabla
if role in before.roles:
await channel.send(f"{after.mention} is not a Booster anymore.")
bruh
Test it and see what you get.
I wanted to but my Boosts are on cooldown xd
To actually make sure you're getting what you want
Id add inside the logic
and role not in after.roles
It checks if the role was in the members before update roles and checks if itβs in their after update roles
No because before and after are two different things.
hm okay
Ahhh just try to add and remove a role.
You canβt manually add a booster role to someone
That's not the point
Discord does boost role handling for you. All you can do is control is the role it gives
Normal Booster Roles are not shown in the Audit Log
What if the code gives an error would you keep boosting it every time?
wdym
thx
Hello, I need some suggestions. I want to develop a discord bot but is actually out of ideas. So do you have any idea like for "what kind of purpose" shall I develop one?
If I had one, then || I would have made one first ||
true tho. But is there anything you feel like a bot must have?
No cap, but there's a shortage of ideas
any small functionality you think that it might be of some use?
Yes
yeah
There's at least one bot which has every features
exactly!!
Make a bot which can make new bots
Lol
Actually there is one iirc
Idk where I saw it
But then dbm is also always there haha
Yeah i know
o
why do I feel like u know literally everything
Hmmmmmmmmmmmmmmmmmmmmm Amen π
oof
Why tho
Why not
Cz u r a Goddess hehe
Hunter
Bye.....
:kek:
@maiden fable oh my goodness, i see the closing curly bracket in your about me xD
Its fine
How can I delete role from channel? I tried this, but it still exists. ```py
await ctx.channel.set_permissions(role, overwrite=None)
I'm trying to get rid of that role from current channel
the role still has permission values in there
how tf am I gonna read all this smh
discord web
Did u try asking in the disnake server
Ah node
Coffeescript
Node is node
ok
Wait......discord lnk and discord web hardly matter
Discord web is more unoptimized since it is chrome
Deprecated*
no lol
Lmao
We still get updates
!d discord.TextChannel.changed_roles
property changed_roles: List[discord.role.Role]```
Returns a list of roles that have been overridden from their default values in the [`roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.roles "discord.Guild.roles") attribute.
Download discord
Not allowed to use discord
Rip this pc
I feel sorry for this masterpiece
Haha this is expected ngl. Anyways let's move this to #ot1-perplexing-regexing
What? Why do I need that for?
You can use that.
@sage otter Okay the role got detected. My code if you want to use it somewhere:
@bot.event
async def on_member_update(before, after):
role = discord.utils.get(bot.guild.roles, id = 9999999999999999)
if role in before.roles and rolle not in after.roles:
print(f"{after.mention} is no booster anymore.")
no print actually a channel.send
but anyways yeh
Nah
Then do it lol
It can delete a role from a channel?
This server is better
Well there are the roles stored so if you would remove it from the list and update it.
Ah makes sense
I need to join this "disnake" server
hai @cloud dawn , have you brought any beers?
β€οΈ
beer π»
I fixed my problem *yay*
it was a stupid problem as well, forgot to put a () on lower() ;-; couldn't figure it out for 2 days
Just me with π₯ 
Ooof
Milk sucks
Very smort
Thats we you have no females
milk is ok

wait wtf
Milk gangπ€
nice new pfp β€οΈ
Ikr
I love π₯
I drink it everyday
How can i add the emoji to the button
components = [
Button(
style=ButtonStyle.URL,
custom_id="insta",
label=":NaN: Instagram account",
Hey, how to look if a given role in a given channel has send_messages as permissions?
!d discord.Role.permissions
property permissions: discord.permissions.Permissions```
Returns the roleβs permissions.
like this?
components = [
Button(
style=ButtonStyle.URL,
custom_id="insta",
label="Instagram account",
url=f"https://www.instagram.com/{message}/",
emoji=":instagram:"
)
])
But that looks for guild permissions, not channel permissions
Im specifically asking for channel permissions
property overwrites: Dict[Union[Role, Member], PermissionOverwrite]```
Returns all of the channelβs overwrites.
This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
Uh and how to look if role (as discord.Role) has a specific permission?
It will return a dict of role object to a permissionoverwrite object
!d discord.PermissionOverwrite
class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.
Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.
The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.
x == y Checks if two overwrites are equal.
x != y Checks if two overwrites are not equal.
iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
Cool ok thx
pair()```
Tuple[[`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions")]: Returns the (allow, deny) pair from this overwrite.
The link broken?
no
Yea it is
Normally it shows blue teyt without the link lmao
it takes some time to load
Yea
O looks different on mobile
Ye
@maiden fable
.
That returns that the object isnt subsvriptable
@slate swan
.
Put that <:emojiname:id> inside there
in the label or there?
Yes like that
yes but it doesnt work
it doesnt send the embed
Ok then idk I just said what they said lmao
πππ
The PermissionOverwrite object
Bruh now it says its a dict....???
Nvm I got it now
Channel().overwrites[role].send_messages
Yes
Not sure if passing the emoji like that will work tho 
I need to do buttons soon
and join this "disnake" server thing
I have never used buttons before.
unfortunately, now comes a time I do
Maybe by passing the emoji object?

You could do that but do you need to
yes it doesnt work
maybe bc its a custom emoji idrk
If the emoji is in a server the bot is in then thatβs not the problem
Put a backslash behind the emoji and send it and use that instead
For example
i have it already
And that doesnβt work you said?
yes
Then your bot canβt see that emoji
how
Is the emoji in a server your bot is in?
yes
What does the error say. When you do it like that.
Mine works perfectly fine with that.
To get the emoji object, you gotta do
emoji = discord.utils.get(Guild().emojis, id=the id as int)
Lol
He doesnβt need to do that tho
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.emoji.name: Invalid emoji
Yea but in case
Try this then ig
If i convert file pyw to exe. Script will hide on taskbar?
hi, I'm trying to make a discord bot that sents a message everytime a variable is odd
any example you have to do it??
odd?
So I've come across https://deta.sh, and I just want to know, has anyone tried to use this for a Discord bot, or something else? It looks great, but I know there has to be a catch
So for the Datetime module, how do you set the time zone as EST?
yes, an odd number
;~;
You can't have it host a discord bot, it's usually only for a website, mainly for an API
Well you can host a discord bot with an API and interactions
I'm just trying to figure out if it has issues like repl.it does
just basic logic. check if the number is odd with the modulo operator by checking if the remainder of a number and 2 is not 0. If itβs not 0 use
Messageable.send to send the message.
from __future__ import annotations do i need a module for this or is this pre included in python. i found it in robodannys cog util for paginators but ive never seen it before and i cant install it
from __future__ import braces
how do i get a channels id?
π
ctx.guild.id I think
isn't that the servers id?
okok
ye thx
plz help
If it's free it's probably going to end up being pretty crappy after a while
At the start, yeah, it looks awesome but you'll probably end up finding out it has a lot of restraints
for date.today() does anyone know how to get it in the format dd/mm/yyyy
instead of the normal yyyy/mm/dd
convert it to a string
split it at the slashes
and reorder it as you want
at least thats how i'd do it

!d datetime.datetime.strftime
datetime.strftime(format)```
Return a string representing the date and time, controlled by an explicit format string. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
Extra datetime ofc... this module 
class datetime(datetime.datetime):
def __init__(self):
self.datetime = self``` infinite `datetime.datetime.datetime.datetime`? hehe
illegal code
self.datetime would be a datetime object not the module so you wouldn't be able to do datetime.datetime
You should use __import__("datetime") instead, that would probably work
Oh yes __import__("datetime") wouldn't make it inf I see what you were trying to go for now
i have this command but when you do smth like this $suggest test again. it will only put the word test in the embed and not test again. heres the code
@client.command()
async def suggest(ctx, description):
authid = ctx.author.id
embed = discord.Embed(title='**Submitter**', description=f'{ctx.author}', inline=False)
embed.add_field(name='Suggestion', value=description)
embed.set_footer(text=f'User ID: {authid} β’ {datetime.strftime(date.today(), "%d/%m/%y")}')
embed.set_thumbnail(url=ctx.author.avatar_url)
channel = ctx.guild.get_channel(763131896045502474)
msg = await channel.send(embed=embed)
await msg.add_reaction('π')
await msg.add_reaction('π')
nvm i got it
theres only 1 parameter, what you need is 2 parameters
No they probably want to consume it all in one
In which case you have to make it like if you were putting in keyword arguments
i.e
async def suggest(ctx, *, description):
# code here
rather than
async def suggest(ctx, description):
# code here
is it possible to make a bot category specific>
If you mean the bot would only work in certain categories, you can have an on_message EVENT (very important), not a LISTENER. You can check if the message is within a certain category, if not, return. If it is, then process_commands
on_message:
if message_in_category:
process_commands()
return
What's the difference between listen() and event
class RelativeDate(Converter):
async def convert(self, ctx, argument: str) -> arrow.Arrow:
...
class Epoch(commands.Cog):
@commands.command()
async def epoch(ctx date_time: RelativeDate):
epoch = date_time.timestamp() # Cannot find reference 'timestamp' in 'RelativeDate'
I have a warning come up that timestamp() does not exist for my converter, RelativeDate. The code works, however I'm wondering if I'm doing something wrong here in regards to typehints
You can have multiple listeners that all get triggered at once, unlike event, which you can only have one of. In the case of on_message, you don't have to process_commands with a listener while you do have to with an event. This can sometimes come in handy, like the case I was explaining above. Sometime's it's not, in which case you can use a listener.
Your epoch function is indentended into the RelativeData class, if I were to guess, it's supposed to be outside of it.
My bad, it's not like that in actuality. I removed some code for sake of brevity
So is it saying that RelativeDate is not found?
It's saying that the converter class RelativeDate has no method timestamp
Which is True, I guess
Well yeah, date_time is going to be turned into a RelativeDate class
but I return arrow.Arrow
Python typehints really do nothing in function except in cases like discord.py
In this case it's different
who can help me make a queue command
For example, Python won't complain when you do something like so:
myString : str = 5
Even though you say it should be a string.
Python doesn't complain but my ide would
Back to the question, what are you returning for convert()?
I have discord.Guild object how I will generate invite link from it ?
help, i want to delete the messages of more 20 letters of length except in the flood channel, but the bot delete the message in all channels and i dont want that, can help me?
the code:
´´´py
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.channel.id == "895281353791258654":
return
else:
if len(message.clean_content) > 20:
await message.delete()
#do stuff here
´´´
it's an arrow.Arrow object, which has the method timestamp() that I need later on
This isn't the only example of this warning, by the way
Can you send how your arrow.Arrow class looks like?
It's from the arrow lib
Oh wait is this an IDE error?
???
It's a warning, yes
Through the console?
Yeah I''m starting to see what you mean, it seems more like an IDE/linter warning
Discord.py does some funky stuff with converters, so there's really not much you can do about it
I've not worked with converters before and I was thinking i've done something weird
No no, it's just how discord.py works with converters
That's a little reassuring
can help me
If I were to guess, I'd go to the documentation, find discord.Guild, and look under the methods section (2nd column)
Probably create_invite() or something along those lines, the docs are very well outlined and have good semantics
You can only create an invite of a channel
@sick birch can you help me make a queue command
Would you look at that, I guessed right haha
Don't ask to ask, just put your question and me or someone else will try our best to assist you
ok my question is how do I make a queue command
You want a general idea?
like how do I do it
Here's how I would do it: have a queue command, and some sort of data structure for holding a queue. You might also be able to make some sort of Track class, which you can put within that list. After each track is done playing, you can move on to the next one and pop the first one.
Perhaps some sort of play() function within the Track class would help
ok how
I just told you how
await msg.edit(content="")
Or
await msg.edit(name="")
I already found it
the first
Ok thx
can you walk me through it.
dm's? It'll take a while probably
I don't do dm help sorry
Also worth mentioning that you probably will fare better if you attempt it on your own, and ask specific questions here rather than "can you walk me through from start to finish on exactly what to do"
so can you help me
On specific questions but not necessarily the whole thing
??u said youd help
Like I said I've never built a queue system before, so I can only help with the general idea, the structure, and some specifics with the library itself
I've already given you a general idea and a structure
I suggest you take it from there and try your best to build a working system, me and others here would be more than happy to help with specifics
I can post my code
Sure post it and i'll take a peek
!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.
That's a start, how well does it work?
Also I can't help with YTDL, as it violates TOS but I will help with discord.py's voice features.
this doesnt have a queue command. and it works good
why does this does not work? when im trying thubnail it send error to the other part of the code
embed = discord.Embed(title="", color=0x2f3136, description=f"",
embed.set_thumbnail(url="")```
theres no title or description?
Start of by adding a queue datastructure (FIFO method)
I have no clue how to
whats the error code? @lyric moat
@sick birch I got no clue what that is. can I see an example
its an button command im trying and it keep sending error its say
File "main.py", line 61
await buttons.send(
^
SyntaxError: invalid syntax`````
Sure, say you have a queue like so:
[1, 2, 3, 4, 5]
If you were to call the remove() method, you would have this:
[2, 3, 4, 5]
Let's say you do add(6). You would have this:
[2, 3, 4, 5, 6]
take a screenshot of the code
so how would I use this
Instead of using numbers like I did, you would probably use some sort of class that represents a music track
so where would it go in my code
Anywhere, it's only a datastructure
and what is the actual code for it
take a screenshot of the error code
@slate swan
You'd write that code yourself
how do I write the datastrucutre
I can give you some psuedocode:
class Queue:
def __init__(self):
# initialize a list
def remove(self):
# code
def add(self, item):
# code
# any other methods you may need
Then you can do something like this:
q = Queue()
q.add(someSong1)
q.add(someSong2)
q.remove()
see im confused
We're only making a datastructure that will hold the songs that we want to play one after the other
The queue class is just a wrapper for a list
When you add objects, it puts them at the end of the list. Removing starts from the front of the list. Hence the FIFO method
In your queue command, you would add the song to the queue. Once it's done laying, using the after= of the play() method, you would remove the song and move on to the next
???????????????
Well to make a queue system we need something to hold all the songs we want to play yes?
So that when we finish one song, we move on to the next, yes?
That's why I'm suggesting you implement a queue class
though if you need help with building the queue class you should move to #algos-and-data-structs and a queue is a datastructure
https://www.geeksforgeeks.org/queue-data-structure/ might help you understand queues better
so I just paste this onto the top of code
No you'll need to fill in the methods yourself
I only gave you a skeleton to work with
methods?
Methods such as add(), remove(), etc...
and what would I need to add to the play command
Be glad you have to write this in Python, our teacher made us write this in Java with nothing but arrays. It was a nightmare.
To the queue command? You would call the .add() method of your queue object, and you would add the song
to the play command
Well you already have a play command working
yes
so I dont need anything else there
Only thing you might need is a system to handle what happens after a track finishes playing
IIRC discord.py provides an after= kwarg that tells it what to do after it finishes playing a song
what if I dont want to learn
Then you won't have a bot?
Then I'm still not giving you code that you can just copy paste becuase I'm not being paid to do it
I mean I have an open source bot anyone can just copy and paste, so eh
True, but I'm not going to explicitly write specific code for someone unless I'm being commissioned for it.
send to me
Looking at your image manipulation cog, isn't PIL blocking?
How do you mean by blocking
Not async
@half sun hi zenyx, please don't share links to projects that implement youtubedl or other ToS breaking aspects
Yes I don't believe PIL is asynchronous
Apologies, won't happen again
Long running PIL processes can bring down your bot, yeah?
I mean all it takes is for it to miss a heartbeat to the gateway servers and bam
Then wouldn't it freeze your bot?
how can i added a thumbnail on this?
embed = discord.Embed(title="", color=0x2f3136, description=f"**Faded Help Layout**\n\n **bot info**\nPrefix: **`//`**\nGuilds : **`{len(client.guilds)}`**\n\n **bot updates**\n__nothing found__")```
I wouldn't consider it a "long" process. It's done within a fraction of a second
All it takes is for someone to run the command at the wrong time
@sick birch i appreciate your efforts in coaching/teaching but please don't further assist that user with the music features of their bot
I mean I've had the bot hosted for 8 ish months on several servers without s hitch
Will do!
Anyway something else then haha?
anyone?
!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.
!d discord.Embed.set_thumbnail
set_thumbnail(*, url)```
Sets the thumbnail 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 thumbnail.
What is buttons?
Hover over the red squiggly, what does it say?
You're missing a closing parenthasies at the end of your Embed(). The line just before embed.set_thumbnail()
yep
lemme try
hi i want to make a reboot command in case i need to restart my bot for applying new changes without having to close the terminal.
here's my code:
(for the reboot command)
the code above was from stackoverflow and from the discordbots subreddit after a quick google search, but it just closes the terminal and somehow causes the bot to run without the terminal (however, it double sends responses)
i even tried await bot.close() or await bot.logout() but it closes the terminal and the bot and never reactivates it unless i reload the script again.
Here's a tip on how to do a reboot command: don't. Instead, you should start using Extensions and Cogs, which can be loaded and unloaded without stopping the program.
It makes it easier to organize your code too
ahhhh this is better thank uuu
Still missing a )
also if you're setting title to an empty string, you can just omit it completely
I am a very unexperienced coder. Anyone know how i can fix this in repl.it?
@sick birch ?
nevermind im an idiot theres legit a button sorry for the ping
That's the python shell you're trying to run it in. Switch over to the Shell tab at the top, or just use the Run button, which runs main.py anyway
yea thank you
lol I got the ping
why spoonfeed?
its aight
hm
it is the bot is really finnicky
i don't see why not
ikr
3 liner if you include the decorator, function declaration, and actual code
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.
Yeah thanks
No need for the str converter
Just bot.get_user(int)
Yeah its a id
Any erros?
Oh wait i thought you ment a member object
Yeah idk how sorry
-discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized```
My token is correct, please ping me on how to solve it!
Hey @karmic totem!
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:
argh
raceback (most recent call last):
File "main.py", line 23, in <module>
bot.run('token')
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nex
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 380, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 335, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 23, in <module>
bot.run('token')
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 666, in run
return future.result()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 645, in runner
await self.start(*args, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 608, in start
await self.login(token)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 476, in login
data = await self.http.static_login(token.strip())
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 384, in static_login
raise LoginFailure('Improper token has been passed.') from exc
nextcord.errors.LoginFailure: Improper token has been passed
look at the last line
yeah but its not
it is
it was straight from dev portal
@commands.command()
async def suggest(self, ctx, arg1, arg2):
await ctx.channel.purge(limit=1)
em = discord.Embed(title=f"{arg1}", description=f"{arg2}", color=0x811aff)
em.set_author(name=f"{ctx.author}", icon_url=f"{ctx.author.avatar_url}")
em.set_footer(text=f"Suggested by {ctx.author}")
await ctx.send(embed=em)```
okay, so i have this suggestion command set up. how would i work it so that instead of each arg being separated by a space be separated by a comma or something else, so that for example, arg 1 could be "add a music bot" and arg 2 could be "you should add a new music bot because groovy is discontinued"
if that makes sense
If thatβs the case you only need to pass one argument into the signature
and just use str.split() on that one argument.
!d str.split
str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).
If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.
For example:
okay thank you
Done but and the last part in thumbnail it gives error β)
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
im getting that error, how do I fix it?
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
intents = discord.Intents().all()
intents.members = True
bot = Bot(command_prefix='+', intents=intents) #Prefix for the bot
bot.remove_command('help')
i'm pretty sure something in there is raising: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
yeah how else are you going to get member
discord needs to know from which guild
idk tbh i have a way but i would rather not tell that because its slow, there must some other way and not that
my_list = [k for k in users]
@bot.command()
async def brackets(ctx,*,n:int,p:int):
h=0
while h!=p:
a = (random.sample(my_list, k= n))
b=a[0]
s=a[1]
await ctx.send(a)
await ctx.send(f"{b} vs {s}")``` this isnt workn
File "/root/caseclosed/cogs/verify.py", line 41, in on_raw_reaction_add
await channel.send(embed=embed)
AttributeError: 'NoneType' object has no attribute 'send'
can you not do channel.send anymore?
Send your code?>
get_channel tries to fetch the channel from the bot's cache. If the channel is not in the cache, it returns none. Do something like this instead
channel = self.bot.get_channel(909942444555116594) or await self.bot.fetch_channel(909942444555116594)
this will fetch the channel from the API if it's not found in the cache
Appreciate it
!d discord.User.mutual_guilds
property mutual_guilds: List[Guild]```
The guilds that the user shares with the client.
Note
This will only return mutual guilds within the clientβs internal cache.
New in version 1.7.
this could be a good way
RoboDanny (official bot of discord.py written by danny), actually has a get_or_fetch() method as a bot subclass method - perhaps this would be easier as well for future issues like this
Yeah, I usually do that in my bots
Channel might be locked for the bot
Your bot dosen't have access to that channel is my guess
how can you be sure
also, when you invited the bot, did you check the guild checkbox for the oauth2 scope?
yes
?
@worthy wagon May I ask a question?
yo
Fair enough, did you check the oauth2 guild scope?
Yes I did
That's super odd
It has access to the channel, it should be able to fetch it
Whats the point of verifying like this? No Offense, just asking, btw whats the problem youre facing
that's what i'm thinking too
automated accounts can't pass it
I see
personally i prefer to use buttons but both work
I'm not in the mood to deal with buttons bro
Well, technically they can, because automated accounts can add reactions
cause of stupid errors like these for instance
I already have a bot that is pretty much all buttons
Did you enable intents?
Different servers do it in different ways, it's hard for a bot to know how to do it
yes
Interesting
I always enable all intents, and give my bots the required permissions, and sometimes just admin if I'm lazy.
try giving it admin now
it has admin
i see
it has all perms on it's role, and I put admin on the invite link
Try giving it an admin role
it has an admin role
Like an external one?
yes
I see
Waiiiiiiit a minute
Try to reinvite the bot and check admin in the oauth2 page
I've tried that already
Code?
Is that verification channel the same one that you are trying to fetch?
yes
I had it working with a different verification command
But I decided to use a reaction instead
oh, and no, nvm
Read that differently
Then make sure that the bot has access to the channel you're trying to fetch
yeah...
you'd be surprised how many people miss stuff like that
yeah
can you send the code then?
and if it didn't have access to the channel, you wouldn't see the bot in the member list on the right
little discord tip for you guys
the member list on the right is for the verification channel which you said isn't what it's trying to fetch
yes, but it has access to both channels
i would think so as you gave it admin
i guess run it again?
i can only chalk it up to server error
now with this reaction method, it broke the sending
Lets not get toxic and maintain a peaceful environment please, no more accusations
Try restarting your bot, maybe...
I didn't get toxic
No one got toxic lol
Ok stop