#discord-bots

1 messages Β· Page 797 of 1

fervent shoal
#

is it

slate swan
#

Nah its easy

maiden fable
#

await self.bot.wait_until_ready() at the top

sick birch
#

But yeah whenever you get that NoneType error it usually means that it couldn't find the channel object for whatever reason

sick birch
slate swan
#

if they save the id as a string in the json , get_member wont ever get the channel

sick birch
#

Yeah, that's why you need to 100% be sure it's an integer

maiden fable
# dry kelp why?

That will not run any code until the bot's cache is fully populated with all the stuff

dry kelp
#

oh lemme see

pliant gulch
#

when discord.py doesn't actually dispatch on_ready when receiving READY

#

πŸ‘οΈ πŸ‘οΈ

fervent shoal
#

Traceback (most recent call last):
File "c:\Users\e\riot bot #4, the bruh.py", line 45, in <module>
@commands.has_permissions(manage_members=True)
File "C:\Users\e\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 1779, in has_permissions
raise TypeError('Invalid permission(s): %s' % (', '.join(invalid)))
TypeError: Invalid permission(s): manage_members

maiden fable
#

and here comes andy πŸ‘€

dry kelp
fervent shoal
slate swan
maiden fable
fervent shoal
#

you lost me at dpy im so sorry

sick birch
#

(bot is boring)

maiden fable
sick birch
#

You're not the first, someone else thought the same haha

dry kelp
dry kelp
maiden fable
maiden fable
pliant gulch
#

I name mine conventionally

slate swan
pliant gulch
#

πŸ‘οΈ πŸ‘οΈ

fervent shoal
sick birch
#

Well I've gotta head out now, and looks like all the smarties are here so you should be alright spooky :)

slate swan
maiden fable
#

No

dry kelp
#

how tf

slate swan
slate swan
slate swan
maiden fable
#

@dry kelp mind verifying the ID?

maiden fable
slate swan
fervent shoal
slate swan
maiden fable
#

πŸ‘€

dry kelp
#

but there's stuff

dry kelp
#

imma run the bot from vsc so i can show ya

slate swan
maiden fable
#

Okay...

slate swan
fervent shoal
slate swan
#

shit

dry kelp
#

yea is weird i should rr my root but im lazy

maiden fable
#

Haha okay...

slate swan
#

or, make your own timeout method

#

which makes a request to the API

fervent shoal
#

i just want the command to work

#

like have the permission to work

slate swan
#

use some other perm simply

slate swan
#

like manage_roles

maiden fable
#

Just use the manage roles perms smh

maiden fable
maiden fable
#

Was a total pain ngl

dry kelp
#

if i run it from the pc the command wont run

slate swan
dry kelp
#

weird lemme see

dry kelp
#

it will send the owner error for some reasons

fervent shoal
#

ok so onw

dry kelp
fervent shoal
#

it says the message, but doesnt add the role

dry kelp
#

bruh

pliant gulch
grim oar
#

😼

dry kelp
# dry kelp

@maiden fable why the keyerror pops up rn?

quick gust
fervent shoal
#

am i doing this right????

grim oar
grim oar
quick gust
#

it's a pos arg right?

fervent shoal
#

await member.add_roles?

dry kelp
#

it should lol

#

since the guild id is inside

fervent shoal
#

ima be real infernum

slate swan
pliant gulch
grim oar
dry kelp
#

whatever weird

fervent shoal
#

i dont know wha tha means

dry kelp
#

@maiden fable if i run it from the root

#

it works like this

#

no key errors

#

but it will load the channel id

fervent shoal
#

and for unmute its remove_roles instead of add_roles

grim oar
#

it's not for "unmuting" But yeah removes roles

fervent shoal
#

alr

dry kelp
quick gust
#

you can just do something Andy suggested if you want to remove all roles, Member.edit(roles=[])

pliant gulch
#

Role based mutes are very much useless now, ever since the timeout feature was added

grim oar
#

Andy is dum

pliant gulch
#

How!

dry kelp
slate swan
grim oar
#

^^

slate swan
#

Timeout can only go up to 28 days

grim oar
pliant gulch
slate swan
#

permanent

grim oar
#

Ah yes permission mutes

slate swan
#

i dont get why the method is named remove/add_roles when it takes a single snowflake

#

you can pass multiple

grim oar
#

^

dry kelp
slate swan
#

member.add_roles(role, role2, role3)

#

i see

#

member.add_roles(*args)

fervent shoal
slate swan
pliant gulch
grim oar
fervent shoal
#

bro the mute role isnt working

pliant gulch
#

Not to mention timeouts are persistent, meaning no database would be required anymore

slate swan
fervent shoal
#

why

grim oar
final iron
pliant gulch
slate swan
#

yes

pliant gulch
#

Ok that's good to know

fervent shoal
fervent shoal
grim oar
#

The error bro

fervent shoal
#

the mute command works

dry kelp
#

this is inside the json

fervent shoal
#

the stupid role itself dont work

final iron
#

Json, ew

slate swan
grim oar
# dry kelp

convert it to int then get_channel then channel.send

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):

        async for i in channel.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.channel_create):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(channel.guild.id)]:
                return
            
            await channel.guild.ban(i.user, reason="Anti-Nuke: Creating Channels")
            await i.target.delete(reason=f"Anti-Nuke: Deleting user created channels")

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            channel_config = config_channel[str(channel.guild.id)]
            try:
                channel_id = channel_config[0]
            except:
                pass

            if not str(channel.guild.id) in config_channel:
                return
            
            log_channel = self.angel.get_channel(channel_id)
            embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**CHANNEL LOGS**\n\nMember: {i.user}\nMember ID: {i.user.id}\n\nMember created a channel!\n\nMember has been **banned** out of the guild!\nChannel has been **deleted**!")
            await log_channel.send(embed=embed)
#

dude i am converting all this shit just look

pliant gulch
# slate swan

I was looking at the member object's attribute, they don't show the 28 days there

#

πŸ˜”

dry kelp
dry kelp
#

huh

#

then how wtf

grim oar
#

log_channel = self.angel.get_channel(int(channel_id))

dry kelp
#

oh aii

maiden fable
grim oar
#

Do it bro

pliant gulch
#

Was it from scratch or

grim oar
#

😼

maiden fable
grim oar
#

Andy's urge to shit on other dapi wrapper libs

maiden fable
#

πŸ˜‚ reasons I ain't sharing the codebase

dry kelp
pliant gulch
dry kelp
#

omfg

#

i will just fix the embed

slate swan
grim oar
pliant gulch
#

Yes I’m lost on how I should do application commands, I could write a fast implementation but it would be bulky as hell

#

I’ve seen some implementations but they are all the same

#

And end up being huge in implementing

slate swan
#

guys discord.py presence using application ID is working on phone but it shows 19k days on pc

#

why

grim oar
#

that's a long time

slate swan
#

must be quite an addiction dboatsHypersweat

maiden fable
#

Oh Dutchy here πŸ‘€

slate swan
#

No eyesshaking

maiden fable
#

Yes πŸ‘€

slate swan
#

ur hallucinating

maiden fable
slate swan
slate swan
maiden fable
maiden fable
slate swan
#

You can say its a work around for pypresence

slate swan
slate swan
pliant gulch
#

Stealing idea πŸ‘οΈ πŸ‘οΈ

#

I will build RPC into rin

grim oar
slate swan
slate swan
grim oar
slate swan
#

what can i saypithink

grim oar
#

Touch grass + L

pliant gulch
#

It's super cool!

slate swan
#

why?

grim oar
slate swan
#

Just use MultiRPC for custom game status CLf_ThinkDerp

maiden fable
slate swan
#

and many other

maiden fable
#

Oh wait it shows 15 hours on mobile

pliant gulch
#

I don't know I haven't read the docs yet

grim oar
#

let's ban them all

maiden fable
pliant gulch
grim oar
#

Nice example tho

#

Ye

pliant gulch
pliant gulch
maiden fable
# pliant gulch Sure

You will get a stroke reading through pypresence's source code, so u better not see that

#

Also, sadly, discord says they have added support for different activity types, but as usual, the API is bugged Β―_(ツ)_/Β―

grim oar
pliant gulch
#

😼 Me and the boys rocking concurrent requests

#

Semaphores are on a tight rope though, buggy as hell with gateway/bot

dire wind
#

how i can connect to proxy with socket module

neat tartan
#

what's the best way to grab a random image of a specific type from the web?

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            if before.icon == None and after.icon:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Icon")
                await after.edit(icon=None)

            try:
                before_icon = await before.icon.read()
            except:
                pass
            
            if before.icon:
                if before.icon != after.icon:
                    await after.ban(i.user, reason="Anti-Nuke: Changing Guild Icon")
                    try:
                        await after.edit(icon=before_icon)
                    except:
                        pass
            else:
                return

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            channel_config = config_channel[str(before.guild.id)]
            try:
                channel_id = channel_config[0]
            except:
                pass

            if not str(before.guild.id) in config_channel:
                return

            log_channel = self.angel.get_channel(int(channel_id))
            if before.icon == None and after.icon:
                embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**ICON LOGS**\n\n**__MEMBER__**\n\nMember: `{i.user}`\nMember ID: `{i.user.id}`\n\n**__ABOUT__**\n\nNon-Trusted member uploaded a guild icon!\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Icon has been set back to none!")
                await log_channel.send(embed=embed)

            if before.icon != after.icon:
                embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**ICON LOGS**\n\n**__MEMBER__**\n\nMember: `{i.user}`\nMember ID: `{i.user.id}`\n\n**__ABOUT__**\n\nNon-Trusted member uploaded a guild icon!\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Icon has been replaced!")
                await log_channel.send(embed=embed)
#

why are the logs not sending here?

#

@grim oar @maiden fable

#

found the error

strong vessel
#

is it possible to make video bot that generates and streams video to discord? wondering if it makes sense at all/possible at all

vocal snow
#

Discord doesn't allow bots to stream video

strong vessel
#

but i can stream music?

vocal snow
#

Yes

#

Audio is fine. No video

strong vessel
#

so the closest is i can keep posting mp4?

vocal snow
#

Yes but that would get you ratelimited

#

Better to just host the stream on a webserver and send a url

strong vessel
#

50 requests/second

vocal snow
#

It's 5messages per 5 seconds

strong vessel
vocal snow
#

Out of discord yes

strong vessel
vocal snow
#

Per bot

#

You could also try one of those integrations like YouTube together, but I'm not at all sure of how they work

strong vessel
#

maybe the rate limit was updated? All bots can make up to 50 requests per second to our API.

#

maybe the rate limit is bigger now?

royal oar
#

Can someone pls help me with this problem? Its picking up amount and guess as the same thing?

@commands.command()
    async def guess(self, ctx, amount:int, guess:int):
        """Guess a number 1-10
        guess: The number to guess.
        E.g:
        mother guess 100 2

        command is:
        guess <bet> <guess>
        """
        user = ctx.message.author
        bal = await update_bank(ctx.author)
        try:
            if  bal[0] < amount:
                await ctx.send(":red_circle: **{}, you can't bet more than you have!**".format(user.name))
                return
            if amount < 0:
                await ctx.send(":red_circle: **Must be greater than `0`!**")
                return
            if guess == 0:
                await ctx.send("Pls input a guess! <3")
                return
            if guess < 10:
                await ctx.send(":red_circle: **{}, you can't guess more than 10!!!**".format(user.name))
                return

            final = []
            for i in range(1):
                b = random.choice(["1","2","3","4","5","6","7","8","9","10"])
                final.append(b)
                await ctx.send(b)

            if final == guess:
                await ctx.send("**{}, you won ${} coins!**".format(user.mention, amount))
                await update_bank(ctx.author, 1*amount)
            else:
                await ctx.send("**{}, you lost ${} coins!**".format(user.mention, amount))
                await update_bank(ctx.author, -1*amount)
        except:
            await ctx.send("Didnt work")
vocal snow
main plover
#

hello i need help i want the input to be with speech recognition how to i implement it in the code?

    try:
        bot_input = input("You:")
        bot_response = get_response(bot_input)
        talk({bot_response})
        print(f'Gideon: {bot_response}')
    except (KeyboardInterrupt, EOFError, SystemExit):
        break;```
strong vessel
#

the bot is meant to be used in a lot of different servers though, as long as its not global rate limit its ok

vocal snow
#

Not global, it's probably per channel

strong vessel
#

ok

vocal snow
strong vessel
#

is it possible for a bot to join a voice chat and listen to what people are saying?

vocal snow
#

Yes

#

Afaik there are no python libs which have stable support for it though

strong vessel
#

so technically the bot could join the voice chat, while people stream from some private youtube url video?

#

so it would be a simulation of the video bot

dry kelp
#
    @commands.Cog.listener()
    async def on_guild_update(self, before, after):

        async for i in before.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.guild_update):

            with open(whitelist_path, "r") as f:
                whitelisted = json.load(f)

            if str(i.user.id) in whitelisted[str(i.guild.id)]:
                return

            if before.icon == None and after.icon:
                await after.ban(i.user, reason="Anti-Nuke: Changing Guild Icon")
                await after.edit(icon=None)

            try:
                before_icon = await before.icon.read()
            except:
                pass
            
            if before.icon:
                if before.icon != after.icon:
                    await after.ban(i.user, reason="Anti-Nuke: Changing Guild Icon")
                    try:
                        await after.edit(icon=before_icon)
                    except:
                        pass
            else:
                return

            with open(channel_path, "r") as f:
                config_channel = json.load(f)

            channel_config = config_channel[str(before.id)]
            try:
                channel_id = channel_config[0]
            except:
                pass

            if not str(before.id) in config_channel:
                return

            log_channel = self.angel.get_channel(int(channel_id))
            if before.icon == None and after.icon:
                embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**ICON LOGS**\n\n**__MEMBER__**\n\nMember: `{i.user}`\nMember ID: `{i.user.id}`\n\n**__ABOUT__**\n\nNon-Trusted member uploaded a guild icon!\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Icon has been set back to none!")
                await log_channel.send(embed=embed)

            if before.icon != after.icon:
                embed = discord.Embed(title="![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security") Anti-Nuke ![security](https://cdn.discordapp.com/emojis/907074407808241746.webp?size=128 "security")", description=f"**ICON LOGS**\n\n**__MEMBER__**\n\nMember: `{i.user}`\nMember ID: `{i.user.id}`\n\n**__ABOUT__**\n\nNon-Trusted member uploaded a guild icon!\n\n**__ACTIONS__**\n\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Non-Trusted member has been banned out of the server!\n![boop](https://cdn.discordapp.com/emojis/929782990618378341.webp?size=128 "boop") Icon has been replaced!")
                await log_channel.send(embed=embed)
#

why is this not sending to the log channel?

vocal snow
#

You want the bot to stream video right?

strong vessel
vocal snow
#

I see, that's interesting

strong vessel
#

not a serious thing i'm just seeing what discord supports

vocal snow
#

You could definitely do the first part

strong vessel
#

i see people stream all sorts of stuff on discord video chat

#

nvm then, it just doesn't make sense to simulate a video bot

#

someone would have to open the private youtube url, then stream their pc

#

too much of a hassle to make sense

neat tartan
#

i dont think video with bots really works because it typically is through a screencapture and most bots are hosted on servers that dont necessarily have screens

strong vessel
#

i meant it would just generate video as a realtime stream from the server as data, just like all those 24/7 youtube radio channels i guess (idk how youtube stream servers work but my guess is they just stream data 24/7 from servers)

royal oar
strong vessel
#

my goal was to emulate the 24/7 youtube radio stream, but as an interactive experience from discord, but it looks like it won't really work

neat tartan
#

ah

strong vessel
#

interactive/personalized video stream experience

neat tartan
#

probably not possible

strong vessel
#

ok

#

thanks a lot

royal oar
#

Can someone pls help figure out why its picking up guess as amount?

@commands.command()
    async def guess(self, ctx, amount:int, guess:int):
        """Guess a number 1-10
        guess: The number to guess.
        E.g:
        mother guess 100 2

        command is:
        guess <bet> <guess>
        """
        user = ctx.message.author
        bal = await update_bank(ctx.author)
        try:
            if  bal[0] < amount:
                await ctx.send(":red_circle: **{}, you can't bet more than you have!**".format(user.name))
                return
            if amount < 0:
                await ctx.send(":red_circle: **Must be greater than `0`!**")
                return
            if guess == 0:
                await ctx.send("Pls input a guess! <3")
                return
            if guess < 10:
                await ctx.send(":red_circle: **{}, you can't guess more than 10!!!**".format(user.name))
                return

This is the only part of the code affected

quaint scaffold
#

It shouldn't be swapping amount and guess

royal oar
quaint scaffold
#

Use the < > operators accordingly

royal oar
#

ahh ok

nimble plume
#

if AFK_PPL in message.content:
TypeError: 'in <string>' requires string as left operand, not list
huh?

slate swan
#

AFK_PPL is a list.

royal oar
#

like this?

neat tartan
#

i have the googleapiclient installed but its giving this error

royal oar
#

after you installed it?

neat tartan
#

i did not. forgot to do that

royal oar
#

just making sure

neat tartan
#

looks like that fixed it

royal oar
#

Lmao

neat tartan
#

thats caught me once before and i forgot about it

royal oar
#

Ive done the same thing many times when i first started

fervent shard
#

anyone know why the bot isnt replying to any commands??? no errors btw.

manic wing
fervent shard
manic wing
#

change the .event to .listen()

#

for the on_message

fervent shard
#

tysm

green bluff
manic wing
#

youre trying to load a cog that doesnt have a setup function

green bluff
#

how

#

what doesnt haev a setup function

slate swan
green bluff
#

yea ik

slate swan
green bluff
#

so i closed it in the explorer forgot to recycle the blank files

#

ik i added blank cogs oops

#

not explorer i mean editor

slate swan
#

no comments

green bluff
#

im stupid

slate swan
green bluff
royal oar
#

Can someone pls help me hide a cog file?
i use the

class hello(commands.Cog,command_attrs=dict(hidden=True)):

but it didnt work?

slate swan
green bluff
slate swan
slate swan
quick gust
royal oar
quaint scaffold
slate swan
quaint scaffold
#

Glad to hear it, but you should still learn the basics

quick gust
quick gust
#

only a single cog

slate swan
#

this wont work?

royal oar
quick gust
#

that will remove the whole help command altogether no?

slate swan
slate swan
royal oar
#

Yes

quick gust
#

it will, and that's not what they want

slate swan
#

hm, I see

quick gust
#

they only wanna hide a single cog

#

i understood this well because I also didn't know how to do that earlier lol

#

well i still don't

royal oar
#

i see

manic wing
#

what do you guys need help with?

#

infernum explain the problem and ill solve it smh

quick gust
#

hide a single cog from displaying in the help command

manic wing
#

in your help command just have a list of blacklisted cogs and check if the message they send is in the blacklisted

slate swan
manic wing
#

let me link to my help command

quick gust
#

wait

unkempt canyonBOT
#

cogs/helpcommand.py line 102

if cog.qualified_name not in self.data:```
tardy plume
#

what is this bot feature's called?

quick gust
#

This is when I do a.help in my help command and I wanna hide the Misc cog from displaying there (and it's commands)

quick gust
tardy plume
#

okk

royal oar
#

if so how would i have the code skip over such cog?

green bluff
#

it didnt edit my nick?

timid wagon
# green bluff it didnt edit my nick?
  1. Check if the bot has the permissions to do so. The bot can't edit nicknames of those that have a higher role than itself.
  2. Check if user_name is a string
  3. Confirm that you're using the command in the server, and not the bot's DMs
#

Other than that, it'd be great if you could mention any errors you get on using the command

pine crown
#
@client.event
async def on_slash_command_error(interaction, error):
  if isinstance(error, commands.MissingPermissions):
    embed=disnake.Embed(color=0xb30000, title="Error", description="You do not have the permission to use this command.")
    await interaction.send(embed=embed)

does isinstance have to be in a event or can i put it into a command?

minor bobcat
#

how do i fix it

maiden fable
#

Do u have multiple Python versions?

minor bobcat
#

no

#

wait i have

#

lol

#

it still doesnt work

minor bobcat
maiden fable
#

U have multiple of those

minor bobcat
#

no i fixed

maiden fable
#

3.10 and 3.9

minor bobcat
maiden fable
#

Now install again and select that version in yr IDE

minor bobcat
#

i restarted

#

3.10?

#

??

maiden fable
#

Yea

minor bobcat
#

bizzy downloading

#

i did

minor bobcat
#

what cmd

trail oxide
# dry kelp

how to code like the traceback gets send in a channel?

slate swan
#

send it in on_command_error

slate swan
minor bobcat
#

it wont work from the site

#

im on win 11

slate swan
minor bobcat
#

ok

#

ill do it

minor bobcat
slate swan
#

as u like

minor bobcat
#

ok i had that one installed

#

but it still doesnt let me have it

slate swan
#

Download the vsc python extension, it allows you to choose your python interpreter

#

watch some videos on youtube, that will help

#

And then Choose the interpreter with nextcord installed

minor bobcat
#

it worked

#

happy boy πŸ˜„

slate swan
#

how do i kick a member?

#

!d discord.Member.kick

unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
slate swan
#

Disnake has the same method

#

yeah im using slash one then i have to use inter right?

#

Are you adding a member option for the slash command?

#

yes

pine crown
#

how to make it so that if the bot doesnt have the permissions to do a command, it sends a message

slate swan
#

so just , member_option.kick()

slate swan
#

Eh

placid skiff
#

!d discord.ext.commands.BotMissingPermissions

unkempt canyonBOT
#

exception discord.ext.commands.BotMissingPermissions(missing_permissions, *args)```
Exception raised when the bot’s member lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
minor bobcat
#

hey i migrated to nextcord but i cant find how to make buttons

pine crown
#

m

minor bobcat
#

m?

quaint scaffold
slate swan
#

Or use edpy GWcentralPikaLUL

minor bobcat
#

cause i am

slate swan
maiden fable
#

πŸ‘€

#

Dutchy here again

pine crown
#

The issue is, is that the slash command doesnt send a error in console when it doesnt have perms to ban someone

#

so that doesnt work

placid skiff
timid wagon
timid wagon
#

The issue would be that the slash command would show an "Interaction failed" error of some sort

#

If you want the user to see "Could not kick/ban user...", the simplest way to get that would be to wrap everything in a try-except block - with that statement being shown if it fails

#
async def ban(inter, member: disnake.Member):
    try:
        ...
    except Exception as e:
        await inter.response.send("I can't do that lol")
        print(e)```
pine crown
#

ok

#

so the try is the command?

teal swan
#

Hey guys I'm working on a bot for a MMO clan and one of the features my clan needs is for it to be able to track prices of market transactions internal to the clan where you could input how much you bought/sold something and then it can be checked later by other members. I wonder how to approach this, I'm thinking perhaps a Dictionary will work here where each category materials/full items/etc will be a dictionary and each item within it another dictionary where every sale can be added together with the date as a list and then easily checked. Is this a good approach? I wonder how to tackle this best.

timid wagon
pine crown
#

ok

#

thx\

timid wagon
#

So yes, 'try' refers to what you want your command to normally do

#

Yep

pine crown
# timid wagon So yes, 'try' refers to what you want your command to normally do
@commands.has_permissions(kick_members=True)
@client.slash_command(description="Kicks a user")
async def kick(ctx, user: disnake.Member=None, reason="The reason was not entered"):
  try:
    if user is None:
      embed=disnake.Embed(color=0xb30000, title="Member not found", description="Please enter the user you want to kick.")
      await ctx.send(embed=embed)
    elif user == ctx.author:
      embed=disnake.Embed(color=0xb30000, title="Error", description="You cannot kick yourself.")
      await ctx.send(embed=embed)
    elif user.guild_permissions.administrator:
      embed=disnake.Embed(color=0xb30000, title="Error", description="You cannot kick a admin.")
      await ctx.send(embed=embed)
    else:
      await user.send(f"You have been kicked from {user.guild.name} for **{reason}** by {ctx.author.mention}")
      await user.kick(reason=reason)
      embed=disnake.Embed(color=0x00d60e, title=f"Successfully kicked {user}", description=f"Kicked {user.name} for **{reason}** by {ctx.author.mention}")
      await ctx.send(embed=embed)
  except Exception as e:
    await ctx.send("I can't do that lol")
    print(e)

i tried it and it didnt wor

dim hazel
#
@commands.has_permissions(administrator=True)
async def createticket(self, ctx, *args):
        format_args = list(args)

        guild_id = ctx.message.guild.id
        channel_id = int(format_args[0].strip('<').strip('>').replace('#', ''))
        title = ' '.join(format_args[1:])

        with open('ticket.json', 'r') as file:
            ticket_data = json.load(file)
            new_ticket = str(guild_id)

            # Update existing ticket
            if new_ticket in ticket_data:
                ticket_data[new_ticket] += [channel_id]
                with open('ticket.json', 'w') as update_ticket_data:
                    json.dump(ticket_data, update_ticket_data, indent=4)

            # Add new ticket
            else:
                ticket_data[new_ticket] = [channel_id]
                with open('ticket.json', 'w') as new_ticket_data:
                    json.dump(ticket_data, new_ticket_data, indent=4)

        # Create new embed with reaction
        ticket_embed = discord.Embed(colour=randint(0, 0xffffff))
        ticket_embed.set_thumbnail(
            url=f'https://cdn.discordapp.com/icons/{guild_id}/{ctx.message.guild.icon}.png')

        ticket_embed.add_field(name=f'Welcome To {ctx.message.guild} Server', value=f'{title}')
        send_ticket_embed = await self.bot.get_channel(channel_id).send(embed=ticket_embed)

        await send_ticket_embed.add_reaction(u'\U0001F3AB')
```   guild_id = ctx.message.guild.id
AttributeError: 'str' object has no attribute 'message'
honest vessel
timid wagon
dim hazel
timid wagon
#

I assume not, since you're using client.command

slate swan
#

you don't need self there

timid wagon
#

^

slate swan
#

and do you even know what *arg does?

timid wagon
honest vessel
#

yes remove self

#

seems like ctx gets passed as a string

timid wagon
#

You could've easily made channel an arg and continued with *, title now that I look at the code

pine crown
timid wagon
dim hazel
pine crown
timid wagon
#

That would give a 403 error

timid wagon
timid wagon
pine crown
#

Oh wait

#

nvm

timid wagon
pine crown
#

My mistake

#

the user not in the server

timid wagon
#

Ah alr

dry kelp
#

[<Role id=937845206894669865 name='new role'>]

#

how do i get the role id from the list?

timid wagon
#

If you're getting it from the user's roles, it's a good idea to use utils.get

slate swan
timid wagon
slate swan
timid wagon
slate swan
fervent shard
#

idk why but it doesnt send the welcome message when someone joined my server.

@bot.event
async def on_member_join(member):
  guild = bot.get_guild(931454966781079553)
  role = discord.utils.get(member.guild.roles, name="unverified")
  await member.add_roles(role)
  embed = discord.Embed(description=f"hey, {member.mention}! welcome to {guild.name}!", colour = 0)
  embed.set_author(name=member.name, icon_url=member.avatar_url)
  embed.set_footer(text="royale high trading | coded by mar.#9585")
  await bot.get_channel(938291931367219291).send(content=None, embed=embed)```**no errors!**
placid skiff
#

sorry guys this is not related directly to bots but i have a lapsus and i'm going crazy:

n = [m.upper() for m in ms]

what is the name of this expression?

unkempt canyonBOT
#

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if statement:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

placid skiff
maiden fable
#

List comprehension?

slate swan
#

In your command line, use pip install <module>
That's one way of doing it

fervent shard
maiden fable
slate swan
maiden fable
#

Hmm

timid wagon
slate swan
#

How do I randomly generate an embed from a defined list?

#

A list of embeds?

#

Ye

maiden fable
unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
slate swan
#

use random.choice

slate swan
#

Say for instance here

timid wagon
slate swan
#

Say it is a command and not an event

#

So, I want to put multiple embeds

#

embed1
embed2
embed3 like that

#

So how should I modify the last line?

#

oh, multiple embeds together?

maiden fable
#

embeds=

slate swan
#

one at a time

#

random

#

use embed=random.choice(list_of_embeds)

#

And send it

timid wagon
#

and wrap that in a for loop if need be

#

Do you want all the random embeds to be different?

maiden fable
#

Abhi, go work on the guide πŸ‘€

slate swan
timid wagon
#

I will, soon

maiden fable
#

Do it now

timid wagon
#

I needed a break lol

slate swan
#

different descriptions, titles, and so on

maiden fable
slate swan
#

creepy Do it faster so we can just link it to everyone when we suggest ppl to use disnake

timid wagon
maiden fable
timid wagon
#

Well then, I'll go write smth

timid wagon
maiden fable
#

Yes.

slate swan
#

!d discord.Member.ban

unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
maiden fable
#

!d discord.Guild.ban also exists BTW

unkempt canyonBOT
#

await ban(user, *, reason=None, delete_message_days=1)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Bans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
slate swan
#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
dim hazel
#

'Message' object has no attribute 'fetch_message'

slate swan
#
@client.command()
@commands.has_permissions(administrator=True)
async def purge(ctx, amount: int):
    if amount > 100:
        amount = 100
        await ctx.channel.purge(limit= amount + 1)
#

I want this code to show the error if the amount is not written

#

Like, when the number of messages is not written, the error shows in terminal

#

I want it to give message in chat instead

#

Tried using else: function

#

did not work as expected

#

sorry im noob lol

oblique adder
#

best way to check if a message is not from a dm in on_message ?

slate swan
slate swan
slate swan
#

i tried seeing example on stack overflow but it shows that it was defined in async def on_command_error(error, commands.CommandNotFound)

nimble plume
#

how to set user nick to default*

#

@slate swan

slate swan
#

use member.edit(nick=None)

nimble plume
#

lol

#

we both edit at same time

slate swan
#

should be a Member, not User

nimble plume
#

my variable my wish

#

Β―_(ツ)_/Β―

#

lol

slate swan
#

im talking about the variable's class, not the variable name

analog nova
#
    @commands.command(aliases=["b"])
    @cooldown(1, 2, BucketType.user)
    async def buy(self, ctx, item):
        """ Buy an item from the market"""
        member = ctx.author
        bal = await ecomoney.find_one({"id": ctx.author.id})
        if bal is None:
            await self.open_account(ctx.author.id)
            bal = await ecomoney.find_one({"id": ctx.author.id})
            return
        elif item == "sgiveaway":
            sgive = 1000
            ubal = bal["bank"]
            role = discord.utils.get(ctx.guild.roles, 938709559462207518)
            await ecomoney.update_one({"id": ctx.author.id}, {"$inc": {"bank": - sgive}})
            for role in ctx.guild.roles:
                await member.add_roles(role)
            await ctx.send(f"You bought {item} for {sgive}$TPET!")
            if ubal < sgive:
                await ctx.send("Check your balance, I don't think you have enough. . .")
            elif "sgiveaway" not in ctx.message.server.roles:
                await ctx.send("That role doesn't exist.")
            elif "sgiveaway" in ctx.message.author.roles:
                await ctx.send("You already have that role, wanna waste more money on that eh?")
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/container/cogs/shop.py", line 135, in buy
    await member.add_roles(role)
  File "/home/container/.local/lib/python3.8/site-packages/discord/member.py", line 777, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "/home/container/.local/lib/python3.8/site-packages/discord/http.py", line 250, in request
    raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role

slate swan
analog nova
#

ah

slate swan
#

role = discord.utils.get(ctx.guild.roles, id=938709559462207518)

analog nova
#

might have forgoten about that :)

#

still shows up with Unknown Role

boreal ravine
#

The role doesn't exist

analog nova
#

well, i must've gotten the id from somewhere

#

it has, and does exist

boreal ravine
#

did you double check

analog nova
#

yes

boreal ravine
#

hm

slate swan
# analog nova **yes**
            for role in ctx.guild.roles:
                await member.add_roles(role)
``` this is the line from where the error comes right? it may be because the bot tries to add all the roles including the `everyone` role, and other integrated rples
analog nova
#

yep

#

135 is await member.add_roles(role)

slate swan
analog nova
#

i believe its 1.7.3

slate swan
#

since 2.0 has role.is_assignable() which may help

analog nova
#

the latest-stable one

slate swan
analog nova
#

nope

#

its just a regular role

slate swan
#

well you loop thru all the roles in the server no

analog nova
#

so should i just remove for role in ctx.guild.roles:?

slate swan
#

you want to add a single role right?

analog nova
#

yup

slate swan
#

yea so there's no need of it

quaint scaffold
#

!d discord.Guild.get_role

unkempt canyonBOT
slate swan
#

just define that role ( you already did ) , and member.add_roles(role)

analog nova
#

πŸ‘ .

#

works fine!

#

thanks

slate swan
#

why cant i use - btw in function name

slate swan
#
@command(name='it-has-dashes')
async def name_it_anything(...```
normal jasper
#

so guys i want to make my command to have cooldown and i know how to , but , when someone runs the command and it causes an error like not enough arguments or umm anything like BadArguments , and they can't use it untill the cooldown is over even they didn't used the command correctly before

nimble plume
#

how to get server owner.

#

im using ctx.guild.owner

slate swan
#

yea it should work. but it needs member intents

nimble plume
#

intents= discord.Intents.default()
intents.members = True

#

got from google ngl

nimble plume
#

bot = commands.Bot( command_prefix= (prefix), intents=intents)

#

@slate swan how to get permmision of a member

#

!userinfo

#

mainly

slate swan
#

wdym by major permissions

nimble plume
nimble plume
slate swan
#

!d discord.Member.guild_permissions

unkempt canyonBOT
#

property guild_permissions: discord.permissions.Permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").

This does take into consideration guild ownership and the administrator implication.
nimble plume
#

k

meager creek
#
@cog_ext.cog_slash(name = 'openevent', description = 'Open voice channel event', guild_ids = [933988798218506331])
@commands.has_any_role(938511801262420008)
async def _openevent(self, ctx: SlashContext, name = choice['monopoly', 'bunker', 'mafia']):
    await ctx.send('test')
``` not working(
slate swan
#

dont use 3rd party libraries, use some fork instead

surreal sierra
#

I got a small problem, no idea whats causing it. the problem is that every command with an embed in the bot gets sent 3 times but it is just the embeds. if the bot sends a normal msg it will only send it once and all the commands is shared up in different cogs and files so Im not sure how I would show the code if not showing all of it. but if you got any ideas that could help pls tell me , thanks

surreal sierra
# slate swan Show one of the commands

here is one of the commands that has that problem

class cogs(commands.Cog):
    def __init__(self, Bot):
        self.bot = Bot

#   Server Information
    @commands.command(name="serverinfo", aliases=["server", "sinfo"])
    async def serverinfo(self, ctx):
        name = str(ctx.guild.name)
        description = str(ctx.guild.description)

        owner = str(ctx.guild.owner)
        server_id = str(ctx.guild.id)
        region = str(ctx.guild.region)
        member_count = str(ctx.guild.member_count)

        icon = str(ctx.guild.icon_url)

        embed = discord.Embed(
            title=name + " Server Information",
            description=description,
            color=0x007011
        )
        embed.set_thumbnail(url=icon)
        embed.add_field(name="Owner:", value=owner, inline=True)
        embed.add_field(name="Server ID:", value=server_id, inline=True)
        embed.add_field(name="Region:", value=region, inline=True)
        embed.add_field(name="Member Count:", value=member_count, inline=True)
        embed.set_thumbnail(
            url='https://cdn.discordapp.com/attachments/776904474458980364/785904953868550194/RoseCliff_'
                'Test_3.png')

        await ctx.send(embed=embed)
        print(f'{ctx.message.author} said - "!server"')

def setup(bot):
    bot.add_cog(cogs(bot))
slate swan
#

if yes, remove the process_commands thing from them

surreal sierra
#

I dont have on_message in the cog

slate swan
#

well the command seems ok, how many times does it print user said - "!server"

surreal sierra
#

only once

#

but the embed gets sent 3 times

slate swan
#

you are having multiple instances of the bot maybe

#

what ide are u using currently

surreal sierra
#

Im using pycharm

slate swan
#

check the tasks and see if there are multiple instances running, that "may be" the issue

slate swan
slate swan
surreal sierra
boreal ravine
#

what sarthak said

#

you have multiple instances running

visual island
boreal ravine
#

try refreshing your token, and use that one

slate swan
boreal ravine
#

it overwrites the old thumbnail

visual island
#

yeah, just wondering

surreal sierra
maiden fable
#

IDFK how many useless variables it has

final iron
#

Damn

maiden fable
#

Lmao

surreal sierra
# visual island

oh I didnt see that, thanks but that or what @final iron said wont solve the problem. the problem is not just this command in this cog, the problem is around every command that has an embed in all cogs.

surreal sierra
visual island
maiden fable
#

@surreal sierra do u have an on_message?

cobalt jacinth
#

any way to use opencv with discord bot...it works but its blocking.

maiden fable
#

!d asyncio.loop.run_in_executor

unkempt canyonBOT
#

awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.

The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.

Example:
surreal sierra
surreal sierra
surreal sierra
cobalt jacinth
final iron
#

!d asyncio.loop.create_task

unkempt canyonBOT
#

loop.create_task(coro, *, name=None)```
Schedule the execution of a [Coroutines](https://docs.python.org/3/library/asyncio-task.html#coroutine). Return a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") object.

Third-party event loops can use their own subclass of [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") for interoperability. In this case, the result type is a subclass of [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task").

If the *name* argument is provided and not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").

Changed in version 3.8: Added the `name` parameter.
final iron
#

Wouldnt this work instead of run_in_executor?

maiden fable
#

No

visual island
#

that happens on me too sometimes

surreal sierra
visual island
#

yeah that's multiple instance running issue

surreal sierra
visual island
#

you should end both Python and Python <version> too

surreal sierra
visual island
#

yeah

maiden fable
#

game suggestions?

#

Ah

visual island
#

tic tac toe

maiden fable
#

Idk

#

I mean there is a tutorial on how to make ttt in discord.py repo lmao

final iron
#

Just steal someone else's code

maiden fable
slate swan
#

My main.py is getting larger and is getting cluttered. How should I proceed with moving the commands to other files?

#

Use cogs

leaden jasper
#

is there an event to detect server owner transfership?

boreal ravine
#

nope

visual island
#

on_guild_update, check after.owner and before.owner

slate swan
#

or after.owner_id and before.owner_id if you don't have member intents catstare

#

how do i check for a specific role of user?

#

!d discord.Member.roles

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.
quick gust
#

mailto:'%40everyone'
what's this in the embed

boreal ravine
#

An everyone ping

quick gust
#

oh mobile discord smh

maiden fable
visual island
boreal ravine
#

this isn't related to discord bots..

#

that is not allowed by discord

#

what library?

#

i think it is anyways

#

mobile discord on a bot

#

what does that prove?

#

no idea

visual island
#

yeah there's no rules regarding that.

boreal ravine
#

ok

#

what library is your bot using?

void mist
#

How do I delete my bot's own message?

boreal ravine
#

but danny doesn't propagate this and we should always trust danny lol

boreal ravine
unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
boreal ravine
#

get the message object, use that on it

void mist
#

thanks

boreal ravine
#

yessir

visual island
#

@slate swan
Modify the lib in file discord/gateway.py. Find lines 292 - 293

                    '$os': sys.platform,
                    '$browser': 'discord.py',β€Š

and edit them to get

                    '$os': 'ios', # or 'android'
                    '$browser': 'Discord iOS', # or 'Discord Android'
``` if you really want this
#

but it isn't that cool imo

void mist
visual island
#

that's not how you use methods

void mist
#

oh

slate swan
void mist
#

I'm not that good at python so

boreal ravine
#

and everything after * are kwargs

slate swan
void mist
#

but it was easy until now

slate swan
visual island
red sundial
void mist
#

ok

#

anyway, thanks

visual island
#

the websocket thing?

#

it's a problem with your code

wary spear
#

someone,please help me with adding the
"Add" command to my discord bot Zer0

visual island
#

"Add" command?

#

...

#

what are you trying to do

slate swan
#

i lost all my codes for my bot in vsl can someone help

visual island
#

run your bot with the normal way, with the source code edited. After it's online, it will have mobile status

placid skiff
#

Guys I have some subcommand in my code, my question is:
When i call subcommand, first of all the code executes the original command, if I write some code in there it will be executed, no metter what subcommand is called. Now i want to add a description which will be called when i use the command without any subcommand, how to not let the other subcommand execute that description too?

spring flax
#

any idea why this returns []

    @disnake.ui.button(label="Nickname History", style=disnake.ButtonStyle.green)
    async def nicknames(self, _,interaction: disnake.Interaction):
        async with bot.db.execute("SELECT prev_name, time FROM usernames WHERE userid=?", (self.member.id,)) as cursor:
            data = await cursor.fetchall()
            print(data)```
placid skiff
visual island
placid skiff
spring flax
visual island
quick gust
#

doesnt that just return None? I might be wrong

placid skiff
# spring flax nope

Then how it works lol? what is bot? why you call it before the db. Btw if the list is empty means that he founds nothing

spring flax
spring flax
visual island
#

πŸ‘

placid skiff
#

just trying to understan what "bot" is

spring flax
#

You mean bot.db?

placid skiff
#

yes

spring flax
#

I just made a bot variable

placid skiff
#

and what is this variable D_D

spring flax
#
bot = commands.Bot(command_prefix=';', intents=intent)
bot.db = bot.loop.run_until_complete(aiosqlite.connect("database_name.db"))
visual island
#

no, maybe the you updated websocket library and your code became broken? Unsure..

placid skiff
#

Finally, lol. So the problem is the query, it founds nothing in the record and returns an empty list

visual island
#

πŸ‘

spring flax
#

    @disnake.ui.button(label="Nickname History", style=disnake.ButtonStyle.green)
    async def nicknames(self, _,interaction: disnake.Interaction):
        async with bot.db.execute("SELECT prev_name, time FROM usernames WHERE userid=?", (self.member.id,)) as cursor:
            data = await cursor.fetchall()
            print(data)

this prints []

visual island
#

can you try selecting everything first? SELECT * FROM usernames

slate swan
#

did you save userid column as TEXT?

visual island
slate swan
#

iirc Sqlite won't take an INT / REAL larger than 16 digits, and a user's id is 18 digit long

spring flax
visual island
#

yeah

spring flax
#

also I'm getting sqlite3.OperationalError: no such column: before_nick now

boreal ravine
#

why did i think xcirno was that one russian guy who always asks for help here hm

visual island
spring flax
#

wait whoooops

placid skiff
pine crown
#

is sqlite hard

visual island
#

no

placid skiff
#

not at all

pine crown
white perch
#

Whats the best remote database service i could use for discord bots

magic ore
#

why do you need it to be remote?

maiden fable
placid skiff
#

someone knows how to take a list of disnake object (list, roles, guilds) as parameter in a slash command using disnake?

maiden fable
slate swan
#

whats the option type for timeout

slate swan
placid skiff
#

well, i don't have it yet cuz i have to code it lol

slate swan
cobalt jacinth
#

hey...is using opencv for image processing in discord bot a good idea ? i assume its gonna need some serious compuation power to process hundreds of images same time ?

slate swan
#

Why would a discord bot need to process hundreds of images at the same time? FeelsSusThink

cobalt jacinth
#

like a user upload a image and bot needs to find some shapes in it and return the image with locations marked

#

i think this needs a lot of cpu power

placid skiff
cobalt jacinth
#

yeah its blocking

placid skiff
#

then is not possible

cobalt jacinth
#

i tried searching non-blocking opencv on google...got nothing useful

placid skiff
#

Well maybe

#

will You save the image that the user will send? even for a moment only?

potent spear
placid skiff
#

it is not necessary, if he can run the opencv script from a different interpreter it could work

#

it will be a little slower but with opencv you can never say how many time it will take to operate

slate swan
#

What is the difference between @client.command() and @commands.command()?

potent spear
slate swan
#

hmm

#

so like can classes only be on cogs?

placid skiff
potent spear
#

or you use *, shits: shitClass
or you can use
shits: typing.Greedy[shitClass]

quick gust
#

sniper and his shits

slate swan
#

commands.Cog.listener()

#

Can someone explain whats this for?

timid wagon
slate swan
#

ah

#

thanks

timid wagon
#

Yep

slate swan
#

I have created a discord bot that sends embeded message to a channel. How do i close the bot so it can sent another message

potent spear
#

are you even using an API wrapper for this?

slate swan
# potent spear why would you close the bot to send another message?

I created this:

class Discord_bot:
    def discord_message(self, id, test1, test2, test3):
                
        @client.event
        async def on_ready():
            channel = client.get_channel(id)
            embed=discord.Embed(title=test1, url=test2, description=test3, color=0xff0000)

            embed.set_footer(text="Test")

            await channel.send(embed=embed)

            # Run the client on the server
        
            client.run(DISCORD_TOKEN)

in another python file i call this function in a loop. Everytime when test1 == test1 for example i would like to call the function. This is not possible because the bot is not closing

            message = discord_bot.discord_message(id, test1, test2, test3)
                message()

cold sonnet
#

inherit commands.Bot to your class please

#

and I just don't know why you wouldn't choose the easy way, this doesn't seem right

#

you run the bot on_ready

kindred epoch
#

I tried getting an epoch timestamp from an embed and converted it into a datetime timestamp but when i try to use sleep_until it yields instantly even tho the time is 12 pm est.

cold sonnet
sick birch
#

You can either have it on the outermost level, or have it within a commands.Bot subclass and override on_ready, without the @bot.event decorator

honest vessel
#

sum say dont use on ready

#

cus it can be retriggered

sick birch
#

Yes you can print in on_ready but that should be about it

sick birch
pliant gulch
#

πŸ‘οΈ πŸ‘οΈ

solid summit
#

Philosophical bot dev

cold sonnet
#

how that works

stone moon
#

how can i assign the display roles above everyone permission to a role
discord.py
how do i fetch the message link of a message

final iron
#

!d discord.Message.jump_url

unkempt canyonBOT
stone moon
stone moon
#

so like print(message.id.jump_url)

manic wing
#

not .id

slate swan
#

message.jump_url

#

I want to create a command which randomly assigns a role

#

From a list

slate swan
slate swan
#

can lists contain roles?

slate swan
slate swan
#

oooh

#

should they be in the form of strings?

#

no

slate swan
#

add roles only accepts a role obj or ints

manic wing
#

it doesnt accept int

slate swan
#

uh

#

self.client.get_role

#

dont billy me im a 1 month old coder

slate swan
#

@async def on_message(message):
if message.content == "give me admin"
role = discord.utils.get(server.roles, name="Admin")
await client.add_roles(message.author.id, role)

#

penises

#
@async def on_message(message):
     if message.content == "give me admin"
           role = discord.utils.get(server.roles, name="Admin")
           await client.add_roles(message.author.id, role)
#

its going to be self assignable

#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

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

How do I make timeout user command?

slate swan
unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
void mist
#

thanks

slate swan
#

what the fuck is disnake i took a 2 month vacation and idek what these new stuff is

#

its a fork

#

oh

#

!pypi disnake

unkempt canyonBOT
manic wing
#

disnake is the only discord fork

slate swan
#

😭

#

looks nice

#

sexy

#

😳

sick birch
slate swan
#

L

#

W

slate swan
#

be a chad and use listenpithink

sick birch
#

Or that too

slate swan
#

and robin you can react here awe😠

sick birch
#

Though on_message particularly has a useful case for @bot.event

slate swan
#

nICE

sick birch
manic wing
#

did you know that creating a bot.event for on_message event is exactly the same as overriding the on_message function in subclassed Bot?

sick birch
#

Yep, same with all the other events iirc?

manic wing
#

not really

#

the other events might have code in them

sick birch
#

True I think on_message is a special case since it's kind of a gateway to the command handlers i guess you'd say

#

That's why a lot of people forget the process_commands() at the end and none of their commands work

#

You can kind of use that to your advantage sometimes

#

Such as blacklisted users, blacklisted guilds or channels, not picking up bot messages, etc..

sick birch
#

sure they could act as checks

#

but only for messages

manic wing
sick birch
#

heh

manic wing
#

!pypi disnake-debug

unkempt canyonBOT
#

A visual debugging extension for disnake discord bots including easy blacklisting, evaluation, echoing and much more!

kindred epoch
#

I tried getting an epoch timestamp from an embed and converted it into a datetime timestamp but when i try to use sleep_until it yields instantly even tho the time is 12 pm est. any idea why?

honest vessel
#

troll server

#

i hope one sees it n copy pasta it n bans yall

honest vessel
#

yeah wtf is server

slate swan
#

where do i define it

#

what do i define server as

honest vessel
#

just rewrite it as on_message -> give admin

#

problem solved

slate swan
#

hmm

honest vessel
#

anyone who types gets admin

#

@slate swani mean aperently u dont even know how to make a simple variable

slate swan
reef trail
#
CommandInvokeError: Command raised an exception: TypeError: Object of type TextChannel is not JSON serializable``` the hell does this mean
honest vessel
#

@slate swanu still has no clue of python and cant make a simple variable

#

your error is what u learn when u try make a hello world python script kinda

slate swan
#

print("hello world")

honest vessel
#

print(server)

#

prob same error

blissful lagoon
#

!tempban 417154674555224077 1w This attitude is not appropriate for our server. You will not be rude to the people asking for help.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @honest vessel until <t:1644511645:f> (6 days and 23 hours).

sick birch
# slate swan

servers are referred to as "guilds", so to get the "server", you would do message.guild

kindred epoch
#

Im getting an epoch timestamp from an embed and converting it into a datetime timestamp but when i try to use sleep_until it yields instantly even tho the time is 12 pm est. any idea why?

slate swan
#

thanks

sick birch
#

Great! Working now?

kindred epoch
#

robin a helper now??

snow ibex
#

Robin poggin

neat tartan
slate swan
#

let me send

#

thanks for the help btw

sick birch
#

You're looking for member.add_roles

slate swan
#

hmm

quick gust
#

!d disnake.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s.

You must have the [`manage_roles`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_roles "disnake.Permissions.manage_roles") permission to use this, and the added [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s must appear lower in the list of roles than the highest role of the member.
sick birch
slate swan
sick birch
#

If you have any specific questions such as why isn't a part of your code working or how would you go about implementing a certain feature, we would be more than happy to help

slate swan
sick birch
#

You can get the discord.Member instance from message.author, which is the person who made the message