#discord-bots

1 messages ยท Page 807 of 1

slate swan
#

A

#

Ok

slim ibex
#

๐Ÿ—ฟ

slate swan
#

make a ripoff of discord?

slim ibex
#

๐Ÿ’€

slow fog
#

Lmao

maiden fable
slate swan
stone beacon
#

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

slate swan
#

they mean name of the user who deleted the message

#

which can be some moderator other than the user itself

stone beacon
#

Ohhh

#

Yea u can't get that as far as ik

ebon island
#

Are buttons added simultaneously to messages or are they delayed one at a time like how reacts are?

stone beacon
#

Audit logs doesn't really show that effectively

slate swan
#

yea, audit logs is an option, but that doesnt work always

slim ibex
#

ye i was thinking the same thing @stone beacon but i realized it wouldn't work

slate swan
#

.send() takes a view kwarg, which is a discord.ui.View with all components

ebon island
#

Ooh, excellent. Do you have an easy way to link info/documentation regarding using those?

slate swan
#

!d discord.ui.View

unkempt canyonBOT
#

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.
slate swan
#

And how to make the file name written when deleting a file / photo.

#

?

tidal hawk
#

What package or how are those banner created (XP system)?

manic wing
#

would be pillow

final iron
tidal hawk
#

Okay!

spring flax
final iron
spring flax
#

I mean you shouldn't just start using pillow and the first thing you do shouldn't be that you should start simple

ebon island
#

How would you accomplish that with Pillow? What would the process look like?

spring flax
#

!pypi pillow

unkempt canyonBOT
final iron
slate swan
#

And how to make the file name written when deleting a file / photo?

#

Like here for example

native wedge
#

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)

slim ibex
#

methods are functions in a class

maiden fable
#

๐Ÿ‘€

#

Imagine nitro links

native wedge
#

Thats what i meant

slim ibex
#

well then you have it down. what did you not understand before?

native wedge
#

No its just i didnt understand OOP

#

I watched a Corey Schafer video

slim ibex
#

you shoudl have a solid understanding of OOP before doing dpy

native wedge
#

I know

#

Because from the docs all I see are classes

#

Its really my problem that I couldnt understand those

slim ibex
#

oh ok

full lily
slow fog
native wedge
stuck flare
native wedge
#

I was asking if i understood how the docs worked to make sure i wasnt making stuff u

slate swan
stuck flare
slate swan
#

I feel like a dummy

native wedge
slim ibex
#

object oriented programming'

slate swan
#

And didn't know

slim ibex
#

uhh

native wedge
slate swan
#

Will do

slim ibex
#

thats why you learn python forst

native wedge
#

This is what I used

stuck flare
native wedge
#

Even though im dont understand 100% at least i know more than i did before watching

final iron
#

Someone who is actually learning python before making a discord bot

native wedge
#

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

tacit knoll
#
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"![yes](https://cdn.discordapp.com/emojis/923454161666863174.webp?size=128 "yes") 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"![no](https://cdn.discordapp.com/emojis/923454180427980821.webp?size=128 "no") **Invalid Syntax**, Use `{prefix + helplist[ctx.command.name][2]}`")
        else:
            await ctx.respond(f"**![no](https://cdn.discordapp.com/emojis/923454180427980821.webp?size=128 "no") {error}**")


def setup(bot):
    bot.add_cog(ConfigurationSlash(bot))
#

anything wrong?

slate swan
#

what's the error

native wedge
kindred drum
#
                            
                            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
slate swan
#

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

native wedge
slate swan
tacit knoll
slate swan
#

User object has no roles attribute, you prob need a Member obj

slim ibex
#

it takes time @tacit knoll

kindred drum
tacit knoll
tacit knoll
#

should register after 10 minutes of waiting im assuming?

slate swan
slate swan
slate swan
kindred drum
#

guild not defined

slate swan
#

that was an example, you would be using your own Guild object ( ctx.guild for you)

kindred drum
#

await ctx.guild.get_member(id)?

slate swan
#

you dont need to await it

kindred drum
#

AttributeError: 'Member' object has no attribute 'role'

slate swan
tacit knoll
#

how would i check?

#

to make sure

slate swan
#

print(bot.cogs) and see if the cog is in the list

tacit knoll
#

yes its the correct name

slate swan
#

so, its loaded

tacit knoll
slate swan
#

wait what library is that?

tacit knoll
#

pycord

#

basically a fork of

slate swan
slate swan
#

well they say they use pycord

tacit knoll
#

yes

#

which is being maintained

slate swan
#

its understandable by their code that they use discord.py,by which library i meant what fork since all forks have different slash impls

oak warren
#

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  )
slate swan
#

why dont you just bot.user instead of fetching it

oak warren
#

bot.user > bool

#

not partialappinfo

slate swan
final iron
slate swan
unkempt canyonBOT
final iron
#

!d discord.user.ClientUser

unkempt canyonBOT
#

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.
slate swan
#

its a discord.User with some additional functionalities

oak warren
#

ok but it doesnt work that way

prime ibex
oak warren
#

i am fetching a different bot

#

not the same one

#

so it wont work that way

tacit knoll
#

for some reason it works without the cogs

prime ibex
slate swan
prime ibex
#

In that cog

tacit knoll
#

it works like this

slate swan
#

not embedded_application

tacit knoll
#
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"![yes](https://cdn.discordapp.com/emojis/923454161666863174.webp?size=128 "yes") Changed the server prefix to {prefix}")


def setup(bot):
    bot.add_cog(ConfigurationSlash(bot))
#

this doesnt?

slate swan
#

what version of pycord you are on?

tacit knoll
#

2.0.0b1

oak warren
#

because the only way is create_invite

slate swan
#

what do you want to do?

slate swan
native wedge
tacit knoll
#

any idea what the error is?

ebon island
#

What if you want a discord Button which can be clicked repeatedly and for example increment a value?

native wedge
ebon island
#

Why is everyone referring to pycord now? Just a week or so ago it was all about Disnake, what's the story there?

slate swan
#

noone is

ebon island
#

๐Ÿ˜‚

slate swan
#

they already use pycord so we r helping them with the library not registering a slash command shit_no

ebon island
#

Haha oof

slate swan
#

laufs in disnake+hikari

ebon island
#

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?

maiden fable
#

Use rin, ezzz

slate swan
#

client.run starts how do i stop is there something like client.stop?

#

client.close(), its a coro

#

thanks

slate swan
maiden fable
slate swan
#

what library are you using?

maiden fable
#

!d discord.ui.Button.callback can also be used, but preferred is to use the first way

unkempt canyonBOT
#

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.
slate swan
unkempt canyonBOT
#

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()```
slate swan
#

the confirm function is the callback of the button

ebon island
#

Excellent! Thank you ๐Ÿ™‚

slate swan
#
time.sleep(1)
client.close()```
drowsy condor
#

is it possible to make on_message_delete and on_message_edit not affect other bots?

ebon island
#

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 ๐Ÿ™‚

grim oar
tacit knoll
#

u need to load the cog before on_ready

slate swan
#

yeah bots dont execute code under .run() method

slate swan
prime ibex
slate swan
#

i mean you can but dont

grim oar
slate swan
#

on_ready can go off multiple times

slate swan
slate swan
#

ill do it myself๐Ÿ˜พ๐Ÿ˜ผ

#

jk

ebon island
#

What do you mean when you say that? Could you share a small example?

slate swan
#

you mean stuff to configure settings of your bot per server right?

prime ibex
ebon island
#

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

drowsy condor
#

is it possible to make on_message_delete and on_message_edit not affect other bots?

prime ibex
#

Like ignore those bots?

slate swan
drowsy condor
#

What is it "Wdym"

ebon island
#

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?

prime ibex
#

What do you mean = wdym

#

Lol

drowsy condor
#

Oh

slate swan
drowsy condor
#

Sorry I'm just stupid

#

@slate swan How

#

?

ebon island
#

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?

slate swan
#

where message is a discord.Message object

ebon island
#

Excellent. Thank you! ๐Ÿ™‚

tidal hawk
#

How to create multiple on_member_join() listeners?

maiden fable
#

In a cog?

tidal hawk
#

Mhm

slate swan
#

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

tidal hawk
#

oh thanks

drowsy condor
#

async def on_message_edit(before, after):
if message.author.bot:
return
channel = bot.get_channel(935160414965211179)

#

So?

slate swan
#

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 ั‚ะฐะบ?

slate swan
#

What?

#

I want to make these events not react to other bots

final iron
#

That makes it so it doesn't react to other bots

final iron
jagged root
#

how can i make my bot answer when it gets pinged

slim ibex
#

if message.author.bot != True?

jagged root
#

idts

slim ibex
#

no not u

jagged root
#

ok

jagged root
#

@slim ibex

slate swan
unkempt canyonBOT
#

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.

slate swan
#

use this to check if your bot user is mentioned, in an on_message event

slim ibex
jagged root
#

hm

slim ibex
#

it would be in an on_message listener

jagged root
#

k

slim ibex
slate swan
slim ibex
#

ah

jagged root
#
async def on_message(message):
    if client.user.mention in message.content.split():
        await client.say("hey")```
#

could this work

slate swan
jagged root
#

shi

slim ibex
#

private context ๐Ÿ—ฟ

slate swan
#

thats jishaku and it uses _ctx for the current context

slate swan
#

but, if you replace client.say with message.channel.send, it "sometimes" works

jagged root
#
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

slate swan
#

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'
ebon island
#

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'
slate swan
#

nah, they have it right

slate swan
ebon island
#

So you don't need to pass ctx then and instead pass interaction?

#

disnake

slate swan
#

Doesn't matter if it's a fork

#

!d discord.Interaction interaction Variable there is this object

unkempt canyonBOT
#

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.
ebon island
#

I have disnake aliased as discord

#

works when passing interaction ๐Ÿ™‚

tender estuary
slate swan
#

No they are different things

#

!d discord.ui.button

unkempt canyonBOT
#

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.
slate swan
#

The method they used needs a small one

ebon island
#

I removed discord and then installed disnake as discord

slate swan
#

But you didn't found the complete thing :)

ebon island
#
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 ๐Ÿ™‚

slate swan
#

the ui.Button is for a class in params

ebon island
#

What is the best method storing/editing an embed for the base message within a view?

gaunt glen
#

hello

slate swan
unkempt canyonBOT
#

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()```
ebon island
#

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

slate swan
gaunt glen
#

i codin my first bot with phy but i not undersent

#

whay?

velvet tinsel
#

because

gaunt glen
velvet tinsel
#

...

#

๐Ÿคฆ FROM not for

#

also

ebon island
#

first of all, don't have your bot key in open text, that isn't a good practice

velvet tinsel
#

thanks for the token ๐Ÿ‘

#

๐Ÿ˜„

ebon island
#

as everyone in here can see your key, I would suggest you generate a new token

velvet tinsel
#

and it should also be a string

gaunt glen
#

mince

#

pas grave

velvet tinsel
#

pas grave?

gaunt glen
#

me'en fiche

velvet tinsel
#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

gaunt glen
#

ok sorry

velvet tinsel
#

also, generate a new token

gaunt glen
#

thats a test bot

velvet tinsel
cold sonnet
#

I'm kinda getting a stroke

velvet tinsel
#

you may just be running a command then suddenly, you realize you didn't code it!

velvet tinsel
ebon island
#

yeah, literally with that token anyone can make your bot send commands

cold sonnet
gaunt glen
#

I know but it's just a test

ebon island
#

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

velvet tinsel
ebon island
#

it is a good practice even with a test bot to keep that information safe, using environment variables is a good practice

#

lmao

velvet tinsel
#

time to screw some people

#

mwahahaha

I'm unstoppable

slate swan
velvet tinsel
ebon island
#

why not just spawn tasks every 0.1 seconds and send a new message, only 100 messages is weaksauce, let's go to infinity! ๐Ÿ˜„

velvet tinsel
#

(yes, I know I'll get ratelimited)

#

...

velvet tinsel
ebon island
#

we were trying to demonstrate to a user why you shouldn't share your key

velvet tinsel
#

okimii was too scared to 1v1 me smh

gaunt glen
#

you talk about me

velvet tinsel
slate swan
ebon island
#

yes, we were trying to demonstrate why sharing your key is a bad idea

velvet tinsel
slate swan
#

!ot

unkempt canyonBOT
velvet tinsel
slate swan
velvet tinsel
#

... ๐Ÿ˜

slate swan
#

dek join the akeno server

velvet tinsel
#

how to make discord bot

velvet tinsel
slate swan
gaunt glen
#

ok we will see but given the connection it will crash

velvet tinsel
slate swan
#

lol

velvet tinsel
#

I'm doing a chemistry ๐Ÿ˜ฆ

slate swan
#

nice

velvet tinsel
#

I can't complain much

#

chemistry is my favorite science

#

physics ๐Ÿฅฑ

slate swan
#

!ot

unkempt canyonBOT
slate swan
ebon island
#

in your above code

#

it should be from not for

#

eg:

from discord.ui import View
gaunt glen
snow ibex
#

bro you just leaked your token

#

@gaunt glen

gaunt glen
#

yes

#

sorry

snow ibex
#

you leaked your token

vale wing
#

Regenerate it

snow ibex
#

also make sure that the token is surrounded with "

gaunt glen
#

yes

gaunt glen
#

thanks

velvet tinsel
velvet tinsel
slate swan
velvet tinsel
slate swan
velvet tinsel
#

OH

#

oh yeah

slate swan
gaunt glen
slate swan
#

fetch_user needs to be awaited

velvet tinsel
#

pithink sor

slate swan
#

should i name myself 'pep8 abuser' pepe_blush

snow ibex
#

you wont ๐Ÿ˜”

sinful ferry
#

fwyb

snow ibex
#

what?

sinful ferry
snow ibex
# sinful ferry fwyb.

man english isnt my firs language i dont know these shortenings i learned wb last day lmao

snow ibex
#

ah

#

i see bro thanks bro

sinful ferry
#

yw

#

and always remember

#

fwyb.

slate swan
#

!ot

unkempt canyonBOT
sinful ferry
#

bro

honest vessel
#
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)
honest vessel
#

just an int

slate swan
honest vessel
#

like guild_id = 12356768986

slate swan
honest vessel
#

@slate swani figured it out, i need like something that tells bot is ready

slate swan
snow ibex
slate swan
#

cause before that the cache would be empty

honest vessel
#

so whats the varaible for put a wait_for_bot or something

#

in a function

slate swan
#

!d discord.Client.wait_until_ready

unkempt canyonBOT
#

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.
honest vessel
#

thanks bud

snow ibex
snow ibex
manic wing
snow ibex
honest vessel
snow ibex
#

np

honest vessel
#

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

pallid mango
#

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

honest vessel
#

(if has answer plz tag me going for a cigg)

median flint
#

Send code

slim ibex
pallid mango
#

no clue

slim ibex
#

regenerate the token, replace it in the code and see if it works

median flint
#

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?

slim ibex
#

that could be a possibvility also

pallid mango
#
  @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

slim ibex
#

wtf

#

holy fucking shit

pallid mango
#

but now this code doesnt work at all

slim ibex
#

what is this

pallid mango
#

dont mind the has_any_role

median flint
#

You need to change the token in the code

pallid mango
median flint
#

Ok and now that doesnโ€™t work AT ALL?

pallid mango
#

no

#

no errors or anything

#

is my indenting wrong or something?

vale wing
#

Do you have an error handler?

pallid mango
#

no

vale wing
#

The on_command_error

slate swan
#

how do you load commands that are in this order

commands.moderation.mute

slim ibex
#

!d discord.ext.commands.has_any_role

unkempt canyonBOT
#

@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")
slate swan
#

or like C:\Users\User\Desktop\Discord Bot\commands\moderation\mute.py

slim ibex
#

are you using cogs @slate swan

slate swan
pallid mango
#
  @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!**')```
slim ibex
#
def setup(bot) -> None:
  bot.add_cog(cog_name(bot))
vale wing
pallid mango
#
def setup(bot):
    bot.add_cog(Mods(bot))```
#

like so ^

vale wing
#
if isinstance(..., ...):
    ...
elif isinstance(..., ...):
    ...
else: # <- attention to this
    raise error```
pallid mango
#

im confused

vale wing
#

Show your error handler

pallid mango
#
  @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!**')```
vale wing
#

Oh no

pallid mango
#

this?

vale wing
#

Why is it local omg

#

Just create a global one

pallid mango
#

wdym

slate swan
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

vale wing
#

Listen for on_command_error and you don't have to create the handler for every command

slate swan
#

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]}')

vale wing
#

Wut

slim ibex
#

lol

vale wing
#

It broke or smth

median flint
#

Yeah

vale wing
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

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.
vale wing
#

Weird

slim ibex
median flint
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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.
median flint
#

Found it

vale wing
slim ibex
pallid mango
#

hola

vale wing
#

It was shorter before

slate swan
vale wing
#

Ok seems like that only belongs to bot class

slim ibex
slate swan
#

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

honest vessel
#

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?

slate swan
slim ibex
pallid mango
vale wing
#

Lemme get a tutorial 4 you

pallid mango
#

okay but like in the mean time to fix the role command

slim ibex
#

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

pallid mango
#

because i must go soon but it is needed in my server

#

holy shot !

slate swan
#

mind the importing

#

lol

pallid mango
#

dawg

vale wing
pallid mango
#

u can just turn all that importing to one line with commas

slate swan
#

ik

pallid mango
#

....

vale wing
#

Looks like java imports but even more aids lmao

slate swan
#

LMFAO

vale wing
#

Are they all even used ๐Ÿ˜ณ

#

Like unused imports just flood your namespace

slate swan
#

mAYBe

slim ibex
#

why tf do u need io and all this other shit

#

its never used in the file

slate swan
#

โ€Just in caseโ€ lmao

slim ibex
slate swan
#

If he ever needed them

slim ibex
#

but why lmfao

slate swan
#

idk

slim ibex
#

bad practice

slate swan
vale wing
#

@slate swan what code editor do you use

pallid mango
#
  @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?

slate swan
#

is there any way to sort the the top 10 mongodb objects based on one field?

ebon island
#

How does sending an embed work within views? Just send or edit a message with embed= embed object?

slate swan
#

like get the top 10 objects by most number of trphies

vale wing
slate swan
vale wing
#

Ok ๐Ÿ‘

pallid mango
vale wing
jagged root
#
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
snow ibex
#

Don't you want to split the query instead?

slate swan
#

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

snow ibex
#

Hmm take this with a grain of salt but doesn't split spilts a string into a list ?

final iron
#

!e

string_ = "this a string"
print(string_.split(" "))
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

['this', 'a', 'string']
final iron
#

@snow ibex yes

snow ibex
#

Yep

snow ibex
slim ibex
slate swan
#
    rankings = mayy_bot_users.find().sort("trophies",-1).limit(5) 

    index = 0
  
    for item in rankings:

it says motor object is not iterable

slate swan
#

i'm trying to make a leaderboard

slate swan
slim ibex
#

where tf is the motor object? unless im blind

vale wing
#

No way I found out how to run aiohttp server inside of a bot

jagged root
slate swan
slate swan
slate swan
slim ibex
pallid mango
slate swan
#
rankings = await mayy_bot....```
pallid mango
#

๐Ÿฅบ

slate swan
#

let me see if it works now

pallid mango
#
  @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)```
slate swan
#

it says typeerror motor object cannot be used in await expression

slim ibex
#

i guess its not a coroutine?

slate swan
#

what's the mayy_bot_users variable?

#

collection

pallid mango
slate swan
potent summit
#

How can I create an event that every time someone presses a button something happens?

vale wing
slate swan
#

on_button_click

pallid mango
vale wing
slate swan
#
@bot.event
async def on_button_click(interaction):
vale wing
snow ibex
pallid mango
vale wing
#

Typically you just subclass the View

snow ibex
pallid mango
#

oof

vale wing
pallid mango
#

u guys were right

snow ibex
#

Or make it spit out the error

potent summit
pallid mango
#

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'

vale wing
snow ibex
#

Hmm isnt it ctx.Member?

vale wing
#

It is crazy inconvenient

snow ibex
vale wing
#

Disnake, nextcord, not the discord_components for god's sake

snow ibex
#

Oh yeah author forgot about that

pallid mango
rustic onyx
#

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
pallid mango
#

i want to identify the person i gave the role to

vale wing
#

Replace all the ctx.member with ctx.author

pliant gulch
ebon fox
#

hey guys how can i make the bot delete all the messages of a specific channel

pliant gulch
#

Commands will most likely use the builder stuff as well though

snow ibex
#

Or I'm just forgetting about some easy way to delete all messages

ebon fox
#

idk am still learning about discord bots

vale wing
#

Usually you can't just purge all the messages

ebon fox
#

like !clear

slate swan
unkempt canyonBOT
#

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...
snow ibex
#

Yeah 100 is the cap

ebon fox
vale wing
#

!d discord.TextChannel.clone

unkempt canyonBOT
#

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.
snow ibex
#

Now that's handy

vale wing
#

It will create a new channel with same settings but with no messages in it

vale wing
#

Typically this is used for deleting all messages

ebon island
#

I heard mention that text/numerical inputs will be possible using Views - is that already implemented or still yet to be implemented?

vale wing
#

But don't forget that ID of the cloned channel will not be the same with original

slate swan
vale wing
#

At least I haven't seen any announcements regarding it

slate swan
ebon island
#

Understood - that will be a very useful tool when it is available!

final iron
#

I agree. I find wait_for is extremely inelegant

ebon island
#

Yeah, I will be using it for a full settings panel / suggestions / submission architecture once possible

pliant gulch
vale wing
#

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)```
honest vessel
#

@vale wingam just courius what does ur server as http?

vale wing
#

Voting rewards

honest vessel
#

ah cool beans

ebon island
#

How are you using aiohttp with the server if you don't mind my asking? What are the advantages of this?

vale wing
#

Advantages over what

compact ruin
#

Guys what would you suggest for a no downtime discord bot host

#

paid or free idm

vale wing
#

Galaxygate has good servers for fair price

snow ibex
#

Free hosting doesn't exist in my opinion

slate swan
#

Check pins

ebon island
#

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

vale wing
honest vessel
#

@compact ruinvultr/digitalocean *

snow ibex
vale wing
pallid mango
#
@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)

compact ruin
vale wing
#

Print the response status code

pallid mango
vale wing
#

Yeah

pallid mango
#

wdym

vale wing
#

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

ebon island
#

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?

vale wing
#

I run my API with it

pliant gulch
#

Otherwise you would start the server more than once

#

As on_ready is dispatched multiple times throughout life-time

maiden fable
ebon island
#

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

pallid mango
#

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)

pallid mango
#

yea but it gives this error

#

so i think there is something else wrong

vale wing
maiden fable
#

Ah my bad

#

then print the response.text

pliant gulch
#

Hunter I pushed the components refactor ๐Ÿ™€

maiden fable
pliant gulch
#

๐Ÿ‘๏ธ ๐Ÿ‘๏ธ

#

It's not that bad bro

maiden fable
#

๐Ÿ‘€ lemme see

pliant gulch
#

Menus look better

maiden fable
#

Don't u think the builder should be inside the if statement?

pliant gulch
#

It would make it look bad since it adds an extra indentation level

#

I cherry picked it for the example

maiden fable
#

Ah okay. Since u r literally making buttons whenever a message is sent

#

BTW, I need to specify the row number in ActionRowBuilder?

pliant gulch
#

I'm not really sure what that means

maiden fable
#

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

pliant gulch
#

Yea, you just do multiple builders

maiden fable
#

Tf :stare:

#

Why not instead add it as a kwarg in the button deco?

#

Optional kwarg

#

Would be much neater that way tbh

pliant gulch
maiden fable
#

Uhhh lemme show u

#

!d discord.ui.button

pliant gulch
#

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])

maiden fable
#

Ah, didn't notice the rows kwarg

#

My bad, sorry

#

But yea, I like the implementation tbh

pliant gulch
#

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

maiden fable
#

Mind giving me an example?

pliant gulch
#

Basically all implementations would be in a single context manager/action row but before the PartialSender sends it, it will split it

maiden fable
#

Ah yea

pliant gulch
#

Also it seems like you cannot send a button and a select menu in the same row?

maiden fable
#

Nope

pliant gulch
#

๐Ÿ˜”

maiden fable
#

A select menu takes a whole row

pliant gulch
#

I guess that makes sense

#

I plan on making slash commands soon and they will follow the same builder concept

maiden fable
#

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

pliant gulch
#

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

maiden fable
#

Ah

pliant gulch
#

Then call that later in INTERACTION_CREATE

pliant gulch
#

SelectMenuBuilder's context manager doesn't do anything right now so still figuring out what to do in there

maiden fable
#

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

pliant gulch
#

Like subclassing the ActionRowBuilder?

maiden fable
#

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

pliant gulch
#

Yea, that's super easy to do. I just need to make a metaclass and a decorator to act as a marker

maiden fable
#

Ah gotcha

#

BTW I like the implementation. Seemed a little off in the start since its new, but a different idea!

pliant gulch
#

Slash commands are gonna look somewhat like this too :^)

#

Application commands*

maiden fable
#

O, would be fun to see people hating loving your implementation

pliant gulch
#

I'll just do full sweep and support them all

maiden fable
#

Cool!

pliant gulch
#

The builder class will make it easier to register commands

maiden fable
#

Ah okay

pliant gulch
#

The callback stuff with the custom args, I'll have to make custom typehints

slate swan
#

where can i add this link?

pliant gulch
#

Or use typing.Annotated

maiden fable
#

Imagine dpy server people seeing your implementation ๐Ÿ‘€

pliant gulch
#

It's not that bad ๐Ÿ˜”

storm steppe
#

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)
maiden fable
hardy wing
#
await message.add_reaction("Flushed")```
anyone know how to correctly format this comes up as an error for me
maiden fable
slate swan
#

guys im so excited

maiden fable
pliant gulch
#

My whole wrapper is already alien bro

slate swan
#

my bot is about to getting verified

#

first timee

maiden fable
#

I remember when mine got verified. Was anxious

storm steppe
hardy wing
#

oh alr thnx

maiden fable
slate swan
#

It's taking me forever

#

Been 11 days ig

maiden fable
#

\:name:

maiden fable
slate swan
hardy wing
#

\

maiden fable
hardy wing
#

what difference does that make

maiden fable
#

Copy and paste that emoji directly

hardy wing
#

oh

pliant gulch
#

๐Ÿ‘๏ธ ๐Ÿ‘๏ธ

maiden fable
pliant gulch
#

I'm totally gonna lose motivation I can already feel it

#

๐Ÿ˜”

maiden fable
#

The last time I made changes/open the source code of my discord bot was.... 2 months ago or smth

hardy wing
#
       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

maiden fable
hardy wing
#

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

maiden fable
#

Ah

#

name=newmsg

#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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.
pliant gulch
hardy wing
#

didn't show any errors

maiden fable
hardy wing
maiden fable
#

huh?

hardy wing
#

I'll try t again ig

maiden fable
#

message.channel.edit(name=newmsg)

hardy wing
#

OOOOH

pliant gulch
#

Because if you just did the builder regularly, imagine ```py
bot = rin.GatewayClient(...)
with AppCommandBuilder(type=AppCommandType.MESSAGE) as demo:
# do stuff

hardy wing
#

alr alr

pliant gulch
#

rin.export would just act as an attacher ig

pliant gulch
#

I could also do syncing in there

maiden fable
#

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

pliant gulch
#

Iโ€™ll make it a generic class so I can pass command type, thus supporting more than slash commands in one builder

maiden fable
#

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

scarlet aurora
#
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?
pliant gulch
#

This is to get rid of the bulky decorators that I hate so much in other wrappers

maiden fable
#

Ah, u mean the people can add different ctx managers for different guilds?

#

Just like for different rows?

median flint
#

Hey I need help with embeds

maiden fable
serene mantle
#

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?

pliant gulch
maiden fable
#

Ah okay cool

pliant gulch
#

Iโ€™ll refactor it after that if you want to suggest things

median flint
# maiden fable I need your question
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
scarlet aurora
maiden fable
unkempt canyonBOT
maiden fable
maiden fable
#

the url and icon_url

scarlet aurora
#
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 ?
serene mantle
scarlet aurora
#

it errored

unkempt canyonBOT
#

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!

median flint
#

this didn't help whatsoever

#

how do I use that

maiden fable
scarlet aurora
#
  "token" = ""
}
``` this errored
serene mantle
scarlet aurora
#

in the json file

median flint
#

replace = with :

maiden fable
maiden fable
median flint
#

HOW DO I GET THE USERS ICON URL

maiden fable
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

maiden fable
#

Anyways

#

ctx.author.avatar_url

maiden fable
median flint
maiden fable
#

Bru

serene mantle
scarlet aurora
#
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
maiden fable
whole sparrow
#

good website to upload python code into?

#

i forgot, its usually used here

scarlet aurora
#

github

#

pastebin

whole sparrow
#

no, like to share code with other people very quickly

scarlet aurora
#

pastebin

whole sparrow
#

there was one specifically for pythgon if i believe

#

but pastebin works too

scarlet aurora
#

repit?

whole sparrow
#

nope

scarlet aurora
#

replit

unkempt canyonBOT
#

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.

whole sparrow
#

yh there u go

#

ty

maiden fable
#

(:

scarlet aurora
#
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

maiden fable
#

Sorry dude u have to go sleep rn

#

I'm sure anyone here can help u

scarlet aurora
#

@whole sparrow help me

maiden fable
#

BTW u should ask the question in a help channel

whole sparrow
#

bruh lol

maiden fable
#

It's more of a general Python question

slate swan
#

hi, does anyone know why it gives me an empty message error when sending an embed (it worked until recently)

vale wing
#

How do you send your embed?

slate swan
#

await ctx.send(embed=emebed)

#

it works on one of my bots, but not the other one... lol

vale wing
#

Ok how do you define embed?

slate swan
#

embed=discord.Embed

vale wing
#

Just this?

#

Well I need the full code of defining embed variable to help you

slate swan
#
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

vale wing
#

Huh

slate swan
#

1 sec ctrl v

#

for example

vale wing
#

Why not just colour = 0x00ffff

#

Like it's simplier than that construction

slate swan
#

true but the issue here is that it wont send (the code works), maybe discord changed something regarding non bot tokens?

vale wing
#

๐Ÿ˜ณ

#

Sorry but we don't help with selfbots

slate swan
ebon island
#

@pliant gulch What is the intent of that package?

pliant gulch
#

What package

ebon island
pliant gulch
#

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

ebon island
#

What is the wrapper intended to in terms of function?

pliant gulch
#

For native API use I'd say, but its also extensible with custom events, collectors, etc

slim ibex
#

Andy ๐Ÿ˜

slate swan
#

(hes trying to hack you with his discord wrapper!!)

pliant gulch
#

Did you see the new components refactor I did

slim ibex
#

no havenโ€™t looked at the repo recently

pliant gulch
slim ibex
#

Lemme check it out

#

example button and menu?

pliant gulch
#

yes

slim ibex
#

ok

#

ooh I like it

#

Nice use of the context manager for the buttons

#

and menu

pliant gulch
#

pog champ

#

Doing slash commands soon, they will look somewhat like those examples

slim ibex
#

ye the code looks rlly clean

pliant gulch
#

Don't look at the internals if you wanna keep that opinion ๐Ÿ˜”

slim ibex
#

๐Ÿ’€๐Ÿ—ฟ

pliant gulch
slim ibex
#

lmao

ebon island
#

This is quite cool. I'm planning to be doing a menu system via views in the near future

pliant gulch
#

๐Ÿ˜ณ

ebon island
#

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

native wedge
#

how do i set a bots About Me?

ebon island
#

and when you click into Settings it edits the message embed and all the buttons to be stuff like Cypher Settings | User Preferences etc

velvet tinsel
#

Hi Andy, baron and binds

slim ibex
#

hello

ebon island
#

Hey there ๐Ÿ™‚

#

How are you doing dek?

slim ibex
ebon island
#

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

pliant gulch
#

Support as in the pros my wrapper would have for that?

slim ibex
#

kinda like menus inside menus?

ebon island
#

Yeah, how would your wrapper handle that sort of more complex menu and component structure?

#

Yeah, menus inside menus precisely

slim ibex
#

that would be pretty cool

pliant gulch
ebon island
#

Does it already do that?

pliant gulch
#

Its gonna look bulky as hell with this, I'm sure with mine it would be a lot more clean

ebon island
#

So how would you do the same sort of thing in yours? Is this already supported?

pliant gulch
#

Well, the builder only builds the select menu. Your stuff would be all done inside of the callback

ebon island
#

so it'd be multiple builders yes?

slim ibex
#

Maybe you could have something like

pliant gulch
#

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

ebon island
#

I'd probably have a builder dict

#

that has things like settings_builder, help_builder, cypher_settings_builder etc

slim ibex
#
class Menu(rin.ActionRowBuilder, complex = True)``` ?
pliant gulch
#

Hmmmm yea I can imagine that would be pretty easy enough to do with what I have right now

slim ibex
#

and complex to true enables the Nested nature

pliant gulch
#

Builders as is already supports nested menus

#

Actually no

ebon island
#

That's excellent. How do I get started? I'll give it a try and perhaps contribute once I understand the featureset better

pliant gulch
#

One menu per action row right?