#discord-bots
1 messages ยท Page 994 of 1
no errors
emoji*
Im not talking to u
@slate swan
hm ic
@slate swan
why would you compare it with an emoji then ๐
what?
cause emojis are cool
and so are roles
Idk never worked much with emoji
when did i compare it to emoji
arg is a str what kind of "content" you want to access
Typehint it with discord.Emoji if you are trying to compare the emojis and remove that "content" emoji has no such attribute
What kind of message
also use a event
no
Why event?
event is much better with these kinds of things
No?
@Command
async def role(ctx, member: discord.Member, arg: discord.Emoji):
emoji = bot.get_emoji()
if arg.id == emoji.id:
_role = bot.get_role(role_id)
await member.add_roles(_role)
wont something like this work?
Private var 
what
๐
!d discord.Emoji
Idk how it checks the equality
You can check source code for Emoji.__eq__
That's equality magic method iirc
class discord.Emoji```
Represents a custom emoji.
Depending on the way this object was created, some of the attributes can have a value of `None`...
bro im getting 3 diff answers confusion
@feral lichen could you please describe what exactly you need, a command that gives a role based on provided emoji or smth
do u want reaction roles?
what i need is basically you do !role @ user emoji, based if the emoji is correct, itll give the user a certain role
Ok
Make a dict of {emoji_id: role_id} and typehint emoji arg with discord.Emoji simple solution
What are u trying to make
.
Not gonna give full code cause no time unfortunately
of course
def __eq__(self, other: Any) -> bool:
return isinstance(other, _EmojiTag) and self.id == other.id
its the same
Bros, just use emoji1.id == emoji2.id
I need some personal opinions on something:
do you think it is easier to use slash commands for bots, or use a symbol prefix?
@role.group(pass_context=True)
async def delete(self, ctx, role: str):
role = discord.utils.get(ctx.guild.roles, name=role)
if role not in ctx.guild.roles:
await ctx.send(f"there is no role named **{role}**")
else:
discord.utils.get(ctx.guild.roles, name=role)
await role.delete()
await ctx.send(f"role **{role}** has been deleted :thumbsup:")
anyone any ideas? when i try to delete a none existing role i get this: https://tokyotokyotokyotokyo.tokyo/โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Both are easy tbh but ye symbol prefix
Bro typehint role
Show code
What about it didnโt work?
?
@role.group()
async def delete(self, ctx, role: discord.Role):
if role not in ctx.guild.roles:
await ctx.send(f"there is no role named **{role}**")
else:
await role.delete()
await ctx.send(f"role **{role}** has been deleted ๐")
it doesnt even send a message at all
error?
no error either
Try excpet in role . Delete
Exception
symbol preferred, got it. one in the symbol column
Why would the role not be in the guilds roles
if it isnt it sends the message?
else:
try:
role.delete()
except Exception as e:
await ctx.send(e)
Sorry for indents im not on pc
allg
Also the if statement type hint dont allow invalid roles
It will raise error in console
U need a error handler for that
@role.group()
async def delete(self, ctx, role: discord.Role):
if role not in ctx.guild.roles:
await ctx.send(f"there is no role named **{role}**")
else:
try:
await role.delete()
except Exception as e:
print(e)
Itโs not going to get a role frkm another guild
thats not what im tryna do
Ye try
DUDE
Remove the if statement no use
im tryna make it so if the role doesnt exist, it sends this message: await ctx.send(f"there is no role named {role}")
no no wait
you are using the variable where it searches the role and when it can't find it it returns as none
you get it?
If it canโt find the role it will raise commands.RoleNotFound and u can catch it in an error handler
Ego try run the cmd
wdym
nothing, tried already
look you are trying to search a role that doesn't exist
This?
yeah but thats what im tryna do in the cmd itself
and then sending it
yeah, and then it sends a message
try rolename = role
No
then await ctx.send(rolename)
@slate swanhey can i ask something
Ill give code wait
?
no need to get mad at eachother
don't spoonfeed
hello
hi
wow this aggression, tone it down 80%
chill
do this rolename = role then try printing the rolename make sure it's above role = discord.utils
it's not spoonfeeding at this point really, because once i see the code i'll know what i've done wrong
can u give me a script that a person will enter my server it will give automatically a role sorry for my bad grammar
i am explaining you man
you are trying printing something that doesn't exist that's why it is none
that's on_member_join and then it adds the role you've specified
oh ok
because you made a var named rolenthen searched the role and when it couldn't find role it returned none and for that var it is none not role name
im 100% bot filter caught that right?
make a variable named different than role
@slate swan
@slate swan u know what is typehint
sparky man
yes
where i can put here
@client.event
async def on_member_join(member):
await client.get_channel(idchannel).send(f"{member.name} has joined the party")
look here
yes thats why use typehint?
role = discord.utils.get()
and if there is no role how can it print the rolename
u can?
but why does it work in the other cmd i have tho
you know what @slate swan just give him the code
give the code
man just try changing the variable name then try it
@role.group()
async def create(self, ctx, role: str):
if discord.utils.get(ctx.guild.roles, name=role):
await ctx.send(f"there already exists a role with the name **{role}**")
else:
await ctx.guild.create_role(name=role)
await ctx.send(f"role **{role}** has been created ๐")
this works. and this is my create role cmd
not this
That's what i've been trying to explain
the one thats not working
i know, sec
Why is your role argument typehinted to a string
this is the code:
@role.group()
async def delete(self, ctx, *, role):
role = discord.utils.get(ctx.guild.roles, name=role)
if role is not ctx.guild.roles:
await ctx.send(f"there is no role named **{role}**")
else:
discord.utils.get(ctx.guild.roles, name=role)
await role.delete()
await ctx.send(f"role **{role}** has been deleted ๐")
because if i dont, then the role wont get recognized
yes thats what im saying
Don't use discord.utils.get that's slow
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
Changed in version 2.0: `role_id` parameter is now positional-only.
oh
simple way
role discord.utils.get()
print(role)
output: none
rolesearch(or anything) = discord.utils.get
print(f"{role} not found")
output: role name in argument
What the fuck is this
he is trying to print the fucking rolename asshole
i dont think its python
Typehint it to discord.Role
i am just trying to explain mate
not mini-moding
but please mind what you say
!mute 959097257435758683 1d did not heed my warning, take a break
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1650780800:f> (23 hours and 59 minutes).
Oh wait don't use get_role
Since you're just trying to get the role
!warn 381799048228896788 unnecessarily aggressive, please tone it down a few notches
:incoming_envelope: :ok_hand: applied warning to @supple thorn.
yeah
@role.group()
async def delete(self, ctx, *, role : discord.Role):
try:
await role.delete()
await ctx.send(f"role **{role.name}** has been deleted ๐")
except Exception as e:
await ctx.send(e)
Yeah just typehint role to discord.Role
but that's not what i'm trying to do
u can also add a error handler?
already tried that, wont work because it wont send the message then
what u want
i already have a global error handles, but this wont work in this situation
Ok so, let me say this better
..
u dont want to ping the role?
after deleting it? doesn't makes any sense
no
i mean in the cmd
You can make a local error handler
I want to make it so if the role in guild.roles does NOT exist, it sends this exact message: there is no role named **{role}**.
so this means it has to get the role from guild.roles and needs to check if it exists or not. If it does exist it DOES delete the role and then sends this exact message: role **{role}** has been deleted :thumbsup:
async def delete(self, ctx, role : discord.Role):
what's the significance of * there?
i guess bolding?
Roles with spaces
makes sense
ok lets help him now

you can just make an error handler for the command to check if the role exists or not ```py
@command()
async def cmd(context, role: discord.Role):
...
@cmd.error()
async def error_handler(context, error):
if isinstance(error, RoleNotFound):
# role does not exist
!d discord.ext.commands.RoleNotFound
exception discord.ext.commands.RoleNotFound(argument)```
Exception raised when the bot can not find the role.
This inherits from [`BadArgument`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BadArgument "discord.ext.commands.BadArgument")
New in version 1.5.
โฌ๏ธ
i know, but that's what im tryna do inside of the code
h?
cus im also using a group rn
not just a commands.command in a cog file
you can't do it "inside" that function since the part of code will never get executed
still implies
!d discord.ext.commands.Group.error
@error```
A decorator that registers a coroutine as a local error handler.
A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.
Changed in version 2.0: `coro` parameter is now positional-only.
but how come it works then in my create cmd? ```py
@role.group()
async def create(self, ctx, role: str):
if discord.utils.get(ctx.guild.roles, name=role):
await ctx.send(f"there already exists a role with the name {role}")
else:
await ctx.guild.create_role(name=role)
await ctx.send(f"role {role} has been created ๐")
Why'd you edit it like 3 times
3 different people yfm ๐ค
๐ no
im kiddin haha
i was joining a server and its full ;/
yikes
try adding print statement to check till what lines does your code gets executed
you need to fetchone() / fetchall() before looping with the cursor
and that con.commit() line is useless, since you're just reading the database
The f-string is useless as well
yea
true, thats not needed
still did not work
any errors?
nope
yo
i want msg like this <t:215413532323:t>
sd = datetime.now()
newDate = sd + timedelta(seconds=ab)
final = newDate.timestamp()
x = datetime.datetime.utcnow().timestamp()
await ctx.send(f"<t:{round(x)}>")
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.
For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.
For a general Python object `number`, `round` delegates to `number.__round__`.
sick
check the test server
Seems cool. But would be cooler if u add another field of hosted by
ok wait
Wrong channel
timestamp glitch
solved
this or
This one looks cooler
fine ๐
cuz i will add requirements too
at down
@slate swan
Hey there everyone, i'm new at python and i wanna learn how to develop python bots. I know the basic syntax of python and oop, how should i continue?
A tutorial to help you make better Discord bots.
thanks a lot!
rip to those who tried to react
๐
what do i use for timer
https://discordpy.readthedocs.io/en/stable/ this is better
no
?
currently i know data types, loops, conditions, exception handling, importing, functions, classes, oop, do i need to learn more before diving into asyncio?
going to be
just read a bit about asynchronous programming
did they announce it officially?
Just start making simple bots you'll learn along the way
.
dpy is back so everyone is switching
datetime module probably
I went from barely being able to send an embed to making fully fledged large scale bots
Timer?
i mean can i use sleep() ?
I asked about if they are officially killing it or smth?
No use asyncio
so it's more of learning while doing, right?
or learning by doing
nope
ye whatever
Yeah
I mean depends, if your bot have long timers, I prefer to not use asyncio
pretty cool
well, bad info then
thanks @slate swan @slate swan
Np
all below 1 month
use datetime and add timedelta to it maybe maybe
and store it in a db
That way when your bot restarts ect it won't be lost
yeah
and a checker?
i said
lovely, try using - https://www.deta.sh
thats what I'm currently using too
and its a json-based db
I use mongo or postgres
wo
yeah postgres could be a nice option too
ikr
I might start work on a new bot
but
But I want a team not to solo it zd
but, as he said, he doesnt know any database, so i just said deta ๐
Xd
i want to complete my gv cmd ;-;
Gl
.gg/dpy will have much better help
Btw
is there some async lib for that?
client.command()
async def math(ctx):
await ctx.send(f"{number} + {number2}")
channel = ctx.channel
def check(m):
return m.content == number + number2 and m.channel == channel
msg = await client.wait_for('message', check=check)
await channel.send('True!')```So what I was trying to do here is if it sends a question, I will answer it. But I am having a trouble in the ```py
def check(m):
return m.content == number + number2 and m.channel == channel``` because I make a variable here ```number = randrange(100)
number2 = randrange(100)``` So it will generate a different number from the ```(f"{number} + {number2}")``` So can you help me to make the answer is the ```number + number2``` that the bot send?
deta[async]==1.1.0a2 is the async version
async for x in y or just for x in y for an async function?
ohhh i see
{number + number2}
it depends on the iterable you are using the for loop on, not your function
WHERE/
... Which leads me into my next question: If I have an asynchronous function (for my command), and I want to call another function I made that converts to integers, do I make that converter function asynchronous as well, or just leave it as it is and just do await func()?
Ok
where?
where u want to send
thats not at all necessary, if that function has nothing to with async/await syntax you can let it be a normal one
Alrighty then. I'm using this approach for my for loop as well then. Thanks!
๐
@slate swan ```py
@client.command()
async def math(ctx):
await ctx.send(f"{number} + {number2}")
channel = ctx.channel
def check(m):
return m.content == {number + number2} and m.channel == channel
msg = await client.wait_for('message', check=check)
await channel.send('True!')
How can I fix this error
Put r before the opening quotation mark
welp, good luck
oh thx
ty
Is there like a file extension which can't opened by any user but can be opened by file handling?
๐
aw, so sweet
wait.....what?
like directly not being able to open it but being able to open it with a command?
I mean it can't be opened normally by double clicking on the file. But can be opened using python and we can write stuff.
Why do you need that?
Like, if we make lock.lock lock is not a real extension and we can't open it from pc. But it can be opened by using python and we can write stuff in it.
To do somethng.
xy-problem
The XY problem can be summarised as asking about your attempted solution, rather than your actual problem.
Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead.
For more information and examples, see http://xyproblem.info/
Just to keep some text secure. @slate swan
We have to use python to open it.
use hashing?
Hey! I want my bot to add one every time one minute has passed but it gives me a error
I gave you an example lock.lock.
It can't be opened by users normally.
But python can access it.
use a botvar
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
it changes the value of the original variable
and how can i make it so it does it every minute?
and make sure it is not named to be a method/attribute that already exists
bot = Bot() #where you define your bot
bot._uptime = 0
@tasks.loop(minutes=1)
async def uptime():
bot._uptime += 1
wait what?
alright nevermind
Like I care anyways
lmao
๐ญ why would I be a troll, wtf
ikr
""THIS IS MY ALT, NOT MY MAIN ACCOUNT""
@slate swan I'm having a trouble here that it just send only one question again and again how can I fix it? ```py
@client.command()
async def math(ctx):
await ctx.send(f"{number} + {number2}")
channel = ctx.channel
def check(message):
return message.author == ctx.author and message.channel == ctx.channel and message.content.isdigit()
message = await client.wait_for("message", check=check)
if int(message.content) == number + number2:
await channel.send("Got it right")
else:
await channel.send("Got it wrong")```
....
its probably sending the same numbers since you are defining them only once in your code and are getting set to only one value when you run your code
Forget everything and chat like they are two different persons lol
adding json for now
visible frustration
....
what?
why dont use a proper db (mongodb or deta ๐)
deta is super easy to use ngl
After type-hinting *nums: str to imply it's a tuple[str], it still does tuple[str, ...]
lmao
i want to test my gv cmd
hm alright, as you wish
ill change everything after my gv cmd
time wastage
but anyways
..
i was not only making timer i was adding requirments
true...
hm alrght
Tf is deta
https://www.deta.sh (credits to huwunter)
yeah, but "local" json "files", arent a good way to store data that may be used up frequently
storing static information might be a good option
You're right...
However,
...is actually also a valid Python expression which represents the singleton Ellipsis object. This object has no methods and was originally intended only for use in advanced slicing notation in thenumpypackage:for example a[..., 0]selects the first elements in the last dimension of a multidimensional array. However, it is sometimes also used:
- as a placeholder for not-yet-written code (e.g.
if error: ...). Code that is intentionally empty is better represented with pass.- when specifying type hints using the
typingmodule (e.g.Callable[..., str]signifies a function that returns a string without specifying the call signature).
May God bless you ๐
Can't differentiate if that's sarcastic or serious ๐
I low-key prefer deta than mongoDB, due its simple UI and the amount of free storage
I think they were being serious
Not sarcastic, I really liked it

lovely
def convertable_to_num(self, x: Any) -> bool:
try:
x = float(x)
except ValueError:
return False
else:
return True
@commands.command(
name="Add", aliases=["add"], description="Gives the sum of all numbers given."
)
async def add(self, ctx: commands.context.Context, *nums: str):
"""Gives the sum of all numbers given."""
nums = list(nums)
for idx, num in enumerate(nums):
if self.convertable_to_num(num):
nums[idx] = Decimal(num)
else:
await ctx.reply(f'"{num}" cannot be converted to a number!')
break
else:
# Stuff
await ctx.reply(f"The sum of {l} is: {s}")
Am I doing this right?
I mean the whole calling a synchronous function from inside an asynchronous function thing
It works
um, i got a weird issue...
i think the images explain for themselves
mute doesnt exist even though it does?
any reason why?
I just mean to be... semantically correct about it (pedantry nonsense)
If this works, you're in for a free Tesla from the person...
wise words
oh whoops, didnt even see that
Tesla time
was resurfacing some code i made some years ago, thanks!
Hunter*
same thing
No
yes
Please stop the rickrolls
lmao
That one was given for. I provoked it.
imagine opening random urls posted randomly ๐
That website helps people make rickroll links
Please take this conversation out of this channel.
This is for help related to discord bots
... by first putting it through a URL un-shortener; then, if safe, using a VPN to go on it in incognito window; then, listening to Rick Astley...
Sorry
np.
You know... how many times u say this, no ones gonna listen to u. That's why I also stopped saying that
just for a random link
well if they don't i'll get a mod here
you're misusing channels.
I, uhhh, nvm
#discord-bots-offtopic ๐
lmao
ew
what
huwunter
help
Show code
well it is what it is
which command
no way
I can only imagine a poor try except
The code behind the join command
@bot.command()
async def join(ctx):
await ctx.author.voice.channel.connect() #Joins author's voice channel
join seems to work
How do I make my bot send a message in another channel when a command is executed (Logs)
no..
await channel.send
Relatable
what does play look like
Python be like: What channel? Prints out 1000 line error
Make a var?
Maybe
yeah, get/fetch the channel
wdym? the code?
Ill try
also, we shouldn't help with music bots but this isn't the ToS breaking part
ofc
ctx.channel.get()...?
nope
Then?
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
I use nextcord
same thing
Eh
yeah there you go
logs = ctx.get_channel(922860659870416901)
await logs.send(f"{ctx.author.mention} warned {member.mention} for {reason}")```
Like dat?
nope, py channel = ctx.guild.get_channel(id) await logs.send()
Alr
Hey , how can I change the status of the bot
you mean like it's activity?
Yea
!d disnake.Game
class disnake.Game(name, **extra)```
A slimmed down version of [`Activity`](https://docs.disnake.dev/en/latest/api.html#disnake.Activity "disnake.Activity") that represents a Discord game.
This is typically displayed via **Playing** on the official Discord client.
x == y Checks if two games are equal.
x != y Checks if two games are not equal.
hash(x) Returns the gameโs hash.
str(x) Returns the gameโs name.
Ik, I fixed it
didn't ask
!d disnake.ext.commands.Bot
class disnake.ext.commands.Bot(command_prefix=None, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result
anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with
this bot.
This class also subclasses [`GroupMixin`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.GroupMixin "disnake.ext.commands.GroupMixin") to provide the functionality
to manage commands.
when you instantiate bot, set the activity to the discord.Game object
Oh ok
for example
-?
game = disnake.Game(name='Moderating...')
bot = discord.ext.commands.Bot(activity=game)```
Cool , ok
The world theeeeese days,
The word theeeeeese days,
Free teslaaaaaaaa,
For youuuuu
Do you guys really use discord.ext.commands? And not just import commands?
nope, we all import commands
'cept if you don't, then you're not my friend
Just for the sake of maintaining transparency whilst giving an example, it is shown like that
It doesn't work without importing commands
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "/workspace/main.py", line 43, in warn
await logs.send(f"{ctx.author.mention} warned {member.mention} for {reason}")
AttributeError: 'NoneType' object has no attribute 'send'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/client.py", line 417, in _run_event
await coro(*args, **kwargs)
File "/workspace/main.py", line 24, in on_command_error
raise error
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/bot.py", line 1048, in invoke
await ctx.command.invoke(ctx)
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 933, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'```
@quaint epoch
Do pip install discord
Bro
...?
See the whole pic and the channel history
Oh no noooo
logs is None
@client.command()
@commands.has_permissions(manage_messages=True)
async def warn(ctx, member : discord.Member, *, reason=None):
logs = ctx.guild.get_channel(922860659870416896)
await ctx.logs.send(f"{ctx.author.mention} warned {member.mention} for {reason}")
await ctx.reply(f"Successfully warned {member.mention}")
await member.send(f"You have been warned in {ctx.guild} for {reason}.")```
Whether guild related events are enabled.
This corresponds to the following events...
Why I already deleted the previous code but it still send that?
Wym
Did you host it anywhere?
In a code editor?
Uhm no?
why do i not have permission? i can kick people with the bot, but i cant mute them, why?
Like herouku
the bot has no perms to manage roles
Mu Editor
its admin though?
Some1 else can help
and it can ban people
gtg
It got no admin
It has all perms, Just not admin
The Muted role is higher than the bot's highest role
-_-
This doesn't mean it has manage roles too
Many people give ban perms but not manage roles since they are two different perms
this wroked
thanks!
i gave it literally all permissions lmao
Ah okay cool
easily
you fetch the channel, then send a message to the channel
use has_guild_permissions, it's better
show the code
you've already been told not to post the "free" nitro in the general, go to ot
don't index the list too high
lmfao
whats your code?
lmao
โฆ
.py ๐

hello spider man :") peter parker
With great power...
Please keep this chat relevant
what
lol
!ban 565531066484523008 2d Yeah uh no thanks, this isn't something we want in our server in any situation. Perhaps re-read our #rules and #code-of-conduct
:incoming_envelope: :ok_hand: applied ban to @plucky swan until <t:1650886141:f> (1 day and 23 hours).
gg

2d uh
I doubt they will join back anyways
@client.command()
async def select(ctx):
await ctx.send(
"select Menu",
components = [
Select(
placeholder = "Select something!",
options = [
SelectOption(label = "69", value = "420"),
SelectOption(label = ":)", value = ":(")
]
)
]
)
interaction = await client.wait_for("select_option")
res = interaction.values[0]
await interaction.send(content = f" selected!")โ
try this
anyone know how i can remove quotes from a str?
What do you mean?
await ctx.send(hi)
something like this?
no
i am taking a number and appending it to a json file
but i need to remove the quotes around the str
Oh, so you wanna save it as int instead of str?
yeah basically
Show me your code
@commands.cooldown(1, 5, commands.BucketType.channel)
is this correct?
Should work
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
python3 main.py
File "main.py", line 283
@commands.cooldown(1, 5, commands.BucketType.channel)
^
IndentationError: unexpected indent
exit status 1
anyone?
error says all
๐คทโโ๏ธ
nvm you just have code formatted incorrectly
It should work as string, why do you want to save it as integer? I also have a blacklist system, which takes the ID of the blacklisted user as string, I don't think it would even work else ways
means?
Basic python
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

usually it is saved without quotes around it
Hm, well it shouldn't throw any error, try it out everything should be fine
ok
nope, interaction failed
Oh wait, do you don't have it in a while True loop?
How can i give a role with dropdown menu?
@client.command()
async def select(ctx):
await ctx.send(
"select Menu",
components = [
Select(
placeholder = "Select something!",
options = [
SelectOption(label = "69", value = "420"),
SelectOption(label = ":)", value = ":(")
]
)
]
)
while True:
interaction = await client.wait_for("select_option")
res = interaction.values[0]
await interaction.send(content = f" selected!")โ
This should work
I'll check it!
@slate swan also for you^
euh it doesnt give a role
it should assign a role to the person who clicks on the dropdown option
add ur own code too?
^ I'm not spoonfeeding everyone
he gived his code
yes
But for some reason many people just start coding bots without any basic knowledge, kinda sad tbh
yes
they just start python for discord bot
Well, if they think it's worth it 
..
well
u cant just put the role name there
^
must be id?
no
You should first of all try to get a dropdown menu working without assigning a role first, then you can start work for assigning a role
u can do
it works.
nope
ty
that doesnt assign it
You need to pass a Role object
role = Guild.get_role(role_id)
await add_roles(role)
I see, then just assign the role after the chosen dropdown interaction has been selected, you can do it as you would assign a normal role with a command
can someone help me with this
^

are you trying to load the cogs in a directory?
yeh
bruh
still says interaction failed
who likes to code while chilling in this chat ๐โโ๏ธ
๐ค
that doesnt even give anyone a role :/
show code?
Hm, then I don''t really know what the problem could be, you're using the discord_components lib?
you "tried" it?
import os
# ...
for filename in os.listdir("./lib/cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
Don't make it that hard for yourself
lol
AttributeError: 'str' object has no attribute 'get_role'
๐
bruh
What
show code
yes im
We already told you, ID not a string/name
can i ask something?
Sure
its attribute
[bot.load_extension(f".lib.cogs.{file[:-3]}") for file in os.listdir("./lib/cogs/") if file.endsiwth(".py")]
is there any nsfw command script so i can make it to my bot
ill use it
Looks good 
make sure to change the path
uh not sure what to add
the path
Well, as you do need to code every command by yourself, you do also need to code that by yourself. You can check if a channel is NSFW
Do you know the basics of Python?
Yes.
no way
ohok
Yes
lie
thx :>
Whats wrong then
so? how u define numbers in a var
variable

all stop ill ask
Ofc
"ofc"
give me a sec, i need to do something rq
how u define numbers in a var
Well, if you do know the basics of python
stop
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
Changed in version 2.0: `role_id` parameter is now positional-only.
i want to ask something
This will help you most likely
what
What's authortje supposed to be btw
thats the person who clicks the button in dropdown
XD i'm gonna work on a new project, just need a development team so that we can get it done fast. I'm willing to invest into ads and more so if you want to help, just DM me!
Is it defined?
yes
As?
that worked before
yo?
thats not the problem
it does so use it
lmao
or use interaction.guild
Is there a way to add multiple images to an embed?
dont just put that id in a tuple string
HOW TO GET A Guild OBJECT WHICH REPRESENTS A SERVER
@Command
async def foo(ctx: commands.Context):
guild = bot.get_guild(guild_id) #look for the Guild object in the cache of the bot and may return None of not found
''' Now the variable guild represents a Guild object '''
There's
embed.set_thumbnail
embed.set_image
&
embed.set_footer(iron_url="")
Else you can just use multiple links to images
Bruh what happened
We're not laughing about you, we are trying to help for the past 20mins if you didn't notice it
Itโs getting heated in the discord-bots channel
We all needed to start somewhere
its always like this
@little ivy would you care to notice?
i already tried that
and
same error
yes we all start from 1 and ur starting from 5
the guild id should be an integer, okay?
send code and full traceback 
https://discordpy.readthedocs.io/en/stable/api.html#discord.Member.add_roles
@little ivy Go through this, if you don't get smart out of it come back
Well, we're trying to help
Another helpful tutorial
lol
Man that's exactly what i meant with people just start with d.py instead of Python
Then they don't even admint that they don't know the basics, like why
yes we were talking
and this guy pops
nice
lmao
I started with d.py for some absurd reason
We never hated on him
Well, you wanna know what? Me too, but I told people that, and they suggested me to start with the basics of Python, then I did that and now I'm in Python for around 6 months & d.py was the first lib i ever used
u know what
It's normal to be interested in something and then trying to do that without basic knowledge, nothing stupid about that, it's a simple mistake
i learned python from discord.py
Same kinda
hi im trying to make acknowledgements in userinfo cmd
code: ```py
async def get_acknowledgements(self, member):
bot_guild = self.bot.get_guild(764049436275114004)
staff_role = bot_guild.get_role(849669358316683284)
if member.id == self.bot.owner_id:
return [f":owner: Owner of {self.bot.user.name}"]
if staff_role in member.roles:
return [f":staff: Staff member in the [support server](link)"]
this in ui cmd
acks_list = await self.get_acknowledgements(member)
acks = "\n".join(acks_list)
errorpy
['Traceback (most recent call last):\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped\n ret = await coro(*args, **kwargs)\n', ' File "D:\Projects\PizzaHat\PizzaHat\cogs\utility.py", line 63, in userinfo\n acks = "\n".join(acks_list)\n', 'TypeError: can only join an iterable\n', '\nThe above exception was the direct cause of the following exception:\n\n', 'Traceback (most recent call last):\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke\n await ctx.command.invoke(ctx)\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke\n await injected(*ctx.args, **ctx.kwargs)\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped\n raise CommandInvokeError(exc) from exc\n', 'discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only join an iterable\n']
uh
Man I remember i used "input" to get user input in discord ๐
same lol
also i learned oop from discord cogs
HOW TO GET A Guild OBJECT WHICH REPRESENTS A SERVER
@Command
async def foo(ctx: commands.Context):
guild = bot.get_guild(guild_id) #look for the Guild object in the cache of the bot and may return None of not found
''' Now the variable guild represents a Guild object '''
HOW TO GET A Role OBJECT WHICH REPRESENTS A ROLE IN DISCORD
@Command
async def foo(ctx: commands.Context):
role = bot.get_role(role_id) #returns a Role object from the cache and in-case the Role object is not found in the cache, it returns None
''' OR YOU MAY USE A Guild OBJECT TO DO THE SAME '''
guild = bot.get_guild(guild_id)
role = guild.get_role(role_id)
@little ivy
I don't know how do I help you more
classes?
Welp, if you're interested in bot development, you try to start with it right away and there's nothing wrong with it unless you say you know the basics but can't define a variabel which containts an int
ye
Another nice tutorial
what
ye create like
role - #discord-bots message
guild
and all
pardon? @slate swan
because thats how they are capped in the library
!d discord.Role
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
input
@bot.event
async def on_message(msg):
print(msg.author)
print("'"+str(msg.content)+"'")
if not msg.author.bot:
await msg.channel.send("Hello World")
output
BrianNone#7593
'Webhooker#7983
Hello World
'
what wrong with my code?
wo
i want to get my msg conyent
msg.content
You have message intents enabled?
ez
just print msg.content
yes i am sure
Oh, he wants to print it out, my bad
Jaguar just type ๐ญ
don't reply only after looking at my code
its msgs or msg?
@slate swan u told to ping if someone needs help 
hes still here
intents = discord.Intents.default()
intents.messages = True
You defined it as msg, so it will be msg
yes
u can freely ping anyone thats not mod and active in this chat
The โTypeError: can only join an iterableโ error is caused when you try to join a value that is not iterable to a string. This can happen if you assign the value of a built-in list method such as sort() to a new variable and try to join the result of that operation to a string.
yeah that is excialy what i did
is that a real error?_
I don't see anything wrong in there tbh
i tried first without the list, by normally returning stuff.. but that gave me the same error, so my friend told me to return it with [] so it'd be a list and .join() would work
can i send you the code and you test it by yourself or...
maybe the problem with me
..
So you want the message content printed out, right?
what do u want to do?
@event
async def on_message(message: discord.Message):
print(message.content)
FOR THIS TO WORK, MAKE SURE YOU HAVE MESSAGE CONTENT ENABLED (dpy 2 and above)
intents = discord.Intents.all()
''' OR '''
intents = discord.Intents.default()
intents.message_content = True
ye
@strong vector
.join() joins a all the list together with a string, there is only one thing in that list so what has it got to join ๐คท
huh that make sense
ok so how do i make them send in new lines?
split the list into parts you want to be on different lines
even though all I write is nuisance ๐
Well, if it works it works 
list = ["All","on","different","lines"]
print("\n".join(list))
finly
BrianNone#7593
'siiii'
Webhooker#7983
'Hello World'
BrianNone#7593
'Hello world finly it works'
Webhooker#7983
'Hello World'
Thanks @slate swan
Have fun working on your bot
hell world finly it works 
so, does that if conditions work?
what?
cool
someone give me bot ideas ๐คฃ
lol
if ctx.author.id == self.bot.owner_id
Art bot that what i am doing right now ๐

If the condition is met it will return the list
Your conditions are fine
Jaguar type faster 
snowyjaguar is gonna finish typing and just say "Ok"
lmao
I was in this one server and this dude typed for a few days, it ended with him just saying "h"
lol
@flat solstice wake up
Sometimes i just do type nonsense then I delete everything and thats pretty much what comes out
h
like this? lmao
lmao
key strokes bl:
ctrl + a ctrl + c backspace O K ENTER
bruh i got distracted by your pfp ๐
so I have this condition https://paste.pythondiscord.com/cemomojosi which is making my embed value a different thing depending on the below (before and after mean before.afk_channel and after.afk_channel)
if before or after exist then run the rest of the code - this means that as long as one of them exists it will add the embed field but if before or after don't exist or are None then it won't add the embed field
if before and after exist then check if they are not the same thing, if they are not the same thing then add the field
if either before or after exist then change the embed field value depending on what the outcome is.
I'm doing this process 4 times, for guild.afk_channel, guild.system_channel, guild.public_updates_channel and guild.rules_channel so I thought it would be a good idea to make it into a function https://paste.pythondiscord.com/buxidawisi but I'm not sure how to incorporate the function call into my embed construction.
I could just call the function from the value of the embed field without any of the existing conditions (since they exist in the func) but I think I'd have to do that 4 times and wouldn't work since it would still be trying to add the field regardless if one exists or not
I could do the above with a if before or after: check which I think would work
I could move the field construction into the function and just call the function 4 times altho it might need the same logic check as above and I'm not sure how I would name the field, maybe I'd need to pass in a name to the func
What
oh my god
lmao
now read it
watch him get no help
due to all of the like stuff in it i can't even read it lmfao
lmao
I thought I was just too lazy to read it ๐
make it smaller ๐ญ
ye
I'm getting a brainfuck trying to understand what he wanna do
same
type it in our language jaguar
lmao
What's the topic
no clue
me C:
me
I swear this chimpanzee knows more than what I figure out for 50 minutes
to busy making a porn bot 
PROMO
oh god
if u wanna make smthn tho dm yh yh
Tell me once its finished
uh
it is pretty much finished tbh
||send API link||
lmao
make the bot ask ur dad no. first it will be cool
isnt that the age when people watch porn
yes but i'm a good lil boi
๐
not a clue what that said

..
..
yeah sure 
who knows right
jaguar is typing once again

thanos is gorn
can we keep it PG-13 in this server?
yeah sorry ๐ญ
thanks a lot
I think it lowkey violates the rules anyways, so yuh
i just spent $200 on a mobile game
ok
was it clash royale or clash of clans
neither
Damn thats a waste
Your dumber than discord.js devs
pubg
was some tycoon game 
lmao
bruh
what the emoji server
"exotic pfps"
idk
content
Click on the emoji
- I just spent 200 dollars on a mobile game
- who cares anyways I'm getting payed in a week
money farmer or what?
ye
jaguar is once again typing
Wtf
Is it a good game?
how?
its decent lol
by clicking the buy button
"decent"
man spent 200 dollars on a decent game
Why'd you buy it then
You probably make bank since your a female on discord ffs
ashley is Elon in disguise




