#discord-bots
1 messages ยท Page 807 of 1
๐ฟ
make a ripoff of discord?
๐
Lmao
Already 2 are present
its time for the third
You can get the message.author on the on_message_delete event. However if the event didn't catch the delete for whatever reason no
they mean name of the user who deleted the message
which can be some moderator other than the user itself
Are buttons added simultaneously to messages or are they delayed one at a time like how reacts are?
Audit logs doesn't really show that effectively
yea, audit logs is an option, but that doesnt work always
ye i was thinking the same thing @stone beacon but i realized it wouldn't work
in discord.py Views are added to a message directly, not one by one
.send() takes a view kwarg, which is a discord.ui.View with all components
Ooh, excellent. Do you have an easy way to link info/documentation regarding using those?
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
would be pillow
Pillow but what you showed in the image is extremely complicated
Okay!
It's not very complicated
It is
I mean you shouldn't just start using pillow and the first thing you do shouldn't be that you should start simple
How would you accomplish that with Pillow? What would the process look like?
I mean just a simple welcome card is easy enough but what they showed in the picture is pretty complicated because you have level, rank, progress bar and all that jaaz
And how to make the file name written when deleting a file / photo?
Like here for example
I need to make sure im understanding Discord py docs
In classes, there is attributes, and methods
Discord py docs, lets say that i have discord.Member, attributes are data about that (ex: roles) and methods are like actions on that class? (Ban example)
methods are functions in a class
well then you have it down. what did you not understand before?
you shoudl have a solid understanding of OOP before doing dpy
I know
Because from the docs all I see are classes
Its really my problem that I couldnt understand those
oh ok
what are you having trouble with in particular?
what do you mean exaclty
No i just didnt understand OOP
What's OOP
maybe u didnt understand python
I was asking if i understood how the docs worked to make sure i wasnt making stuff u

object oriented programming
I feel like a dummy
Object oriented programming
object oriented programming'
Man I've been developing bots for a week
And didn't know
uhh
You should learn that, it helped me a bit
Will do
thats why you learn python forst

In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...
This is what I used
this is the best imo
Even though im dont understand 100% at least i know more than i did before watching
Look someone told me to learn python here
So i just restarted and re looked
I tried to learn like a bit of everything, but just the basics
Like a bit of SQL, webscrape, file handling, and i re learned everything
from discord.ext import commands
import discord
from discord.commands import slash_command, Option
from helplist import helplist
class ConfigurationSlash(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(guild_ids=[931241793083822080, 862560109048496139], name="setprefix", description="Changes Prefix")
@commands.has_permissions(manage_guild=True)
async def setprefix(self, ctx, prefix: Option(str, description="Prefix to set")):
if ctx.guild.id not in self.bot.settings:
self.bot.settings[ctx.guild.id] = {}
self.bot.settings[ctx.guild.id]['prefix'] = prefix
self.bot.db.set('settings', str(self.bot.settings))
await ctx.respond(f" Changed the server prefix to {prefix}")
@setprefix.error
async def setprefix_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
prefix = self.bot.settings[ctx.guild.id]['prefix'] if ctx.guild.id in self.bot.settings and 'prefix' in self.bot.settings[
ctx.guild.id] else self.bot.default_prefix
await ctx.respond(
f" **Invalid Syntax**, Use `{prefix + helplist[ctx.command.name][2]}`")
else:
await ctx.respond(f"** {error}**")
def setup(bot):
bot.add_cog(ConfigurationSlash(bot))
anything wrong?
what's the error
whats the error
role = discord.utils.get(ctx.guild.roles, id=915363576867344435)
if role in member.roles: ```
``ommand raised an exception: AttributeError: 'User' object has no attribute 'roles'`` anyone know a fix? trying to see if the user has a roll
when will people understand that we can't go through each line of your code just to figure out a syntax error lol. even more so considering the fact that we'd have to look at the code of all the methods in the code too to properly determine what's wrong, which is very time-consuming and something that should be left up to the compiler
can you send error you get when you run code ?
convert into Member object
there is no error, my slash command just does not register
User object has no roles attribute, you prob need a Member obj
it takes time @tacit knoll
whow
its a guild slash command?
should register after 10 minutes of waiting im assuming?
member = discord.utils.get(guild.members, id=id)
if its guild specific it gets added as soon as the code runs and request is made, for globals it take upto 1 hr
or, guild.get_member(id) is faster
guild not defined
that was an example, you would be using your own Guild object ( ctx.guild for you)
await ctx.guild.get_member(id)?
you dont need to await it
AttributeError: 'Member' object has no attribute 'role'
yes
but it did not work
its roles
is the cog loaded?
print(bot.cogs) and see if the cog is in the list
so, its loaded
wait what library is that?
its not, discord.py does not have slash commands
its understandable by their code that they use discord.py,by which library i meant what fork since all forks have different slash impls
Thanks for tryna help me mate
how do i get PartialAppInfo from create_invite in disnake
i have this code ```py
member = await bot.fetch_user(820882341190303754)
invite = await channel.create_invite( target_user = member , target_type = disnake.InviteTarget.embedded_application)
#await ctx.send(invite.target_application.description) and None
#await invite.delete()
but it gives invalid user id ( user is bot )
why dont you just bot.user instead of fetching it
are you sure the guild ids are correct, since i dont see anything wrong their according to the code
one moment
bot.user doesnt return a bool
!d discord.ext.commands.Bot.user
property user: Optional[discord.user.ClientUser]```
Represents the connected client. `None` if not logged in.
!d discord.user.ClientUser
class discord.ClientUser```
Represents your Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the userโs hash.
str(x) Returns the userโs name with discriminator.
its correct btw
its a discord.User with some additional functionalities
ok but it doesnt work that way
Did u invite the bot with application commands scope?
yes
for some reason it works without the cogs
Show ur imports
first thing, the target_user is used only if target type is TargetType.stream
In that cog
it works like this
not embedded_application
import discord
from discord.commands import slash_command, Option
from discord.ui import Button, View
from discord.ext import commands
intents = discord.Intents().all()
intents.presences = False
class PersistentView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label="Hello", custom_id="test")
async def test(self, button: Button, interaction: discord.Interaction):
await interaction.response.send_message("hi!")
class botReady(commands.Bot):
def __init__(self):
super().__init__(command_prefix='!', intents=intents)
async def on_ready(self):
print('ready')
self.add_view(PersistentView())
client = botReady()
@client.slash_command(guild_ids=[931241793083822080, 862560109048496139], name="button", description="A test command to get a Persistent Button!")
async def button(ctx):
return await ctx.respond('Hi!', view=PersistentView())
client.run("Otoken lol")
this code works
but somehow
from discord.ext import commands
import discord
from discord.commands import slash_command, Option
from helplist import helplist
class ConfigurationSlash(commands.Cog):
def __init__(self, bot):
self.bot = bot
@slash_command(guild_ids=[931241793083822080], name="setprefix", description="Changes Prefix")
@commands.has_permissions(manage_guild=True)
async def setprefix(self, ctx, prefix: Option(str, description="Prefix to set", required=True)):
if ctx.guild.id not in self.bot.settings:
self.bot.settings[ctx.guild.id] = {}
self.bot.settings[ctx.guild.id]['prefix'] = prefix
self.bot.db.set('settings', str(self.bot.settings))
await ctx.respond(f" Changed the server prefix to {prefix}")
def setup(bot):
bot.add_cog(ConfigurationSlash(bot))
this doesnt?
what version of pycord you are on?
2.0.0b1
then i wont be able to what i want..
because the only way is create_invite
what do you want to do?
where does it import pycord
pycord uses the discord namespace
oh
What if you want a discord Button which can be clicked repeatedly and for example increment a value?
no cause it doesnt return an errror
Why is everyone referring to pycord now? Just a week or so ago it was all about Disnake, what's the story there?
noone is
probably to say how bad it is
๐
they already use pycord so we r helping them with the library not registering a slash command 
Haha oof
laufs in disnake+hikari
So Hikari, per what I was asking earlier - I've managed to get working buttons and have an understanding of Views/Buttons now - for example, if I want an interaction which is repeatable like every time you click the button it sends a message, what is the process for that type of thing?
Use rin, ezzz
client.run starts how do i stop is there something like client.stop?
client.close(), its a coro
thanks
you setup a callback for the button
What u specify in the function of the decorator of the button is executed whenever a button click is there
what library are you using?
!d discord.ui.Button.callback can also be used, but preferred is to use the first way
await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overriden by subclasses.
this works for all , avoid the self.close() if you want to take multiple interactions
examples/views/confirm.py lines 16 to 28
class Confirm(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
# When the confirm button is pressed, set the inner value to `โTrue`โ and
# stop the View from listening to more input.
# We also send the user an ephemeral message that we're confirming their choice.
@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message('Confirming', ephemeral=True)
self.value = True
self.stop()```
the confirm function is the callback of the button
Excellent! Thank you ๐
time.sleep(1)
client.close()```
is it possible to make on_message_delete and on_message_edit not affect other bots?
I'm building essentially a control panel which will set user specific settings, I'm going to have to think about how to make it happen ๐
run blocks forever, it won't reach your close
oh btw i figured it out from stack over flow
u need to load the cog before on_ready
ye i see :S
yeah bots dont execute code under .run() method
wheres your rin pfp๐
Donโt load cogs or technically any thing much on_ready event itโs not a good idea to do so, instead try using the
if __name__ == โ__main__โ:
#load cogs
#run the bot
i mean you can but dont
Birthday over, pfp gone
on_ready can go off multiple times
sed day๐
personally, i just have a configuration category which has commands related to settings
ill do it myself๐พ๐ผ
jk
What do you mean when you say that? Could you share a small example?
you mean stuff to configure settings of your bot per server right?
What he means is he has a category (cog) where thereโs are commands related to setting up per server wise config ie prefix, command toggles etcโฆ
I mean like, a user can have a word_count as an example, this is obviously not how it would work in practice but works well enough to illustrate what I want the function to do:
User can hit a button +/- which increments or decrements the word_count
but I want a menu where you can effectively go up and down levels, say you want to go into your settings you hit a button that modifies the view and displays the menu options (and splash screen) for settings, then you click "cypher settings" and it will open up the cypher settings menu which will have things like word_count and such which you could ideally either enter a value or +/- button to increment/decrement. How would you accomplish this? I'd consider having Views defined for each level of the menu and essentially connect the menu via interactions so the user can move through the menu. All of this would be persistent message in DMs between the bot and the user
is it possible to make on_message_delete and on_message_edit not affect other bots?
Wdym by โeffect other bots โ
Like ignore those bots?
that gotta be hard, but is for sure possible with views
I think I'd probably make a dict of all of the menu screens and call the views somehow, I'll have to brainstorm but it makes sense to me -- is the best practice on this editing the message to have the new view and it will automatically change the message with the new view?
Oh
if you mean not get triggered when the event is caused other bots , use .bot property of User/Member and if its true , return
say for example you post a message which is view=first_view
then you have an interaction which edits the message and sets the view=second_view - will that fully convert the original message into the new view?
if message.author.bot : return
where message is a discord.Message object
Yup
Excellent. Thank you! ๐
How to create multiple on_member_join() listeners?
In a cog?
Mhm
provide the event name in the listener instead of naming the function
@Cog.listener()
async def on_ready(self):```
-> ```py
@Cog.listener('on_ready')
async def my_event(self):```
tho it should work normally too
oh thanks
async def on_message_edit(before, after):
if message.author.bot:
return
channel = bot.get_channel(935160414965211179)
So?
before and after are your message objects here
@bot.event
async def on_message_edit(before, after):
if message.author.bot:
return
channel = bot.get_channel(935160414965211179)
@slate swan ัะฐะบ?
^^
What?
I want to make these events not react to other bots
That makes it so it doesn't react to other bots
Have you even tried learning basic level oop?
how can i make my bot answer when it gets pinged
if message.author.bot != True?
idts
no not u
ok
do you know this?
@slim ibex
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
use this to check if your bot user is mentioned, in an on_message event
if bot.user.mentioned_in(message)?
hm
it would be in an on_message listener
k
this is nice, never knew about this
fun fact, its true even with everyone mentions
ah
async def on_message(message):
if client.user.mention in message.content.split():
await client.say("hey")```
could this work
that code is...seriously outdated
shi
private context ๐ฟ
thats jishaku and it uses _ctx for the current context
thats for the old async version
but, if you replace client.say with message.channel.send, it "sometimes" works
async def on_message(message):
if bot.user.mentioned_in(message):
await message.channel.send("You can type **. help** for more info")```
did this but it answers when i do @ here or everyone
how can i fix that
.
when using await channel.client.logout()
i'm getting this error:
tasks = {t for t in task_retriever(loop=loop) if not t.done()}```
```await channel.client.logout()
AttributeError: 'TextChannel' object has no attribute 'client'
So I'm toying around with Views, but I'm having difficulty passing CTX and understanding how the flow of things should go:
class TestView(View):
def __init__(self, ctx):
super().__init__(timeout=0)
self.ctx = ctx
@discord.ui.button(label='Settings')
async def button_callback(self, button, interaction, ctx):
await interaction.response.edit_message(view=view_dict.get('settings')(ctx=ctx))
await interaction.followup.send('Test')
class SettingsView(View):
def __init__(self, ctx):
super().__init__(timeout=0)
self.ctx = ctx
@discord.ui.button(label='Back')
async def button_callback(self, button, interaction, ctx):
await interaction.response.edit_message(view=view_dict.get('test')(ctx=ctx))
await interaction.followup.send('Test')
for reference, view_dict is a simple dict of the type:
view_dict = {
'test': TestView,
'settings': SettingsView
}
these are obviously just for testing but I'm trying to determine the feasibility of this implementation style
with the above code, when clicking on the TestView button:
TypeError: TestView.button_callback() missing 1 required positional argument: 'ctx'
nah, they have it right
the interaction is already a context like object
Doesn't matter if it's a fork
!d discord.Interaction interaction Variable there is this object
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
if you have discord downloaded that may cause problems
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
The method they used needs a small one
I removed discord and then installed disnake as discord
But you didn't found the complete thing :)
import discord
from discord.ui import View
class TestView(View):
def __init__(self, ctx):
super().__init__(timeout=0)
self.ctx = ctx
@discord.ui.button(label='Settings')
async def button_callback(self, button, interaction):
button.label = "True"
await interaction.response.edit_message(view=view_dict.get('settings')(interaction))
await interaction.followup.send('Test')
class SettingsView(View):
def __init__(self, ctx):
super().__init__(timeout=0)
self.ctx = ctx
@discord.ui.button(label='Back')
async def button_callback(self, button, interaction):
button.label = "True"
await interaction.response.edit_message(view=view_dict.get('test')(interaction))
await interaction.followup.send('Test')
view_dict = {
'test': TestView,
'settings': SettingsView
}
working at present ๐
the ui.Button is for a class in params
this works right?
hm
What is the best method storing/editing an embed for the base message within a view?
hello
thats not how views work , read the example from danny https://github.com/Rapptz/discord.py/blob/45d498c1b76deaf3b394d17ccf56112fa691d160/examples/views/confirm.py#L16-L28
examples/views/confirm.py lines 16 to 28
class Confirm(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
# When the confirm button is pressed, set the inner value to `โTrue`โ and
# stop the View from listening to more input.
# We also send the user an ephemeral message that we're confirming their choice.
@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message('Confirming', ephemeral=True)
self.value = True
self.stop()```
going to have to figure out adding multiple buttons via view, I'm going to refer to docs and see if I can make heads or tails
yo
because
first of all, don't have your bot key in open text, that isn't a good practice
as everyone in here can see your key, I would suggest you generate a new token
and it should also be a string
pas grave?
me'en fiche
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
ok sorry
thats a test bot
still, anybody can steal your bot's token
I'm kinda getting a stroke
you may just be running a command then suddenly, you realize you didn't code it!
well done ๐
yeah, literally with that token anyone can make your bot send commands
and it bombs your chat
Thanks!
I know but it's just a test
so one of us who saw it, not that we would, could literally run your bot as if we were you and make it do things you don't want
I mean...
@bot.command()
async def spam():
user = bot.get_user(689376859435433997):
for i in range(100):
await user.send("spam")
(yes, I know I'll get ratelimited)
it is a good practice even with a test bot to keep that information safe, using environment variables is a good practice
lmao
๐
what happens when you get token ๐
time to screw some people
mwahahaha
I'm unstoppable
youre just asking to get ratelimited
๐คฆ
why not just spawn tasks every 0.1 seconds and send a new message, only 100 messages is weaksauce, let's go to infinity! ๐
while loop is a thing
yes!
yes
we were trying to demonstrate to a user why you shouldn't share your key
okimii was too scared to 1v1 me smh
you talk about me
?
whatsup okimii
yes, we were trying to demonstrate why sharing your key is a bad idea
hey baron X
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
?

how to make discord bot
link
in git
ok we will see but given the connection it will crash
ok
lol
I'm doing a chemistry ๐ฆ
nice
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.

you leaked your token
Regenerate it
also make sure that the token is surrounded with "
yes
noooo
thanks
thanks
noooooo
xD
you dont await get_user
oh

yea it gets the user from the cache

fetch_user needs to be awaited
sor
should i name myself 'pep8 abuser' 
you wont ๐
fwyb
what?
fwyb.
man english isnt my firs language i dont know these shortenings i learned wb last day lmao
its a meme bro
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
bro
guild = self.bot.get_guild(guild_id)
``` why this is None in one Cog and not in another cog is it sum cache issue? (its same guild)
don't you dare
what's the guild_id variable?
just an int
while True:print('ok' , 'i wont')```
like guild_id = 12356768986
make sure the guild id is correct
@slate swani figured it out, i need like something that tells bot is ready
yea that would work only after the bot is online
think you are looking for on_ready?
cause before that the cache would be empty
!d discord.Client.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the clientโs internal cache is all ready.
thanks bud
await self.bot.wait_until_ready()
in a cog
damn its built into the bot thats nice
?
docs
yeah i got it already thanks tho
np
is there a way to have a link that is a video into a embed
that will be playable directly in discord?
if i post only link as user it automaticly converts it to viewable video
but not if i just post the link from bot
guys so im using replit to code, and my bot is sending the message twice after i use said command
no errors or anything just sends it twice
(if has answer plz tag me going for a cigg)
Send code
are there somehow two instances of the bot running'
no clue
regenerate the token, replace it in the code and see if it works
repl canโt run to instances of the same file at once
Maybe he has an extra process_commands()? If he has an on_message?
that could be a possibvility also
@commands.command(help = 'Add/Remove a members role!')
@commands.has_any_role("SALRP | High Staff Team","SALRP | Asst. Lead Developer","SALRP | Media Director","SALRP | Gang Management","SALRP | Business Management","SALRP | Manager Assistant","Discord Appeals Team","SALRP | Head of Support Team","Department High Command")
async def role(self, ctx, user : discord.Member, *, role : discord.Role):
if role.position > ctx.author.top_role.position:
return await ctx.send('**:x: | That role is above your top role!**')
if role in user.roles:
embed = discord.Embed(description= f"โ
**Successfully given {ctx.member.display_name}#{ctx.member.discriminator} {role}!**", color=discord.Color.green())
await ctx.send(embed=embed)
await user.remove_roles(role)
else:
embed = discord.Embed(description= f"โ
**Successfully removed {role} from {ctx.member.display_name}#{ctx.member.discriminator}!**", color=discord.Color.green())
await ctx.send(embed=embed)
await user.add_roles(role)```
i fixed it
but now this code doesnt work at all
what is this
dont mind the has_any_role
You need to change the token in the code
i did, it fixed
Ok and now that doesnโt work AT ALL?
Do you have an error handler?
no
The on_command_error
how do you load commands that are in this order
commands.moderation.mute
!d discord.ext.commands.has_any_role
@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.
Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.
This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
or like C:\Users\User\Desktop\Discord Bot\commands\moderation\mute.py
are you using cogs @slate swan
Ya
i do have an error handler actually
@role.error
async def role_error(self, ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('**:x: | You do not have permission to use this command!**')```
def setup(bot) -> None:
bot.add_cog(cog_name(bot))
Make sure it raises all the unknown errors
if isinstance(..., ...):
...
elif isinstance(..., ...):
...
else: # <- attention to this
raise error```
im confused
Show your error handler
@role.error
async def role_error(self, ctx, error):
if isinstance(error, MissingPermissions):
await ctx.send('**:x: | You do not have permission to use this command!**')```
Oh no
this?
wdym
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'moderation'
No documentation found for the requested symbol.
Listen for on_command_error and you don't have to create the handler for every command
when i try to do it like this
for foldername in os.listdir('./commands'):
for filename in os.listdir(foldername):
if filename.endswith('.py'):
bot.load_extension(f'commands.{foldername}{filename[:-3]}')
Wut
lol
It broke or smth
Yeah
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
Weird
what do your cogs and file structure look like?
!d discord.ext.commands.Bot.on_command_error
await on_command_error(context, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for command error.
Found it
You forgot a dot ig
bot.load_extension(f'commands.{foldername}.{filename[:-3]}')```
why not just put it in one cog?
hola
i actually dont know i find that its neat like this
Ok seems like that only belongs to bot class
what is some code in the file
So I am trying to make my bot detect if the amount of CAPS in a message is above 70%
But I cant figure out any way how
ok so bot can post directlink to mp4 and it embeds it as a viewable video, but how i can a viewable video from a link into a discord.embed?
the code in one of the moderation files?
yes
With the power of math we can 
so what should i do?
Lemme get a tutorial 4 you
okay but like in the mean time to fix the role command
i would imagine you subclass it with command, then create a cog file in the directory where you load all the commands, then you load all cog.py files in your load_cogs function i guiess
dawg
@pallid mango https://tutorial.vcokltfre.dev/tutorial/12-errors/
Okay, we've made it to part 12! Be forewarned, this is going a long one. This part is going to be about how you can make error handlers for your commands, like you saw briefly in the previous part about cooldowns.
u can just turn all that importing to one line with commas
ik
....
Looks like java imports but even more aids lmao
LMFAO
mAYBe
image stuff
โJust in caseโ lmao
๐
but why lmfao
idk
bad practice

@slate swan what code editor do you use
@commands.command(help = 'Add/Remove a members role!')
@commands.has_permissions(kick_members=True)
async def role(self, ctx, user : discord.Member, *, role : discord.Role):
removedembed = discord.Embed(description= f"โ
**Successfully removed {role} from {ctx.member.display_name}#{ctx.member.discriminator}!**", color=discord.Color.green())
givenembed = discord.Embed(description= f"โ
**Successfully removed {role} from {ctx.member.display_name}#{ctx.member.discriminator}!**", color=discord.Color.green())
if role.position > ctx.author.top_role.position:
return await ctx.send('**:x: | That role is above your top role!**')
if role in user.roles:
await user.remove_roles(role)
await ctx.send(embed=removedembed)
else:
await user.add_roles(role)
await ctx.send(embed=givenembed)```
it works when i dont include the embed
so what am i doing wrong with the embed?
is there any way to sort the the top 10 mongodb objects based on one field?
How does sending an embed work within views? Just send or edit a message with embed= embed object?
like get the top 10 objects by most number of trphies
Does mongo use SQL or some other interface?
nvm i figured it out lol
Ok ๐
#help-mushroom when someone is free
Embeds and views are both "attached" to a message, I don't get wdym by "embeds within views"
async def embed(ctx, *, query):
em = disnake.Embed(
color=0x00000,
description=
f"{' '.join(ctx.message.content.split(' ')[1:])}"
)
await ctx.send(embed=em)``` why this doesnt work
Don't you want to split the query instead?
So I am trying to make my bot detect if the amount of CAPS in a message is above 70%. And I canโt figure out a way to detect it, help pls kek
Hmm take this with a grain of salt but doesn't split spilts a string into a list ?
!e
string_ = "this a string"
print(string_.split(" "))
@final iron :white_check_mark: Your eval job has completed with return code 0.
['this', 'a', 'string']
@snow ibex yes
Yep
Hmmm all i can think of is regular expressions to figure it out not sure if it will work tho ๐
if message.content.upper() would convert the message to uppercase i believe. but idk how to check if a certain percent of it is upper. maybe regex like stealth said
rankings = mayy_bot_users.find().sort("trophies",-1).limit(5)
index = 0
for item in rankings:
it says motor object is not iterable
Alr
i'm trying to make a leaderboard
What do you even want to do
where tf is the motor object? unless im blind
No way I found out how to run aiohttp server inside of a bot
send embed with given text
It's their mongodb connection mb
use the query variable for that.
You didn't await
oh ok
pleaseeee check dms
๐ฅบ
let me see if it works now
@commands.command(help = 'Add/Remove a members role!')
@commands.has_any_role("SALRP | High Staff Team","SALRP | Asst. Lead Developer","SALRP | Media Director","SALRP | Gang Management","SALRP | Business Management","SALRP | Manager Assistant","Discord Appeals Team","SALRP | Head of Support Team","Department High Command")
async def role(self, ctx, user : discord.Member, *, role : discord.Role):
if role.position > ctx.author.top_role.position:
return await ctx.send('**:x: | That role is above your top role!**')
if role in user.roles:
await user.remove_roles(role)
removedembed = discord.Embed(description= f"โ
**Successfully removed {role} from {ctx.member.display_name}#{ctx.member.discriminator}!**", color=discord.Color.green())
await ctx.send(embed=removedembed)
else:
await user.add_roles(role)
givenembed = discord.Embed(description= f"โ
**Successfully given {ctx.member.display_name}#{ctx.member.discriminator} {role}!**", color=discord.Color.green())
await ctx.send(embed=givenembed)```
it says typeerror motor object cannot be used in await expression
i guess its not a coroutine?
embed isnt working, everything else works plsss help
How can I create an event that every time someone presses a button something happens?
Have you removed that local error handler or added errors raising
on_button_click
Depends on the library you use
no because it isnt nessecary is it?
It is eating your error
@bot.event
async def on_button_click(interaction):
interaction prolly through a view
This is low level event that is not recommended to use in most of cases
It probably is just taking your error and not outputting it
but like what would be the error here lol
Typically you just subclass the View
so what do i do
Hmm still try to remove the handler
oof
We don't know, that's why you should raise all unknown errors
u guys were right
Or make it spit out the error
discord, discord components and discord.ext I guess ๐
i removed it and it spit this
Traceback (most recent call last): File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'member'
Follow my advice, migrate to a dpy fork and don't use that lib
Hmm isnt it ctx.Member?
It is crazy inconvenient
Dpy isn't coming back which is sad tbh
Disnake, nextcord, not the discord_components for god's sake
ctx.author
Should be
Oh yeah author forgot about that
but where?
you're looking for ctx.author
is it possible to get data from another task?
meaning the following
task.loop
task1_data = get https://api1234/abcdefg
return
task.loop2
if task1_data < 0:
aaaa
i want to identify the person i gave the role to
Replace all the ctx.member with ctx.author
https://github.com/an-dyy/Rin/tree/master/examples/components What do you guys think about these two examples
hey guys how can i make the bot delete all the messages of a specific channel
Why not add a command example?
Cause I haven't added commands yet
Commands will most likely use the builder stuff as well though
Wouldn't it be easier to store the channels name and just delete and remake it?
Or I'm just forgetting about some easy way to delete all messages
idk am still learning about discord bots
Clone the channel and delete the original
Usually you can't just purge all the messages
wanted to make it like a command
like !clear
!d discord.TextChannel.purge if it doesnt have messages that are older than 2 weeks or clone
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting botโs messages...
Yeah 100 is the cap
ah i see
!d discord.TextChannel.clone
await clone(*, name=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Clones this channel. This creates a channel with the same properties as this channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.
New in version 1.1.
Now that's handy
It will create a new channel with same settings but with no messages in it
ah thats cool thanks
Typically this is used for deleting all messages
I heard mention that text/numerical inputs will be possible using Views - is that already implemented or still yet to be implemented?
But don't forget that ID of the cloned channel will not be the same with original
i fixed it by adding async to the for loop
Not yet
At least I haven't seen any announcements regarding it
Ah it was an AsyncIterator cool
Understood - that will be a very useful tool when it is available!
I agree. I find wait_for is extremely inelegant
Yeah, I will be using it for a full settings panel / suggestions / submission architecture once possible
Pretty useful for inline events though
Any better ways to run the aiohttp server simultaneously with the bot application?
from aiohttp import web
...
@bot.event
async def on_ready():
await web._run_app(app)```
@vale wingam just courius what does ur server as http?
Voting rewards
ah cool beans
How are you using aiohttp with the server if you don't mind my asking? What are the advantages of this?
Advantages over what
Galaxygate has good servers for fair price
Free hosting doesn't exist in my opinion
Check pins
I don't have a point of reference - I want to understand why you are trying to use it that way, what it adds to your application
Unless you know some ways ๐
@compact ruinvultr/digitalocean *
๐ณ
@client.command(aliases=['playerid', 'loid', 'server'])
@commands.has_permissions(administrator=True)
async def pid(ctx, pids):
if not pid:
await ctx.send('<@{}>, Please Specify A In-Game Player ID!')
return
resp = rq.get('http://'+config.serverIP+'/players.json')
for _ in resp.json():
if _['id'] == int(pids):
pembed = discord.Embed(title='PlayerID Query Successful!', color=discord.Color.dark_green())
pembed.add_field(name='Steam Name : {}\nIn-Game ID : {}'.format(_['name'], _['id']), value='Ping : {}'.format(_['ping']), inline=False)
[pembed.add_field(name=args.split(':')[0].capitalize(), value=args.split(':')[1], inline=False) for args in _['identifiers']]
await ctx.send(embed=pembed)
else:
pass```
Traceback (most recent call last): File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I am guessing i buy this one?
Print the response status code
me?
Yeah
wdym
When you make a request to API, it returns some content and a status code
If the status code isn't 2xx (200 if everything went totally fine), something is wrong
Exen, what are you doing specifically with the web module of aiohttp? Why do you need a server in your use case rather than just a session?
I run my API with it
A better way would be hooking the web running inside of your start method bound to your bot
Otherwise you would start the server more than once
As on_ready is dispatched multiple times throughout life-time

Could you give a rough overview of how that is working? I just want to understand more what it is doing that simple aiohttp requests don't do
Traceback (most recent call last): File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/home/runner/SALRP/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Got it
Add {} in yr JSON file
He's making a request lol
Hunter I pushed the components refactor ๐
Don't tell me u pushed the context manager one 
๐๏ธ ๐๏ธ
It's not that bad bro
๐ lemme see
Menus look better
Don't u think the builder should be inside the if statement?
It would make it look bad since it adds an extra indentation level
I cherry picked it for the example
Ah okay. Since u r literally making buttons whenever a message is sent
BTW, I need to specify the row number in ActionRowBuilder?
As in?
I'm not really sure what that means
Since there can be 5 rows for components
Like a message supports upto 5 rows
Suppose I want to add 1 button to row 1, then 2 to row 2 and so on
Yea, you just do multiple builders
Tf :stare:
Why not instead add it as a kwarg in the button deco?
Optional kwarg
Would be much neater that way tbh
I must be not understanding what you mean
do ```py
partial = rin.PartialSender(self, 780449307891204166)
with rin.ActionRowBuilder() as builder:
with rin.SelectMenuBuilder() as menu:
menu.option("Option 1", "Foo", description="The first option.")
menu.option("Option 2", "Bar", description="The second option.")
menu.option("Option 3", "Baz", description="The third option.")
menu.option("Option 4", "Stuff", description="The fourth option.")
menu.option("Option 5", "More stuff", description="The fifth option.")
menu.option("Option 6", "woah", description="The sixth option.")
@menu.set_callback()
async def callback(interaction: rin.Interaction, menu: rin.SelectMenu) -> None:
await interaction.send(f"{menu.values}")
builder.add(menu)
with rin.ActionRowBuilder() as builder2:
@builder2.button("foo1", rin.ButtonStyle.PRIMARY)
async def button(inter, button):
await inter.send("FOO1")
@builder2.button("foo2", rin.ButtonStyle.SUCCESS)
async def button(inter, button):
await inter.send("FOO2")
@builder2.button("foo3", rin.ButtonStyle.DANGER)
async def button(inter, button):
await inter.send("FOO3")
await partial.send("foo", rows=[builder, builder2])
Ah, didn't notice the rows kwarg
My bad, sorry
But yea, I like the implementation tbh
Although, It would be super easy to add a splice method to the action row builder
so you can do a chimera action row sorta
Mind giving me an example?
Basically all implementations would be in a single context manager/action row but before the PartialSender sends it, it will split it
Ah yea
Also it seems like you cannot send a button and a select menu in the same row?
Nope
๐
A select menu takes a whole row
I guess that makes sense
I plan on making slash commands soon and they will follow the same builder concept
Hey BTW, if I wanna add it in a class, then I will have to make a separate method and do all the context manager stuff inside it and then call the method in the init or smth?
iirc, you cannot use a context manager outside a method in a class
The context manager is optional, but without using it you need to cache all the components manually
Since I cache the custom_id to component
Ah
Then call that later in INTERACTION_CREATE
Basically this but, somewhere do builder.cache_all()
SelectMenuBuilder's context manager doesn't do anything right now so still figuring out what to do in there
Rip, would be better if u think about the class implementation too. Since people who would want to make a paginator class will have to do this all stuff (make buttons and stuff) inside a class
Like subclassing the ActionRowBuilder?
Hmm, that's a possibility. But then, how would I make buttons inside it?
Like after subclass ui.View, I can simply use the deco or self.add_item
Yea, that's super easy to do. I just need to make a metaclass and a decorator to act as a marker
Ah gotcha
BTW I like the implementation. Seemed a little off in the start since its new, but a different idea!
O, would be fun to see people hating loving your implementation
I'll just do full sweep and support them all
Cool!
Well, the only thing that will be different is the construction of the slash commands
The builder class will make it easier to register commands
Ah okay
The callback stuff with the custom args, I'll have to make custom typehints
where can i add this link?
Or use typing.Annotated
Imagine dpy server people seeing your implementation ๐
It's not that bad ๐
i have an error now when this same bot i made has been working idk why
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'Embed'
embed=discord.Embed(title="Add Plxsma", url="https://discord.com/oauth2/authorize?client_id=939892090316423171&scope=bot&permissions=534723951712", color=discord.Color.magenta())
await ctx.send(embed=embed)
OAuth2 > General
await message.add_reaction("Flushed")```
anyone know how to correctly format this comes up as an error for me
It ain't but would seem weird and alien to them
You have a command named discord
My whole wrapper is already alien bro
":flushed:"
Best of Luck!!!
I remember when mine got verified. Was anxious
thanks
oh alr thnx
Yea, but you got some good ideas for implementations
Wot
Verification, it takes a lot of time
U sent another bot for verification
what difference does that make
\๐ณ
Copy and paste that emoji directly
oh
Guess I'll add application commands today
๐๏ธ ๐๏ธ
Yes, you can do it and let's hope u don't lose motivation again
The last time I made changes/open the source code of my discord bot was.... 2 months ago or smth
newmsg = msg.split('$schn ',1)[1]
print(newmsg)
message.channel.edit(newmsg)```
last question for some reason it's saying "newmsg" is two arguments but when I print it's only 1 and it won't change the channel's name
I'm confused
I feel that. I was coding a project with a friend of mine but haven't even opened up the repo of that project or any other since 2 months or smth
wym two args?
I'm just making a basic admin commands bot rn
it's saying for the message.channel.edit() that it needs 1 arg but gets 2
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
oh I'll go back to an old idea of mine. ```py
with AppCommandBuilder(type=AppCommandType.MESSAGE) as demo:
# do stuff
rin.export(demo, guild_ids=[])
tried that didn't work for some reason
didn't show any errors
rin.export?
show
it's just the same as this but with message.channel.name = newmsg
huh?
I'll try t again ig
message.channel.edit(name=newmsg)
OOOOH
Because if you just did the builder regularly, imagine ```py
bot = rin.GatewayClient(...)
with AppCommandBuilder(type=AppCommandType.MESSAGE) as demo:
# do stuff
alr alr
rin.export would just act as an attacher ig
Or I can get rid of export and use the context manager to attach, this means bot would be passed to AppCommandBuilder
I could also do syncing in there
Okay so tbh I don't understand much about all this stuff, but why not add the export method to the Message command class, and add the guild ids kwarg to that. So it will look something like
with AppCommandBuilder(...) as whatever:
@whatever.command(name=..., aliases=..., guild_ids=...)
async def whatever_part_2(...):
. . .
whatever_part_2.export()
or if u can, attach the command automatically on exit, so that it works without doing the export thingy
I mean, I don't really know much about the Commands API, so I cannot really help u with the implementation, sorry
That would work. But I also want to get rid of all that decorator stuff cause it gets to bulky, it would probably look close to this, but instead setting attributes inside of the context manager itself
Iโll make it a generic class so I can pass command type, thus supporting more than slash commands in one builder
Well u will still be needing the deco, since people can opt to add different app commands to different guilds for testing, that's why I specially focused on the guild_ids kwarg in the deco
with open('config.json', 'r') as f:
config = json.load(f)
def check():
if os.path.exists("/config.json"):
with open("/config.json", encoding="utf-8") as infile:
token = json.load(infile)
return token['bot_token']
def inputtoken():
token = input(pyfade.Fade.Horizontal(pyfade.Colors.col, f"Input Token: "))``` I want to input my bots token into a console that stores it in a json file, then uses that token, but when console opened again, it uses the token already stored in the json file, how do i do that?
The decorator should only be needed to mark a commands callback, guild ids, etc can be set via the context manager
This is to get rid of the bulky decorators that I hate so much in other wrappers
Ah, u mean the people can add different ctx managers for different guilds?
Just like for different rows?
Hey I need help with embeds
remove the check
I need your question
Hello guys! im coding a Discord Bot that has to do with preventing Discord DM Spamming. I need to import a variable from one of my cogs to another one of my cogs, any idea how i would do this?
Uhh not really but close ig? Youโll see when I push the first implementation
Ah okay cool
Iโll refactor it after that if you want to suggest things
em = discord.Embed(title=f"{user}\'s Profile", color = discord.Color.random(), url = user.icon.url)``` How do I make the image of the Embed the event caller's profile picture
the whole funciton or just def check():
!d disnake.PublicUserFlags.spammer u will want to use this too
Returns True if the user is marked as a spammer.
New in version 2.3.
the whole func
!d discord.Embed.set_author
the url and icon_url
with open('config.json', 'r') as f:
config = json.load(f)
def inputtoken():
token = input(pyfade.Fade.Horizontal(pyfade.Colors.col, f"Input Token: "))
filename = 'config.json'
with open(filename, 'w') as file_object:
json.dump(token, file_object)```now what @maiden fable ?
Thank you ๐
Nothing
it errored
!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!
Tbh, this is more of a general Python question. Would be better to go to #โ๏ฝhow-to-get-help
"token" = ""
}
``` this errored
what??
in the json file
replace = with :
em.set_author
What
HOW DO I GET THE USERS ICON URL
!d discord.Member.avatar.url
No documentation found for the requested symbol.
Wait what?
this was errored
Bru
what is !bot var
with open('config.json', 'r') as f:
config = json.load(f)
def inputtoken():
token = input(pyfade.Fade.Horizontal(pyfade.Colors.col, f"Input Token: "))
filename = 'config.json'
with open(filename, 'w') as file_object:
json.dump(token, file_object)``` i want it to make it so that when no token in config.json is detected, it prompts token = input
Read the embed
if token == "" or smth
no, like to share code with other people very quickly
pastebin
repit?
nope
replit
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
(:
with open('config.json', 'r') as f:
config = json.load(f)
def inputtoken():
token = input(pyfade.Fade.Horizontal(pyfade.Colors.col, f"Input Token: "))
filename = 'config.json'
with open(filename, 'w') as file_object:
json.dump(token, file_object)```is this getting better @thin wolf
@maiden fable
@whole sparrow help me
BTW u should ask the question in a help channel
bruh lol
It's more of a general Python question
hi, does anyone know why it gives me an empty message error when sending an embed (it worked until recently)
How do you send your embed?
await ctx.send(embed=emebed)
it works on one of my bots, but not the other one... lol
Ok how do you define embed?
embed=discord.Embed
embed = discord.Embed(
colour = discord.Colour(int('00FFFF', 16))
)
embed.add_field(name='Server: ', value=f'{item["Name"]}', inline=False)
embed.add_field(name='Server Population: ', value=f'{item["NumPlayers"]}', inline=False)
await ctx.send(embed=embed)```
holy
Huh
true but the issue here is that it wont send (the code works), maybe discord changed something regarding non bot tokens?
One or both of your item["name"] and item["NumPlayers"] are returning an empty string or something

@pliant gulch What is the intent of that package?
What package
oh my wrapper
I guess the intent is to make something sleek? Different, and cool to use?
Also try to be as type-safe as possible with a strong emphasis on type safety
What is the wrapper intended to in terms of function?
For native API use I'd say, but its also extensible with custom events, collectors, etc
Andy ๐
(hes trying to hack you with his discord wrapper!!)
no havenโt looked at the repo recently
look at these two
yes
ye the code looks rlly clean
Don't look at the internals if you wanna keep that opinion ๐
๐๐ฟ
https://github.com/an-dyy/Rin/blob/master/rin/models/message/components.py ๐๏ธ ๐๏ธ refactored last night but ocd making me wanna redo the whole thing
lmao
This is quite cool. I'm planning to be doing a menu system via views in the near future
๐ณ
So take for example the following, I have a menu which at the top level has broad options like Help | Settings | Stats as an example
how do i set a bots About Me?
and when you click into Settings it edits the message embed and all the buttons to be stuff like Cypher Settings | User Preferences etc
Hi Andy, baron and binds
hello
Discord developer portal app for your bot
and when you click Cypher Settings it has things like Word Count and Mode, when you click Word Count it displays the current value and has a + / - and ? which takes an input
how well would your wrapper support that sort of use case? @pliant gulch
Support as in the pros my wrapper would have for that?
kinda like menus inside menus?
Yeah, how would your wrapper handle that sort of more complex menu and component structure?
Yeah, menus inside menus precisely
that would be pretty cool
Easy as hell I would say, at least easier than what forks have. And providing it in a sleek way
Does it already do that?
For an example take disnakes select menu https://github.com/DisnakeDev/disnake/blob/305c7cd31b21de535d390aa77ee1dc2612fbcbc1/examples/views/select/dropdown.py#L10-L24
Its gonna look bulky as hell with this, I'm sure with mine it would be a lot more clean
So how would you do the same sort of thing in yours? Is this already supported?
Well, the builder only builds the select menu. Your stuff would be all done inside of the callback
so it'd be multiple builders yes?
Maybe you could have something like
The callback you'd do some flow control with the values selected, if a certain value is selected oyu can make a new builder
You also aren't forced to use the ctx manager, and that lowers indentation count
I'd probably have a builder dict
that has things like settings_builder, help_builder, cypher_settings_builder etc
class Menu(rin.ActionRowBuilder, complex = True)``` ?
Hmmmm yea I can imagine that would be pretty easy enough to do with what I have right now
and complex to true enables the Nested nature
That's excellent. How do I get started? I'll give it a try and perhaps contribute once I understand the featureset better
One menu per action row right?
oh, uhhhhh

