#discord-bots

1 messages · Page 748 of 1

slate swan
#

he could make a veriable for the role so when someone use the command add they'll get the role

vale wing
slate swan
#

pithink = pikachurole
so just str the emoji and add the rolelemon_pika

slate swan
frank tartan
#

it doesnt work. I've tried the role names and ids

slate swan
slate swan
vale wing
#

It is applicable for custom emojis only, stringing the unicode one would return itself

tawdry flume
#

Thx

slate swan
vale wing
#

His question is about adding a role but role is found by emoji

slate swan
#

then he needs sets 🙂

slate swan
vale wing
slate swan
#

this conversation is given me a stroke

vale wing
#

Docs site lagging for me for some reason

slate swan
vale wing
#

This is called a dict, not a set and isn't this what I said at first

slate swan
#

Idk how to explain doe💀

slate swan
#

yeah totally

vale wing
#

And you can get an item from a dict like

d = {'yes': True, 'no': False}
d['yes']```
#

You don't need utils.get for a dict lol

slate swan
vale wing
#

To get the role you need role's id

#

If we exclude the usage of utils.get

slate swan
frank tartan
#

can you guys just stop with it? i got it to work...

    newEmoji = emoji.split(":")
    newEmoji2 = newEmoji[1]
    roleName = newEmoji2.replace("_", " ")

    role = discord.utils.get(member.guild.roles, name=(roleName))
    await member.add_roles(role) 
velvet tinsel
slate swan
velvet tinsel
vale wing
# slate swan so how you're going to get the role🤔
d = {'👮‍♂️': 12345}

@bot.command()
async def cmd(ctx, emoji):
    await ctx.author.add_roles(ctx.guild.get_role(d[emoji]))```
Like this besides I don't remember what the emoji is like when parsed to command
slate swan
frank tartan
slate swan
vale wing
#

And the docs are not letting me view the docs for emoji 😡

#

!d discord.Emoji

unkempt canyonBOT
#

class discord.Emoji```
Represents a custom emoji.

Depending on the way this object was created, some of the attributes can have a value of `None`...
frank tartan
#

I have @commands.has_any_role(roleList), and ive tried using the role id's and names, but it just doesnt work

cold sonnet
#

what's in roleList

slate swan
#

probably doesnt work because you could be storing ints as a str

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
vale wing
#

You could do

if some_role in member.roles```
slate swan
#

the rolelist is a list of ceratin foles i assume

frank tartan
prime basin
#

is there an easy way to replace unicode emojis with their text representation?
(e.g. 👀 -> :eyes: or 😳 -> :flushed:)

cold sonnet
#

remove the quotation marks

cold sonnet
frank tartan
frank tartan
#

frick

#

your right, @slate swan tyy

slate swan
frank tartan
frank tartan
honest vessel
#

@frank tartan troll?

frank tartan
honest vessel
#

well

slate swan
#

does it even accept a list

frank tartan
slate swan
#

i dont think so

cold sonnet
frank tartan
slate swan
#

i think it accepts *args

honest vessel
#

u make 3 hardcoded var for ids

slate swan
#

which is a tuple

cold sonnet
#

bet

honest vessel
#

n put to list n pass it

cold sonnet
#

!d discord.ext.commands.has_role

#

wrong one

honest vessel
#

why not hardcode em in a list

frank tartan
cold sonnet
#

BRO

#

!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")
cold sonnet
#

I'm gonna retreat

vale wing
#
member_roles_ids = map(lambda i: i.id, ctx.author.roles)
if any([role_id in member_roles_ids for role_id in roles_list])```
Any better way to check if the user has one of roles in list (full of ids)?
slate swan
#

even has a example

@commands.has_any_role('Library Devs', 'Moderators', 492212595072434186)
honest vessel
#

roleList badname first of all

vale wing
#

Hold up wrong way to much iter

frank tartan
slate swan
frank tartan
honest vessel
#

but discord_ids = ["1234", "5678", "901011"]

slate swan
#

yw

frank tartan
#

🙂 your de best

cold sonnet
slate swan
cold sonnet
#

man you are throwing

vale wing
#

Now I really need to know what does emoji look like when parsed to a command but the problem is it's 1am

honest vessel
#

or idlist = []
idlist.append(id_var)

slate swan
#

hes problem has been solved why continue?

honest vessel
#

@vale wing 10pm

cold sonnet
#

here aswell

vale wing
#

1am just hit

honest vessel
#

2200 militarytime

vale wing
#

Behold, I've created the worst looking rank card

slate swan
#

🚪🚶

vale wing
#

It actually looks better with black background

slate swan
#

yes

#

hey everyone

#

i have another question to ask

#

i am trying to make a bot where if you dm it once, it will give you a response. but if you dm it twice, it will give you a different repsonse

``dm 1: hey, i am a bot

dm 2: you already dmd me!``

slate swan
#

oh

tacit token
#

My problem would be that the nanny button refers to the fact button, so the nanny changes after pressing the button. I tried to replace the custom id but then did not send anything to the button. Lib: discord_components The Code:

    async def dadjoke(self, ctx):
            await ctx.send(embed=discord.Embed(color = 0x34568B, title="Dad Jokes From CTRL", description=f"{random.choice(dadjokes)}"), components=[[
                Button(style=ButtonStyle.green, label="Next :arrow_forward:", custom_id="button1"),
                Button(style=ButtonStyle.red, label="Stop :octagonal_sign:", custom_id="button2"),

            ]])
        
    @commands.Cog.listener()
    async def on_button_click(self, interaction):
            if interaction.component.custom_id == "button1":
                await interaction.respond(type=7, embed=discord.Embed(color = 0x34568B, title="Dad Jokes From CTRL", description=f"{random.choice(dadjokes)}"))
            
            elif interaction.component.custom_id == "button2":
                await interaction.edit_origin(embed=discord.Embed(color = 0x34568B, title="Dad Jokes Stopped! :police_officer:", description=f"If you would like to use it longer, then push the next button or >dadjoke"))

    @commands.command(aliases=["Facts","facts","Fact"])
    async def fact(self, ctx):
            await ctx.send(embed=discord.Embed(color = 0x990033, title="Did you know? :astonished:", description=f"{random.choice(facts)}"), components=[[
                Button(style=ButtonStyle.green, label="Next", custom_id="button1"),
                Button(style=ButtonStyle.red, label="Stop", custom_id="button2"),

            ]])
        
    @commands.Cog.listener()
    async def on_button_click(self, interaction):
            if interaction.component.custom_id == "button1":
                await interaction.respond(type=7, embed=discord.Embed(color = 0x990033, title="Did you know? :astonished:", description=f"{random.choice(facts)}"))
            
            elif interaction.component.custom_id == "button2":
                await interaction.edit_origin(embed=discord.Embed(color = 0x990033, title="random Facts Stopped!", description=f"If you would like to use it longer, then push the next button or >fact"))```
unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
vale wing
cloud dawn
unkempt canyonBOT
#

Whether the commands should be case insensitive. Defaults to False. This attribute does not carry over to groups. You must set it to every group if you require group commands to be case insensitive as well.

tacit token
vale wing
frank tartan
#

how can i do
!removeRole member
and it will remove the member role from them?
ive tried
await member.remove_roles(roleName)
but i cant seem to find a way to define member that makes it still work

cloud dawn
vale wing
cloud dawn
#

Reading is also part of the job

frank tartan
vale wing
#
async def removerole(ctx, member: discord.Member, *, role: discord.Role)```
And then you can remove it with `remove_roles`, as it takes `Role` object
cloud dawn
slate swan
tacit token
cloud dawn
frank tartan
slate swan
vale wing
vale wing
cloud dawn
frank tartan
# vale wing Can you show your code?
@client.command()
async def removeRole(ctx,emoji):
    author_id = ctx.author.id
    newEmoji = emoji.split(":")
    newEmoji2 = newEmoji[1]
    roleName = newEmoji2.replace("_", " ")
    await member.remove_roles(roleName)
slate swan
vale wing
#

You don't have the thing you mentioned

cold sonnet
frank tartan
slate swan
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

cloud dawn
cold sonnet
vale wing
cloud dawn
cold sonnet
#

me neither

frank tartan
#

i just need to define member in member.remove_roles

vale wing
#

It takes Role object, not the name

#

!d discord.Member.remove_roles

unkempt canyonBOT
#

await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
vale wing
#

And you get Role by its id (better method) or by using utils.get with certain params

slate swan
frank tartan
slate swan
frank tartan
slate swan
frank tartan
slate swan
frank tartan
#

i will

slate swan
vale wing
frank tartan
# slate swan Tell me if it works

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'id'
i get this error

frank tartan
# slate swan Show me ur code

@client.command()
async def removeRole(ctx,emoji):
    member = ctx.author
    newEmoji = emoji.split(":")
    newEmoji2 = newEmoji[1]
    roleName = newEmoji2.replace("_", " ")
    await member.remove_roles(roleName)
vale wing
#

I told you to provide Role object and not a name

#

roleName is a str

cold sonnet
#

those are 4 unnecessary variables

vale wing
#

Also camelCase is not for python

frank tartan
vale wing
#

Well personally I don't really care about that but it is not suitable for python in terms of code readability

#

If Java or C# is written with camelCase it will be readable, but python won't and vise versa

frank tartan
#

ok nice to hear about your opinion on how i write my code

vale wing
#

Not an opinion but a small advice you can follow or ignore

frank tartan
slate swan
#

how can i stop my bot from waiting for an event should i set the timeout to the timeout i want with a var and then when i change the var it will cancel it since the timeout was set to a second?

weary mirage
#

I'm using sqlite3 with python, and when I use string.replace(), it makes sqlite3 raise errors because its counting them as multiple bindings

frank tartan
weary mirage
#

type that?

weary mirage
slate swan
vale wing
#

That's an interesting question

slate swan
vale wing
#

But like how do you want to stop it, from code or by sending a message, adding reaction, etc.

slate swan
slate swan
vale wing
#

It is raised when the event is stopped, we don't need this

#

We need to stop the event

slate swan
#
a = 60.0
timeout=a
#on an interaction
a = 1.0

this is my method i was thinking

slate swan
slate swan
vale wing
#

60 will be parsed to the function and it will not vary

slate swan
#

ah yeah makes sense

vale wing
#

Afaik the wait_for will only stop if it got a right event with check passed or if it timeouts

slate swan
#

yeah ik

#

ion think u can stop an event pithink

#

im using buttons and one of them uses waif for to wait on a msg and i set a button to stop the event and stop the action given by the first button

vale wing
#

Why'd you need to stop the event, you could just handle the return

frank tartan
slate swan
#

or maybe i can just set a timeout and if the author isnt right just pass it ig

vale wing
#

Could you show your wait_for with a check

slate swan
#

dont have one lol

vale wing
#

Oh lol

slate swan
slate swan
slate swan
frank tartan
vale wing
slate swan
vale wing
#

Ok

slate swan
#

i am trying to make a bot where if you dm it once, it will give you a response. but if you dm it twice, it will give you a different repsonse

``dm 1: hey, i am a bot

dm 2: you already dmd me!``

#

anyoneee

vale wing
#

You would probably need to store the users it has replied to somewhere

slate swan
#

how would i do that

slate swan
vale wing
#

If you are going to store it after bot shutdown, there are databases

cloud dawn
slate swan
cloud dawn
#

I told him 30 min ago to use a database

frank tartan
# slate swan Wym

well either you tell me how to add more items to it or i have to have 30+ variables...

frank tartan
vale wing
#

For small projects you could use pickle or json tho it's not recommended

cloud dawn
frank tartan
cloud dawn
slate swan
#

Like adding it to dict?

vale wing
frank tartan
slate swan
vale wing
#

By small I mean 1-2 guilds

slate swan
cloud dawn
#

sqlite for around 30k if you merge it with aiosqlite

vale wing
#

How many with asyncpg huh

cloud dawn
vale wing
#

Considering them the same you counted for sqlite

cloud dawn
#

I'd say one server can handle about a million or 2/3

vale wing
#

🤯

#

The power of postgres is unlimited

frank tartan
cloud dawn
#

Well that's still pretty small when looking at bigger companies. Also looking as commands can sometimes use multiple queries.

vale wing
slate swan
frank tartan
vale wing
#

Clusters?

cloud dawn
vale wing
#

Haha yes

frank tartan
slate swan
frank tartan
vale wing
#

I am thinking on migrating from sqlite to postgres when my bot hits 200 servers, right now I store lists in a very bad way

frank tartan
#

wait

slate swan
vale wing
#

The issue is I gotta read too much of docs but I alr will

cloud dawn
frank tartan
vale wing
#

I have already tried it on my ubuntu server and I couldn't even find the proper setup guide at first

frank tartan
slate swan
frank tartan
vale wing
#

@cloud dawn can you recommend any good postgres setup guides

slate swan
vale wing
#

Besides their documentation

frank tartan
# slate swan Remove role?
@client.command()
async def removeRole(ctx,emoji):
    member = ctx.author

    newEmoji = emoji.split(":")
    newEmoji2 = newEmoji[1]
    roleName = newEmoji2.replace("_", " ")

    await member.remove_roles(roleName)
frank tartan
# slate swan Wut abt add role?
newEmoji = emoji.split(":")
    newEmoji2 = newEmoji[1]
    roleName = newEmoji2.replace("_", " ")

    role = discord.utils.get(member.guild.roles, name=(roleName))
    await member.add_roles(role) 
unkempt canyonBOT
#

class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
frank tartan
slate swan
vale wing
#

Why is your roleName in brackets

#

I mean it shouldn't turn into tuple but why

frank tartan
slate swan
#
@client.command()
async def removeRole(ctx,role:discord.Role):
    member = ctx.author


    await member.remove_roles(role) 

#Command Use:
{prefix}removeRole <metion role> or <or role.id>

Example (if prefix is !)
!removeRole @Admin 
!removeRole role_id
vale wing
#

He's doing a different thing and can't figure it out yet

#

He wants to add roles by an emoji

slate swan
#

oh

frank tartan
slate swan
#

never see that!

frank tartan
#

ok im dumb

#

i forgot to add
role = discord.utils.get(member.guild.roles, name=(roleName))
to remove role

reef falcon
#

yo

#

i need someone from here to help me

cloud dawn
limpid thicket
#
for file in os.listdir():
  if file.endswith(".mp3"):
    os.rename(file, "song.mp3")

await ctx.author.voice.channel.connect()
voiceClient = discord.utils.get(client.voice_clients, guild=ctx.guild)
voiceClient.play(discord.FFmpegPCMAudio(Path("song.mp3"), **ffmpeg_options))

Could someone help why this isn't working? It just comes up saying Option reconnect not found.

#

All I want to do is play music from a .mp3 file lol, yet it's so complicated.

vale wing
limpid thicket
#

Will it work without it?

vale wing
#

I think so

cloud dawn
#

!d disnake.ext.commands.Bot.reload

unkempt canyonBOT
#

Whether to enable automatic extension reloading on file modification for debugging. Whenever you save an extension with reloading enabled the file will be automatically reloaded for you so you do not have to reload the extension manually. Defaults to False

New in version 2.1.

cloud dawn
#

Well this saved a lot of time

modest plover
#

If I was gonna make a leaderboard, how would I do that?
Like an embed with all the names and point values then I also need a command to add points.
How would I do that?

modest plover
#

Is there any good but easy ones that I should use?

#

Like ones that aren't too hard to learn

cloud dawn
#

.name

modest plover
cloud dawn
modest plover
#

What's the difference between postgresql and sqlite?

cloud dawn
modest plover
#

Wdum relational?

cloud dawn
#

So for postgre you need an additional program to run it. Sqlite doesn't that are just files. Postgre is significantly faster though.

modest plover
#

An additional program.. what is it?

cloud dawn
#

I recommend postgre for large projects around 30k+ guilds and postgresql for more guilds than that

cloud dawn
slate swan
#

no more cogwatch

modest plover
#

It's for about 16-17 guilds at most

cloud dawn
modest plover
#

Ok

cloud dawn
#

Use aiosqlite and your good

modest plover
#

Aiosqlite, got it, thanks Panda

cloud dawn
#

!pypi aiosqlite

unkempt canyonBOT
cloud dawn
#

:3

modest plover
#

Thanks :)
how do I use it tho

#

Never had to use databases

slate swan
cloud dawn
modest plover
#

Ok

#

Where do I find the docs?

#

Like you got a link or some shit?

slate swan
modest plover
#

What's the difference between SQL and aiosqlite?

cloud dawn
slate swan
modest plover
#

Ah, so aiosqlite is like an add-on in a way to sqlite

cloud dawn
slate swan
#

its like and api wrapper

#

it just talks to sqlite which aiosqlite is like the endpoint of it

#

gosh im horrible at examples

#

that's.. really not how it works

#

the endpoint is the remote server, which in this case would be sqlite

#

yeah ik

#

aiosqlite is the client connecting to the remote

#

but idk if he understood it

modest plover
slate swan
#

its like going to dpy without knowing dpy

#

you wont understand it

#

You should start learning over here, https://sqlbolt.com/ sqlbolt teaches you SQL by examples and quick challenges

#

really good interactive tutorial

modest plover
#

That's what I'm following, the sqlbolt thing

slate swan
#
##############################
#--- button ticket system ---#
class Support(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None

    @discord.ui.button(label='Create a ticket', style=discord.ButtonStyle.grey, emoji="📩")
    async def create(self, button: discord.ui.Button, interaction: discord.Interaction):
        channel = await interaction.guild.create_text_channel(name=f"{interaction.user.name}-{interaction.user.discriminator}")
        await channel.set_permissions(interaction.user, send_messages=True, read_messages=True)
        await interaction.response.send_message(content=f"Ticket created {channel.mention}", ephemeral=True)
        self.value = False


@bot.command()
async def support(ctx):
    view = Support()
    supportembed = discord.Embed(title=" ", color=botcolortheme, description="To create a ticket, click below")
    supportembed.set_author(name="Support")
    await ctx.send(embed=supportembed, view=view)
    await view.wait()
#--- end of button ticket system ---#
#####################################

with this command it creates a channel with overwritten perms to the ticket to type and view the channel as a ticket, is it possible to make the channel created in a specific category with a id or the category name(prefered)?

left crater
#

can i send a message when the bot turn on

modest plover
#

Like how do I put info into it?

#

It's got this sort of lay out on the site but never actually says how to make a database on sqlbolt, it just uses a table diagram

slate swan
#

sqlbolt teaches you sql syntax

#

not how to use an sql database in python

modest plover
slate swan
modest plover
#

Damn

glacial bridge
#

@modest plover there is one

#

Not a guide, but examples

slate swan
#

largely depends on what he's going to use

glacial bridge
#

Oop nvm you’re not using PostgreSQL

#

Probably still examples if you look in the official dpy server

#

Wait that’s a different person; what are you going to use?

#

If it’s postgresql I can provide an example or two

modest plover
#

Sqlite

sweet oxide
#

I just started making discord bots, and I got an error saying that "event() missing 1 required positional argument: 'coro' error discord.py" in this code:

import discord
import os

client = discord.Client

@client.event
async def on_ready():
  print(" We have logged in as, {0.user}" .format(client))

@client.event
async def on_message(message):
  if messag2.author == client.user:
    return

  if message.content.startswith('[ Hi'):
    await message.channel.send('Hello bros')

client.run(os.getenv("token"))```
pls halp!
slate swan
#

messag2

modest plover
sweet oxide
#

oops i did that

#

but its telling theres a problem with "async def on_ready():" thats what the error was for

sweet oxide
slate swan
#

!d discord.ext.commands.Bot.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.
slate swan
#

disnake

#

Ok

torpid dew
slate swan
#

Thanks

slate swan
#

Which should I do py cord or disnake

#

thats just dumb

torpid dew
#

pycord is very similar

slate swan
torpid dew
#

discord.js has more features and can do more with it

slate swan
#

Disnake is like the exact same right just import disnake

slate swan
slate swan
#

sure

#

Ok thanks

visual island
slate swan
#

Thx

#

there it is

torpid dew
slate swan
#

slow

#

disnake is better tbh

torpid dew
#

i just see why u switch

slate swan
#

Yeah I’ve seen some of the documentation

torpid dew
final iron
#

Pycord is regarded as one of the meh forks

slate swan
#

yes

#

disnake is just superior pithink

torpid dew
slate swan
#

Bro there is no difference

#

Well I mean besides a few things

slate swan
#

But majority it’s like exact same

torpid dew
#

it is suppose to be similar

#

or it will be different language

slate swan
#

Dude why would I go to something that’s not goi mf to be updated

slate swan
#

dpy is hard and python as well so dont come here comparing thempithink

torpid dew
#

that is python

#

@slate swan if u dont want anything very similar to discord.py try discord.js

slate swan
#

bro what?

#

are you ok?

final iron
slate swan
#

What do u not understand

#

djs isnt even in the same language?

torpid dew
slate swan
#

disnake is a fork btwpithink

#

is there any way i can make a discord bot not repeat a previous message? for example

bot: @user tagged me!
user: @bot
bot:-------```
slate swan
slate swan
#

he probably wants it per user so use a db

#

What do u use for db

pliant gulch
#

Hikari is actually pretty nice clean written

slate swan
#

@slate swan

slate swan
#

andy knows

pliant gulch
slate swan
#

he can tell cuz im eating

#

What u eating

slate swan
#

Oh nice

slate swan
slate swan
slate swan
#

Lol

slate swan
unkempt canyonBOT
pliant gulch
slate swan
#

Ok thx

slate swan
pliant gulch
#

The repo is private right now but if you see the revamp as it is now It's pretty different

pliant gulch
#

Even revamped caching system

#

Now it looks like this ```py
class User(Cacheable, type="User", max=1000):
...

slate swan
#

nice

quaint epoch
#

is it

#

like sqlite3

#

or sql

#

but for async

final iron
#

Yes

slate swan
#

its a async bridge of sqlite

quaint epoch
final iron
#

Its just sqlite3 but async

quaint epoch
#

so like database stuff im guessing?

slate swan
#

yeah

quaint epoch
#

nice

#

are there docs for it?

slate swan
#

yes

slate swan
#

hi again

#

whats the script for

#

if last message = second to last message

magic ore
slate swan
#

i cant find it

pliant gulch
#

And I know that Cache[type] isn't valid but It was to late when I found that out

magic ore
#

it doesn't really make sense to do attrs["__cache__"] = Cache[type](max) # type: ignore

pliant gulch
#

What should I do here?

slate swan
#

how do i make a bot delete a duplicate message?

magic ore
#

actually you probably want Cacheable[type[Self]]

#

oh wait no

pliant gulch
magic ore
#

actually that does work

pliant gulch
#

Wow perfect, thanks man

magic ore
#
class Cacheable(metaclass=CacheableMeta):
    __cache__: Cache[type[Self]]``` you want this instead btw
pliant gulch
#

That's what I get for trying to make a strongly typed package without being that good at types

magic ore
#

since Self would be an instance of it instead of the class

pliant gulch
#

Actually in this case I wouldn't want type[Self] though right?

#

As get etc in Cache return an instance or should

#

Not a type of the class

magic ore
#

if the T for self.root is an instance then yeah, just Self

slate swan
#

how do i make a bot delete a duplicate message? @magic ore

#

can u pls help me

pliant gulch
#

Alright yea sounds good, thanks

magic ore
#

👍

magic ore
slate swan
#
if chanel.last_message.content == int(message.content):
              await message.delete() ```
#

i got this prob doesnt make sense Cry_Univers

#

your making message content a int?

#

wut

#

int(message.content)

#

uhhhh

dry orbit
#

how can i put the a function on my discord bot to play music?

sinful fern
#

Rule 5

#

I think the rule was

unkempt canyonBOT
#

Hey @dry orbit! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

dry orbit
#
import discord
import os

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as {0}!'.format(self.user))

    async def on_message(self, message):
        print('Message from {0.author}: {0.content}'.format(message))
        if message.content == ';;regras':
            await message.channel.send(f'{message.author.name} as regras do servidor são: {os.linesep} 1- não tem regras ksksks {os.linesep} 2- sla só tô testando meu bot sksksksksks {os.linesep} 3- python é legal!')
        elif message.content == ';;comandos':
            await message.channel.send(f'{message.author.name} Regras: {os.linesep} ;;regras - Vê as regras do bot {os.linesep} ;;nivel - Manda o seu nivél na sua DM')
        elif message.content == ';;nivel':
            await message.author.send('Nivel 1, mlk mó noob')
        else:
            pass

client = MyClient()
client.run('meu_tokin')

sinful fern
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
dry orbit
#

i wanna put a function for music

#

i wanna the code

sinful fern
#

Yes and we can't help you

dry orbit
dry orbit
pliant gulch
magic ore
#

not too sure, try asking in #type-hinting
iirc Self didn't work well in metaclasses but that might've been changed

slate swan
final iron
slate swan
pulsar shell
final iron
#

sus

slate swan
#

||s||||u||||s||

pliant gulch
#

Of course this would mean I get rid of any type errors that would pop up though,

slate swan
#

can i use wait for with buttons?

rancid tendon
#

Hey, I'm using py-cord v2.0.0-alpha...
Does self.bot.wait_for('message', check=lambda m: m.author.id==ctx.author.id) not work anymore?
I have a / command, where my bot sends a dm and then waits inside the dms for a message, but somehow wait_for doesn't respond at all and my code "freezes".

Do I have to use something new for this?
I used discord.py before and it worked (well... I didn't use lambda, but it should be the same, except for the checked values)

rancid tendon
slate swan
rancid tendon
#

Yup

slate swan
#

not sure then

#

im having the same problem lol

rancid tendon
#

haha

#

Like everyone else seems to not have that

#

This is the weirdest one so far

slate swan
#

same

rancid tendon
#

But thank you for trying ^^

slate swan
#

yw ig

hoary cargo
#

Idk If u should use dpy 2.0 since it's not a final product

rancid tendon
#

Like I would be happy if it even would just trhow anything

slate swan
#

mine is defined as well but im not sure why its not respoding because its not even printing in the check

rancid tendon
slate swan
#

!pypi disnake

unkempt canyonBOT
slate swan
#

you can use disnake

rancid tendon
#

Does it also have full slash and cogs support?

slate swan
#

yes

rancid tendon
#

Also discord.Guild.Events?

slate swan
#

probably yes

rancid tendon
#

Thank you. I'll take a look

slate swan
#

yw

hoary cargo
#
import disnake as discord

My favorite line

slate swan
hoary cargo
#

But why

slate swan
#

🚪 🏃

hoary cargo
#

bullshit bullshit Don't run

slate swan
#

🏃💨

hoary cargo
#

Fart

slate swan
#

why does everyone call it a fart

#

smh🚙

hoary cargo
#

Because looks like fart

slate swan
#

no

#

u could , but should not

#

bad practice

#

Instead. Install it with the discord namespace

#

its like doing

import seed as plant
hoary cargo
#

It can work nicely for embeds though

slate swan
#

😭

#

nooooooooo😠

hoary cargo
slate swan
#

ah

slate swan
slate swan
hoary cargo
#

No, since disnake is a fork of discord literally is almost copy paste dpy

hoary cargo
#

Yes

slate swan
#

theirs a difference🧍‍♂️

hoary cargo
#

Well yes
The slash commands and all the new stuff

slate swan
#

what if someone has both Disnake and discord installed

hoary cargo
#

But besides that it's the same

slate swan
#

its more developed like a plant compared to a seed

slate swan
hoary cargo
slate swan
#

not recommended btw

hoary cargo
slate swan
#

Doesn't exist on discord

#

i had it on my laptop but i dont anymore

#

getch is only for disnake

#

Yeah that's what in saying

hoary cargo
#

I use pycharm so it's fine
The projects don't inherit the libraries between them

slate swan
#

I use venvs remSmile

#

i quit pycharm cuz it doesnt support md filespithink

#

just edit it somewhere else...

hoary cargo
#

I feel more comfortable coding in pycharm tbh
Vs Atom or vscode

slate swan
pliant gulch
#

Neovim 🙏

hoary cargo
#

Vsc 💩

pliant gulch
#

Vsc bloatware

slate swan
#

ive never used atom only pycharm vsc and the idle

pliant gulch
slate swan
#

vim is a trap u don't want to fall into

#

i feel u

#

vim is so just ew

pliant gulch
#

It's amazing

analog barn
#

uh hey, rq, ik its weird practice but instead of a prefix with "-" or whatever for my bot, I actually just want my bot's prefix to be when someone mentions it... how do I do that? lmao
I keep tryna search it up online and it's just being weird and giving me answers that dont appear to be helpful at all
this is for discord.py btw

slate swan
slate swan
#

or you can have both prefixes

analog barn
#

ill try it, thanks!

slate swan
pliant gulch
analog barn
#

I was using "when mentioned or": instead

#

yeah

slate swan
hoary cargo
#

@slate swan does vsc has the code together feature? Like in Pycharm you can invite someone to code with u in ur project I think that's being done in cloud

slate swan
left crater
#

can i make messages send a certain amount of time after the command? (for example the person says !hello and the bot replies hello 5 seconds later)

slate swan
slate swan
pliant gulch
#

Meanwhile you windows users need to do like hella steps to set a PATH variable

#

I just do export

#

We are not the same

slate swan
#

And yes afaik , u can do multiplayers on vsc cause someone once sent me a link for their vscode project

pliant gulch
slate swan
#

or , keep your device running for 48hrs straight like me

slate swan
slate swan
#

WHOAAAAA Windows is an OS worth try ||uninstalling||

slate swan
#

OMG I love that song

slate swan
pliant gulch
slate swan
#

oh wait.......................

slate swan
magic ore
#

you could do that though yeah

#

since generic metaclasses aren't supported as well afaik

pliant gulch
#

Yea, ended up going with that workaround

#

As the current behaviour is rather undefined so

#

Just not worth the trouble to try to make it work

frank tartan
#

is there a way to make buttons last for like 30 minutes? if so, how?

wicked atlas
#

Buttons last forever, you just need to recieve the interaction

#

might be more difficult with some libraries tho, I don't really use them much

frank tartan
potent spear
wicked atlas
potent spear
#

I'd throw an error for sure

slate swan
potent spear
slate swan
#

new movie: living the life as a discord-components button

#

rated: R

potent spear
#

I'd rate it an F

slate swan
#

good one

slate swan
potent spear
#

that's where we draw the line lol

slate swan
tranquil badge
#

Trying to make a command that puts my bot into a state that only i can use the commands.

@bot.event
async def on_message(message):
    await bot.process_commands(message)
    if bot.test_mode == False:
        return
    <other on_message actions>

def test_mode(ctx):
    if ctx.author.id == 352986404621647873:
        return

@bot.command(name='testmode')
@is_owner()
async def test_mode(ctx):
    bot.test_mode = True
    await ctx.send('`Now in testmode.`')
slate swan
#

well according to your on_message override , you are allowing the commands to get processed normally , and other things inside on_message will happen only if test_mode is true

tranquil badge
kind wasp
#

What is disnake

final iron
slim ibex
#

nextcord

halcyon sparrow
#

Why not use hikari

slate swan
#

disnake is the only right answer

maiden fable
shadow wraith
slate swan
#

same thing

shadow wraith
#

¯_(ツ)_/¯

maiden fable
shadow wraith
#

oh

#

!d disnake.ext.commands.is_owner 😎

unkempt canyonBOT
#

@disnake.ext.commands.is_owner()```
A [`check()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.check "disnake.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot.is_owner "disnake.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.NotOwner "disnake.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure").
tranquil badge
#

I mean im already using that...

shadow wraith
tranquil badge
#

What im trying to do is make it so the rest of the commands get locked to only me

maiden fable
shadow wraith
#

o

tranquil badge
#

@is_owner()

tranquil badge
#

i didnt include this

def is_owner():
    async def predicate(ctx):
        return ctx.author.id == 352986404621647873
    return commands.check(predicate)
maiden fable
#

Don't

tranquil badge
#

not related

slate swan
#

just use the dpy one

maiden fable
#

!d discord.ext.commands.is_owner is already a check

unkempt canyonBOT
#

@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.

This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").

This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
shadow wraith
#

thats what i said earlier, i already showed that

maiden fable
#

Mhm

tranquil badge
#

i have my reasons for not using is_owner in normal sense

shadow wraith
#

yeah what are they

maiden fable
#

Okay...

maiden fable
shadow wraith
tranquil badge
#

it's besides the point

#

the code still functions the same

shadow wraith
#

don't go "whatever works ill use", just improov and never settl

pliant gulch
#

I know I told you yesterday about process_commands but now I realise that this is a much better method of doing this

tranquil badge
#

yea

#

i looked into checks and it seemed easier

#

but i went with the suggestion

verbal cairn
#

so many elif 😭

final iron
#

What are these role variables?

#

Like the member, admin, organizer

#

Can we see the code for those?

tranquil badge
grand saffron
#

is it slow?

slate swan
#

What should be changed is the naming of all variables.

#

None of them follow the Python naming conventions.

grand saffron
#

that makes sense.

slate swan
#

Well you're showing random parts of your code which don't help us to find the issue.

Do you get an error?
What is the full code before and after you've initialized the variables?

#

Well we still need a better code overview.

flint cypress
#

How can I make my bot to leave other servers

unkempt canyonBOT
#

Hey @hidden hazel!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

slate swan
unkempt canyonBOT
#

await leave()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Leaves the guild.

Note

You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
flint cypress
#

Can't I just type that command in my server and bot leave other servers

slate swan
#

you type the id of the guild and it will leave that guild

frank tartan
#

lets say I have a yes or no question. How can I make it so if either button is pressed, both get disabled?

flint cypress
quick gust
#

delete your bot account

quick gust
#

and actually

#

u can just make a for loop?

slate swan
#
for guild in bot.guilds:
    print(guild.id)
quick gust
#

for guild in bot.guilds: await guild.leave()

flint cypress
final iron
slate swan
final iron
#

Simple for loop

quick gust
flint cypress
slate swan
#

bot.guilds contains all guilds your bot is in, including IDs.

frank tartan
slate swan
#

So yes, you do have the IDs.

quick gust
#

oh

quick gust
#

nah he just wants his bot to leave all servers

slate swan
#

just add the coro easy

flint cypress
#

Can you tell me how can I make invite link from my bot of all guilds in which my bot is in so I can know who invited my bot

quick gust
flint cypress
slate swan
#

Breaching Developers Policy of Discord.

#

Can get your bot and account terminated.

flint cypress
#

then how will I know who invited my bot

slate swan
#

thats just creepy no offense

slate swan
flint cypress
#

I wanna know because my bot isn't made for public use

final iron
frank tartan
final iron
#

I need to check if I'm breaching tos

slate swan
#

It doesn't matter, it's backdooring.

flint cypress
slate swan
#

It is

slate swan
#

Backdooring is not allowed as per the Developers policy.

#

or a for loop if you have many

#

So please stop asking about how to do this.

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

frank tartan
quick gust
flint cypress
slate swan
#

Provide a way to contact you, do not backdoor servers.

#

As simple as that.

slate swan
flint cypress
# slate swan No.

Discord have the access of all accounts in discord? That doesn't mean backdooring

slate swan
#

Are you Discord?

tranquil badge
#

they dont lmao

slate swan
#

Exactly, no

frank tartan
flint cypress
final iron
#

What?

flint cypress
slate swan
tranquil badge
#

this dude just trolling now

slate swan
frank tartan
flint cypress
slate swan
#

You're just going off topic trying to prove you're not breaching their terms of service.

slate swan
tranquil badge
#

@ mods pls ban him

frank tartan
final iron
#

@flint cypress Bottom line is, what you're trying to do breaches tos. You can continue talking about it but that will be against this servers rules and you might be punished

flint cypress
slate swan
#

So please drop the topic before Moderators come all right?

flint cypress
#

I was just asking doubts

slate swan
flint cypress
#

That's unfair ban

slate swan
#

you were trying to prove yourself right

#

when you cant

flint cypress
#

Nvm

#

Cut it

tranquil badge
#

would be a deserved and fair ban

slate swan
#

¯_(ツ)_/¯

flint cypress
tranquil badge
#

okay sure

flint cypress
#

This discord bring a new feature. Add server button that's why

#

My private bot is added in many servers now 😭

#

My replit got crashed

slate swan
#

Disable the public bot check.

flint cypress
slate swan
#

Make the bot leave all the guilds. Invite it again yourself to needed guilds.

frank tartan
# slate swan yeah

TypeError: decline_reply() missing 1 required positional argument: 'self'

async def decline_reply(interaction, self):

slate swan
frank tartan
slate swan
#

And invite it again only to the needed servers.

frank tartan
tranquil badge
slate swan
#

or a class

frank tartan
slate swan
final iron
slate swan
#

Yes you can, would just be unnecessary as they don't seem to have a lot of knowledge.

frank tartan
slate swan
tranquil badge
#

children still

slate swan
#

If you have the IDs of excluded servers just check before leaving it.

#

yeah just children

frank tartan
slate swan
frank tartan
slate swan
#
for guild in guilds:
    if not guild.id in [1234, 4321]: # Ignore servers the bot should be in
        await guild.leave()
flint cypress
#
@bot.command() 
async def leave(ctx): 
await ctx.send("I am leaving this guild!") 
await ctx.guild.leave()

This is ok? But I don't have guild id or server

slate swan
#

Indentation is not correct.

#

Other than that, yes.

flint cypress
slate swan
#

Make a loop, and leave all guilds.

flint cypress
#

Didn't I have to execute that in that particular server

frank tartan
slate swan
#

Then make the bot private and invite it to needed servers.

flint cypress
slate swan
#

It leaves the current guild.

slate swan
#

Make a for loop and leave all guilds.

flint cypress
#

for guild in guilds:
if not guild.id in [1234, 4321]: # Ignore servers the bot should be in
await guild.leave()

frank tartan
slate swan
#

You said you don't have guild IDs

flint cypress
slate swan
flint cypress
#

On_ready?

frank tartan
slate swan
flint cypress
#

K

final iron
frank tartan
final iron
#

...

frank tartan
final iron
#

Replace disnake with discord

slate swan
#

basic stuff

frank tartan
slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
003 | 3
004 | 4
005 | 5
006 | 6
007 | 7
008 | 8
009 | 9
slate swan
#

make sense

slate swan
frank tartan
slate swan
#

discord.children

frank tartan
tranquil badge
#

discord uses children

slate swan
#

im not sure myself

#

probably does

#

It's either ActionRow.children or View.children.

#

yeah

frank tartan
slate swan
#

I guess you have a View object yourself.

tranquil badge
#

still dont get why children

slate swan
#

So simply go on and use view.children if you do so.

slate swan
slate swan
tranquil badge
#

ahh missed that part

frank tartan
#
for child in view.children:
            view.child.disabled = True
slate swan
#

and no need for view.child.disabled just child

frank tartan
slate swan
frank tartan
slate swan
#

yes

final iron
slate swan
frank tartan
final iron
#

Learning it is hard

frank tartan
#
for child in View.children:
            child.disabled = True
slate swan
#

no

for child in discord.ui.View.children:
            child.disabled = True
#

It's supposed to be your view object.

#

Not just the class of discord. It will never work.

#

let me watch my anime i cant anymore😠

#

You also never do discord.Member.name, you do ctx.author.name.

tranquil badge
slate swan
#

Since ctx.author represents an object of discord.Member.

frank tartan
slate swan
slate swan
frank tartan
tranquil badge
slate swan
slate swan
slate swan
#

thats not what i replied to

frank tartan
slate swan
#

well it needs the be the view obj

frank tartan
frank tartan
spring flax
#

Any way to get the role icon?

#

using disnake ^

slate swan
#

!d disnake.Role.icon

unkempt canyonBOT
#

property icon: Optional[disnake.asset.Asset]```
Returns the role’s icon asset, if available.

New in version 2.0.
slate swan
frank tartan
#

so how can i make it so when someone clicks a button, the message the button is attatched to gets deleted?

slate swan
#
        elif ctx.author.top_role.id == 855877108055015465:            
            allowed_channels = [795879613393666048, 795709746501648384, 756552586248585368, 747853054329487500, 747184622386806824]
            if ctx.channel.id in allowed_channels:
                if channel.overwrites_for(ctx.guild.default_role).send_messages == None or channel.overwrites_for(ctx.guild.default_role).send_messages == True:
                    await channel.set_permissions(ctx.guild.default_role, send_messages=False)
                else:
                    await ctx.send(f"🔒 Looks like `{channel}` is already locked")
            else:
                await ctx.send(f"You are not allowed to lock {channel}")

In this part of my code, I want a certain role to be able to unlock only certain channels. However when the user with that role tries unlocking a channel even if its in allowed_channels it still sends you are not allowed to lock ...

flint cypress
#

Bro one person is banned but I can't find them in discord ban list. How is that possible

slate swan
#

Not the place to ask for it

full valley
#
Traceback (most recent call last):
  File "/root/6mans/cas_v1.py", line 961, in report
    team2_mmr[team2idlist[count]] = get_mmr(team2idlist[count])
  File "/root/6mans/cas_v1.py", line 553, in get_mmr
    mmr = x["MMR"]
TypeError: 'NoneType' object is not subscriptable```
#

What have I done Sadge

#

is x none?

maiden fable
#

Yea

untold token
#

Yes

untold token
#

That could be a reason

flint cypress
#

In ban list but they show me link shows banned from server