#discord-bots

1 messages ยท Page 994 of 1

feral lichen
#

prolly not

slate swan
#

no errors

#

emoji*

#

Im not talking to u

#

@slate swan

#

hm ic

#

@slate swan

#

why would you compare it with an emoji then ๐Ÿ˜”

#

what?

#

cause emojis are cool

#

and so are roles

#

Idk never worked much with emoji

slate swan
vale wing
#

arg is a str what kind of "content" you want to access

slate swan
#

!role @novodyfound hyperlemon

#

replace arg with message

vale wing
#

Typehint it with discord.Emoji if you are trying to compare the emojis and remove that "content" emoji has no such attribute

vale wing
slate swan
#

also use a event

vale wing
#

It's a command

#

Or he wants to make sort of reaction role

feral lichen
#

no

slate swan
#

Why event?

#

event is much better with these kinds of things

#

No?

#
@Command
async def role(ctx, member: discord.Member, arg: discord.Emoji):
  emoji = bot.get_emoji()
  if arg.id == emoji.id:
    _role = bot.get_role(role_id)
    await member.add_roles(_role)

wont something like this work?

vale wing
#

Private var lemon_thinking

slate swan
#

what

vale wing
#

Afaik you can just compare the emojis without ID but I am not sure about that

#

Eh

slate swan
#

๐Ÿ˜”

vale wing
#

!d discord.Emoji

slate swan
#

cant we just use if arg == ๐ŸŽ‰

#

F

vale wing
#

Idk how it checks the equality

#

You can check source code for Emoji.__eq__

#

That's equality magic method iirc

slate swan
#

Bruh

#

!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`...
feral lichen
#

bro im getting 3 diff answers confusion

slate swan
#

Go with ash

#

She gived spoonfeed code

vale wing
#

@feral lichen could you please describe what exactly you need, a command that gives a role based on provided emoji or smth

slate swan
#

do u want reaction roles?

feral lichen
vale wing
#

Ok

#

Make a dict of {emoji_id: role_id} and typehint emoji arg with discord.Emoji simple solution

feral lichen
#

.

vale wing
#

Not gonna give full code cause no time unfortunately

feral lichen
#

of course

slate swan
maiden fable
#

Bros, just use emoji1.id == emoji2.id

slate swan
#

@slate swan tried and still doesnt work

#

any help yet?

soft thunder
#

I need some personal opinions on something:

do you think it is easier to use slash commands for bots, or use a symbol prefix?

slate swan
#

    @role.group(pass_context=True)
    async def delete(self, ctx, role: str):
        role = discord.utils.get(ctx.guild.roles, name=role)
        if role not in ctx.guild.roles:
            await ctx.send(f"there is no role named **{role}**")
        else:
            discord.utils.get(ctx.guild.roles, name=role)
            await role.delete()
            await ctx.send(f"role **{role}** has been deleted :thumbsup:")

anyone any ideas? when i try to delete a none existing role i get this: https://tokyotokyotokyotokyo.tokyo/โ€‹โ€‹โ€Œโ€Œโ€‹โ€Œโ€‹โ€Œโ€‹โ€‹โ€Œโ€Œโ€‹โ€Œโ€‹โ€Œโ€‹โ€Œโ€Œโ€‹โ€Œโ€‹โ€‹โ€‹โ€‹โ€‹โ€Œโ€Œโ€‹โ€Œโ€Œโ€Œโ€‹โ€Œโ€‹โ€‹โ€‹โ€Œโ€Œโ€‹โ€‹โ€Œโ€‹โ€‹โ€‹โ€Œโ€‹โ€‹โ€‹โ€Œโ€Œโ€‹โ€Œโ€Œโ€Œโ€‹โ€‹โ€Œโ€Œโ€Œโ€‹โ€‹โ€Œโ€Œ

slate swan
slate swan
#

no need to get the role

#

doesnt work

slate swan
torn sail
#

What about it didnโ€™t work?

slate swan
#

?

#
    @role.group()
    async def delete(self, ctx, role: discord.Role):
        if role not in ctx.guild.roles:
            await ctx.send(f"there is no role named **{role}**")
        else:
            await role.delete()
            await ctx.send(f"role **{role}** has been deleted ๐Ÿ‘")
#

it doesnt even send a message at all

#

error?

#

no error either

#

Try excpet in role . Delete

#

Exception

soft thunder
torn sail
slate swan
#
else:
           try: 
                role.delete()
           except Exception as e:
               await ctx.send(e)
#

Sorry for indents im not on pc

#

allg

slate swan
#

It will raise error in console

#

U need a error handler for that

#
    @role.group()
    async def delete(self, ctx, role: discord.Role):
        if role not in ctx.guild.roles:
            await ctx.send(f"there is no role named **{role}**")
        else:
            try:
                await role.delete()
            except Exception as e:
                print(e)

torn sail
slate swan
#

Ye try

slate swan
#

im tryna make it so if the role doesnt exist, it sends this message: await ctx.send(f"there is no role named {role}")

#

no no wait

#

you are using the variable where it searches the role and when it can't find it it returns as none

#

you get it?

torn sail
slate swan
#

Ego try run the cmd

slate swan
slate swan
slate swan
#

and then sending it

slate swan
slate swan
#

No

#

then await ctx.send(rolename)

clever hamlet
#

@slate swanhey can i ask something

slate swan
#

Ill give code wait

slate swan
#

no need to get mad at eachother

slate swan
daring olive
#

hello

slate swan
daring olive
#

wow this aggression, tone it down 80%

boreal ravine
#

chill

slate swan
slate swan
clever hamlet
# slate swan ?

can u give me a script that a person will enter my server it will give automatically a role sorry for my bad grammar

slate swan
#

i am explaining you man

#

you are trying printing something that doesn't exist that's why it is none

slate swan
slate swan
#

because you made a var named rolenthen searched the role and when it couldn't find role it returned none and for that var it is none not role name

slate swan
#

make a variable named different than role

#

@slate swan

#

@slate swan u know what is typehint

#

sparky man

#

yes

clever hamlet
slate swan
#

look here

#

yes thats why use typehint?

#

role = discord.utils.get()
and if there is no role how can it print the rolename

#

u can?

slate swan
#

you know what @slate swan just give him the code

slate swan
slate swan
#
    @role.group()
    async def create(self, ctx, role: str):
        if discord.utils.get(ctx.guild.roles, name=role):
            await ctx.send(f"there already exists a role with the name **{role}**")
        else:
            await ctx.guild.create_role(name=role)
            await ctx.send(f"role **{role}** has been created ๐Ÿ‘")

this works. and this is my create role cmd

#

not this

#

That's what i've been trying to explain

#

the one thats not working

#

i know, sec

supple thorn
slate swan
# slate swan give the code

this is the code:

    @role.group()
    async def delete(self, ctx, *, role):
        role = discord.utils.get(ctx.guild.roles, name=role)
        if role is not ctx.guild.roles:
            await ctx.send(f"there is no role named **{role}**")
        else:
            discord.utils.get(ctx.guild.roles, name=role)
            await role.delete()
            await ctx.send(f"role **{role}** has been deleted ๐Ÿ‘")
slate swan
slate swan
supple thorn
slate swan
#

already had a whole discussion about this

#

what u suggest i use?

supple thorn
#

!d discord.Guild.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
slate swan
#

oh

#

simple way
role discord.utils.get()
print(role)
output: none

rolesearch(or anything) = discord.utils.get
print(f"{role} not found")
output: role name in argument

supple thorn
#

Use this since this gets the role from the cache

#

Constant return time

slate swan
#

he is trying to print the fucking rolename asshole

supple thorn
slate swan
#

i am just trying to explain mate

slate swan
daring olive
#

!mute 959097257435758683 1d did not heed my warning, take a break

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1650780800:f> (23 hours and 59 minutes).

supple thorn
#

Since you're just trying to get the role

daring olive
unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @supple thorn.

slate swan
#
    @role.group()
    async def delete(self, ctx, *, role : discord.Role):
        try:
            await role.delete()
            await ctx.send(f"role **{role.name}** has been deleted ๐Ÿ‘")
        except Exception as e:
            await ctx.send(e)
  
                

supple thorn
#

Yeah just typehint role to discord.Role

slate swan
slate swan
slate swan
#

what u want

slate swan
#

Ok so, let me say this better

#

..

#

u dont want to ping the role?

slate swan
#

no

slate swan
torn sail
slate swan
#

I want to make it so if the role in guild.roles does NOT exist, it sends this exact message: there is no role named **{role}**.

so this means it has to get the role from guild.roles and needs to check if it exists or not. If it does exist it DOES delete the role and then sends this exact message: role **{role}** has been deleted :thumbsup:

#

async def delete(self, ctx, role : discord.Role):

#

what's the significance of * there?

daring olive
#

i guess bolding?

slate swan
#

they edited the message,

#

they?

torn sail
#

Roles with spaces

slate swan
paper sluice
slate swan
#

!d discord.ext.commands.RoleNotFound

unkempt canyonBOT
#

exception discord.ext.commands.RoleNotFound(argument)```
Exception raised when the bot can not find the role.

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

New in version 1.5.
slate swan
#

โฌ†๏ธ

#

i know, but that's what im tryna do inside of the code

#

h?

#

cus im also using a group rn

#

not just a commands.command in a cog file

#

you can't do it "inside" that function since the part of code will never get executed

slate swan
#

!d discord.ext.commands.Group.error

unkempt canyonBOT
#

@error```
A decorator that registers a coroutine as a local error handler.

A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.

Changed in version 2.0: `coro` parameter is now positional-only.
slate swan
#

but how come it works then in my create cmd? ```py
@role.group()
async def create(self, ctx, role: str):
if discord.utils.get(ctx.guild.roles, name=role):
await ctx.send(f"there already exists a role with the name {role}")
else:
await ctx.guild.create_role(name=role)
await ctx.send(f"role {role} has been created ๐Ÿ‘")

slate swan
#

im boy

#

he

supple thorn
slate swan
#

ok?

slate swan
#

๐Ÿ˜‘ no

#

im kiddin haha

#

i was joining a server and its full ;/

#

yikes

#

try adding print statement to check till what lines does your code gets executed

#

you need to fetchone() / fetchall() before looping with the cursor

torn sail
#

You should use aiosqlite

#

!pypi aiosqlite

unkempt canyonBOT
slate swan
#

and that con.commit() line is useless, since you're just reading the database

high sun
slate swan
#

yea

slate swan
south jetty
slate swan
#

any errors?

south jetty
#

nope

slate swan
#

yo

#

i want msg like this <t:215413532323:t>

#
sd = datetime.now()
newDate = sd + timedelta(seconds=ab)
final = newDate.timestamp()
olive osprey
slate swan
#

!d discord.utils.format_dt

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
slate swan
#

uh ok round()

#

!d round

unkempt canyonBOT
#

round(number[, ndigits])```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.

For the built-in types supporting [`round()`](https://docs.python.org/3/library/functions.html#round "round"), values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.

For a general Python object `number`, `round` delegates to `number.__round__`.
slate swan
#

looks cool?

#

also dont mind the timestamp its incorrect

paper sluice
#

sick

slate swan
maiden fable
sullen pewter
#

I can't fix this error

placid skiff
sullen pewter
slate swan
sullen pewter
slate swan
#

fine ๐Ÿ‘

slate swan
#

uh wait

slate swan
#

at down

#

@slate swan

gloomy sandal
#

Hey there everyone, i'm new at python and i wanna learn how to develop python bots. I know the basic syntax of python and oop, how should i continue?

slate swan
#

:D

gloomy sandal
slate swan
slate swan
slate swan
slate swan
#

no

sullen pewter
#

nextcord is outdated

#

going to be

slate swan
#

i dont use nextcord

#

wait what

#

that website is changed

slate swan
gloomy sandal
#

currently i know data types, loops, conditions, exception handling, importing, functions, classes, oop, do i need to learn more before diving into asyncio?

sullen pewter
slate swan
slate swan
slate swan
slate swan
sullen pewter
slate swan
#

I went from barely being able to send an embed to making fully fledged large scale bots

slate swan
slate swan
slate swan
#

No use asyncio

gloomy sandal
#

or learning by doing

slate swan
slate swan
gloomy sandal
#

pretty cool

slate swan
gloomy sandal
#

thanks @slate swan @slate swan

slate swan
#

Np

slate swan
#

then?

slate swan
#

and store it in a db

#

That way when your bot restarts ect it won't be lost

#

yeah

slate swan
#

Nice

slate swan
slate swan
#

a task to be specific

#

๐Ÿคฎ

slate swan
#

Don't use json

#

i dont know any db

slate swan
#

He did

slate swan
slate swan
#

thats what I'm currently using too

#

and its a json-based db

#

I use mongo or postgres

#

yeah postgres could be a nice option too

slate swan
#

I might start work on a new bot

#

but

#

But I want a team not to solo it zd

slate swan
slate swan
#

i want to complete my gv cmd ;-;

#

Gl

#

.gg/dpy will have much better help

#

Btw

slate swan
slate swan
#

what is it called?

#

wait

brisk zodiac
#
client.command()
async def math(ctx):
    await ctx.send(f"{number} + {number2}")
    channel = ctx.channel
    
    
    def check(m):
        return m.content == number + number2 and m.channel == channel

    msg = await client.wait_for('message', check=check)
    await channel.send('True!')```So what I was trying to do here is if it sends a question, I will answer it. But I am having a trouble in the ```py
 def check(m):
        return m.content == number + number2 and m.channel == channel``` because I make a variable here ```number = randrange(100)
number2 = randrange(100)``` So it will generate a different number from the ```(f"{number} + {number2}")``` So can you help me to make the answer is the ```number + number2``` that the bot send?
slate swan
#

sheesh

#

!pip deta

unkempt canyonBOT
slate swan
#

deta[async]==1.1.0a2 is the async version

brisk dune
#

async for x in y or just for x in y for an async function?

slate swan
#

ohhh i see

slate swan
brisk zodiac
slate swan
#

Hi!

#

hola

slate swan
#

@slate swan are you making a discord bot?

brisk dune
#

... Which leads me into my next question: If I have an asynchronous function (for my command), and I want to call another function I made that converts to integers, do I make that converter function asynchronous as well, or just leave it as it is and just do await func()?

slate swan
#

Ok

brisk zodiac
slate swan
slate swan
brisk dune
slate swan
#

๐Ÿ‘

brisk zodiac
#

@slate swan ```py
@client.command()
async def math(ctx):
await ctx.send(f"{number} + {number2}")
channel = ctx.channel

def check(m):
    return m.content == {number + number2} and m.channel == channel

msg = await client.wait_for('message', check=check)
await channel.send('True!')
slate swan
#

Hola, Yerlikaya

#

learning to be alive by not dying, you?

sullen pewter
#

How can I fix this error

brazen raft
#

Put r before the opening quotation mark

slate swan
#

welp, good luck

brisk zodiac
#

oh thx

sullen pewter
slate swan
#

Is there like a file extension which can't opened by any user but can be opened by file handling?

brazen raft
#

๐Ÿ‘

slate swan
#

aw, so sweet

slate swan
#

like directly not being able to open it but being able to open it with a command?

#

I mean it can't be opened normally by double clicking on the file. But can be opened using python and we can write stuff.

brazen raft
#

Why do you need that?

slate swan
#

Like, if we make lock.lock lock is not a real extension and we can't open it from pc. But it can be opened by using python and we can write stuff in it.

#

To do somethng.

unkempt canyonBOT
#

xy-problem

The XY problem can be summarised as asking about your attempted solution, rather than your actual problem.

Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead.

For more information and examples, see http://xyproblem.info/

slate swan
#

Just to keep some text secure. @slate swan

#

We have to use python to open it.

#

use hashing?

#

Hey! I want my bot to add one every time one minute has passed but it gives me a error

#

I gave you an example lock.lock.

#

It can't be opened by users normally.

#

But python can access it.

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

slate swan
#

it changes the value of the original variable

slate swan
#

and make sure it is not named to be a method/attribute that already exists

slate swan
#

wait what?

#

alright nevermind

#

Like I care anyways

#

lmao

#

๐Ÿ˜ญ why would I be a troll, wtf

#

ikr

#

""THIS IS MY ALT, NOT MY MAIN ACCOUNT""

brisk zodiac
#

@slate swan I'm having a trouble here that it just send only one question again and again how can I fix it? ```py
@client.command()
async def math(ctx):
await ctx.send(f"{number} + {number2}")
channel = ctx.channel

def check(message):
    return message.author == ctx.author and message.channel == ctx.channel and message.content.isdigit()
message = await client.wait_for("message", check=check)
if int(message.content) == number + number2:
    await channel.send("Got it right")
else:
    await channel.send("Got it wrong")```
slate swan
#

....

slate swan
keen talon
#

Forget everything and chat like they are two different persons lol

slate swan
#

smart

#

@slate swan btw, what did you do with your gv command?

slate swan
brisk dune
#

visible frustration

slate swan
slate swan
slate swan
brisk dune
# slate swan what?

After type-hinting *nums: str to imply it's a tuple[str], it still does tuple[str, ...]

slate swan
#

lmao

slate swan
#

hm alright, as you wish

#

ill change everything after my gv cmd

#

time wastage

#

but anyways

#

..

slate swan
brisk dune
#

true...

slate swan
slate swan
#

yeah, but "local" json "files", arent a good way to store data that may be used up frequently

#

storing static information might be a good option

brisk dune
#

You're right...

However, ... is actually also a valid Python expression which represents the singleton Ellipsis object. This object has no methods and was originally intended only for use in advanced slicing notation in the numpy package: for example a[..., 0] selects the first elements in the last dimension of a multidimensional array. However, it is sometimes also used:

  • as a placeholder for not-yet-written code (e.g. if error: ...). Code that is intentionally empty is better represented with pass.
  • when specifying type hints using the typing module (e.g. Callable[..., str] signifies a function that returns a string without specifying the call signature).
keen talon
slate swan
#

I low-key prefer deta than mongoDB, due its simple UI and the amount of free storage

brisk dune
keen talon
keen talon
slate swan
brisk dune
#
def convertable_to_num(self, x: Any) -> bool:
    try:
        x = float(x)
    except ValueError:
        return False
    else:
        return True

@commands.command(
    name="Add", aliases=["add"], description="Gives the sum of all numbers given."
)
async def add(self, ctx: commands.context.Context, *nums: str):
    """Gives the sum of all numbers given."""
    nums = list(nums)
    for idx, num in enumerate(nums):
        if self.convertable_to_num(num):
            nums[idx] = Decimal(num)
        else:
            await ctx.reply(f'"{num}" cannot be converted to a number!')
            break
    else:
        # Stuff
        await ctx.reply(f"The sum of {l} is: {s}")

Am I doing this right?

#

I mean the whole calling a synchronous function from inside an asynchronous function thing

#

It works

heady heron
#

um, i got a weird issue...

#

i think the images explain for themselves
mute doesnt exist even though it does?
any reason why?

brisk dune
#

I just mean to be... semantically correct about it (pedantry nonsense)

#

If this works, you're in for a free Tesla from the person...

#

wise words

heady heron
#

oh whoops, didnt even see that

brisk dune
heady heron
#

was resurfacing some code i made some years ago, thanks!

maiden fable
heady heron
slate swan
maiden fable
#

No

slate swan
#

yes

maiden fable
slate swan
#

lmao

brisk dune
slate swan
#

imagine opening random urls posted randomly ๐Ÿ˜”

maiden fable
#

That website helps people make rickroll links

slate swan
#

Please take this conversation out of this channel.

#

This is for help related to discord bots

brisk dune
brisk dune
slate swan
maiden fable
slate swan
#

you're misusing channels.

maiden fable
#

I, uhhh, nvm

cold sonnet
#

k it's not just for help

#

but yes

boreal ravine
#

#discord-bots-offtopic ๐Ÿ‘€

brisk dune
#

lmao

cold sonnet
slate swan
cold sonnet
#

huwunter

boreal ravine
brisk dune
slate swan
boreal ravine
cold sonnet
brisk dune
#

The code behind the join command

boreal ravine
#
@bot.command()
async def join(ctx):
    await ctx.author.voice.channel.connect() #Joins author's voice channel
cold sonnet
#

join seems to work

cold oyster
#

How do I make my bot send a message in another channel when a command is executed (Logs)

boreal ravine
cold sonnet
#

what does play look like

cold oyster
#

Make a var?

#

Maybe

quaint epoch
boreal ravine
cold oyster
cold sonnet
#

also, we shouldn't help with music bots but this isn't the ToS breaking part

cold sonnet
cold oyster
quaint epoch
cold oyster
#

Then?

quaint epoch
#

oof

#

!d disnake.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
cold oyster
#

I use nextcord

quaint epoch
#

same thing

cold oyster
#

Eh

quaint epoch
#

!d nextcord.Guild.get_channel

#

!d nextcord.Guild.get_channel

#

eh

cold oyster
#

Lol

#

Leave it

quaint epoch
#

yeah there you go

cold oyster
#

Same yeah

#

Thanks

cold oyster
# quaint epoch yeah there you go
    logs = ctx.get_channel(922860659870416901)
    await logs.send(f"{ctx.author.mention} warned {member.mention} for {reason}")```

Like dat?
quaint epoch
cold oyster
#

Alr

inner sierra
#

Hey , how can I change the status of the bot

quaint epoch
inner sierra
#

Yea

quaint epoch
#

!d disnake.Game

unkempt canyonBOT
#

class disnake.Game(name, **extra)```
A slimmed down version of [`Activity`](https://docs.disnake.dev/en/latest/api.html#disnake.Activity "disnake.Activity") that represents a Discord game.

This is typically displayed via **Playing** on the official Discord client.

x == y Checks if two games are equal.

x != y Checks if two games are not equal.

hash(x) Returns the gameโ€™s hash.

str(x) Returns the gameโ€™s name.
cold oyster
#

Ik, I fixed it

quaint epoch
#

didn't ask

quaint epoch
unkempt canyonBOT
#

class disnake.ext.commands.Bot(command_prefix=None, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result
anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with
this bot.

This class also subclasses [`GroupMixin`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.GroupMixin "disnake.ext.commands.GroupMixin") to provide the functionality
to manage commands.
quaint epoch
#

when you instantiate bot, set the activity to the discord.Game object

inner sierra
#

Oh ok

quaint epoch
#

for example

inner sierra
#

-?

quaint epoch
#
game = disnake.Game(name='Moderating...')
bot = discord.ext.commands.Bot(activity=game)```
inner sierra
#

Cool , ok

slate swan
slate swan
quaint epoch
#

'cept if you don't, then you're not my friend

brisk dune
maiden fable
#

It doesn't work without importing commands

cold oyster
#
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "/workspace/main.py", line 43, in warn
await logs.send(f"{ctx.author.mention} warned {member.mention} for {reason}")
AttributeError: 'NoneType' object has no attribute 'send'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/client.py", line 417, in _run_event
await coro(*args, **kwargs)
File "/workspace/main.py", line 24, in on_command_error
raise error
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/bot.py", line 1048, in invoke
await ctx.command.invoke(ctx)
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 933, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/app/.heroku/python/lib/python3.10/site-packages/nextcord/ext/commands/core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'```

@quaint epoch
cold oyster
maiden fable
#

Bro

cold oyster
#

...?

maiden fable
#

See the whole pic and the channel history

cold oyster
cold oyster
# maiden fable logs is None
@client.command()
@commands.has_permissions(manage_messages=True)
async def warn(ctx, member : discord.Member, *, reason=None):
    logs = ctx.guild.get_channel(922860659870416896)
    await ctx.logs.send(f"{ctx.author.mention} warned {member.mention} for {reason}")
    await ctx.reply(f"Successfully warned {member.mention}")
    await member.send(f"You have been warned in {ctx.guild} for {reason}.")```
maiden fable
#

The channel ID

#

!d discord.Intents.guilds is also needed

unkempt canyonBOT
brisk zodiac
#

Why I already deleted the previous code but it still send that?

maiden fable
#

Wym

cold oyster
brisk zodiac
cold oyster
heady heron
#

why do i not have permission? i can kick people with the bot, but i cant mute them, why?

cold oyster
#

Like herouku

maiden fable
brisk zodiac
heady heron
cold oyster
heady heron
#

and it can ban people

cold oyster
#

gtg

cold oyster
#

It has all perms, Just not admin

maiden fable
heady heron
maiden fable
#

Many people give ban perms but not manage roles since they are two different perms

heady heron
#

thanks!

heady heron
maiden fable
#

Ah okay cool

slate swan
#

you fetch the channel, then send a message to the channel

boreal ravine
slate swan
#

BRUH

#

-_-

boreal ravine
#

No offense but we don't care.

#

and that's obviously a rickroll

quaint epoch
# slate swan BRUH

you've already been told not to post the "free" nitro in the general, go to ot

boreal ravine
#

don't index the list too high

gaunt ice
placid ore
#

whats your code?

slate swan
velvet tinsel
keen talon
slate swan
#

ded chat ๐Ÿ˜•

#

hi?

keen talon
slate swan
#

hello spider man :") peter parker

brave flare
#

With great power...

slate swan
#

Please keep this chat relevant

olive osprey
#

what

slate swan
#

lol

olive osprey
slate swan
#

<@&831776746206265384>

#

Disgusting

#

?

#

nothing

#

ban pan

#

coming

#

ig

hot cobalt
#

!ban 565531066484523008 2d Yeah uh no thanks, this isn't something we want in our server in any situation. Perhaps re-read our #rules and #code-of-conduct

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @plucky swan until <t:1650886141:f> (1 day and 23 hours).

slate swan
#

gg

olive osprey
slate swan
#

2d uh

olive osprey
#

I doubt they will join back anyways

slate swan
#

ye ig

#

Still waiting

#

sad

#

Ikr :(

olive osprey
#
@client.command()
async def select(ctx):
    await ctx.send(
        "select Menu",
        components = [
            Select(
                placeholder = "Select something!",
                options = [
                    SelectOption(label = "69", value = "420"),
                    SelectOption(label = ":)", value = ":(")
                ]
            )
        ]
    )

    interaction = await client.wait_for("select_option")
    res = interaction.values[0]
    await interaction.send(content = f" selected!")โ€Š

try this

solar seal
#

anyone know how i can remove quotes from a str?

olive osprey
solar seal
#

no

#

i am taking a number and appending it to a json file

#

but i need to remove the quotes around the str

olive osprey
#

Oh, so you wanna save it as int instead of str?

solar seal
#

yeah basically

olive osprey
#

Show me your code

slate swan
#
@commands.cooldown(1, 5, commands.BucketType.channel)

is this correct?

olive osprey
#

Should work

solar seal
slate swan
#
python3 main.py
  File "main.py", line 283
    @commands.cooldown(1, 5, commands.BucketType.channel)
    ^
IndentationError: unexpected indent
exit status 1
#

anyone?

solar seal
#

what are you trying to do?

#

oh

slate swan
#

๐Ÿคทโ€โ™‚๏ธ

solar seal
#

nvm you just have code formatted incorrectly

olive osprey
slate swan
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
solar seal
olive osprey
#

Hm, well it shouldn't throw any error, try it out everything should be fine

solar seal
#

ok

slate swan
olive osprey
little ivy
#

How can i give a role with dropdown menu?

olive osprey
#
@client.command()
async def select(ctx):
    await ctx.send(
        "select Menu",
        components = [
            Select(
                placeholder = "Select something!",
                options = [
                    SelectOption(label = "69", value = "420"),
                    SelectOption(label = ":)", value = ":(")
                ]
            )
        ]
    )
    while True:
      interaction = await client.wait_for("select_option")
      res = interaction.values[0]
      await interaction.send(content = f" selected!")โ€Š

This should work

little ivy
#

I'll check it!

olive osprey
#

@slate swan also for you^

little ivy
#

euh it doesnt give a role

#

it should assign a role to the person who clicks on the dropdown option

slate swan
#

add ur own code too?

olive osprey
#

^ I'm not spoonfeeding everyone

olive osprey
#

The rest should be pretty easy, atleast when you know the basics of d.py & Python

slate swan
#

yes

olive osprey
#

But for some reason many people just start coding bots without any basic knowledge, kinda sad tbh

slate swan
#

they just start python for discord bot

olive osprey
#

Well, if they think it's worth it a_m_shrug

slate swan
#

..

little ivy
#

Well , had this

#

But that didnt work

olive osprey
#

well

slate swan
#

u cant just put the role name there

olive osprey
#

^

little ivy
#

must be id?

slate swan
#

no

little ivy
#

oh getrole

#

danmit

slate swan
#

..

#

also

olive osprey
#

You should first of all try to get a dropdown menu working without assigning a role first, then you can start work for assigning a role

slate swan
#

u can do

slate swan
#

for roles in interaction.guild.roles:
if roles.id == role id:
pass

#

if u want

little ivy
slate swan
olive osprey
#

I see, then just assign the role after the chosen dropdown interaction has been selected, you can do it as you would assign a normal role with a command

nova stag
#

can someone help me with this

slate swan
#

jk

slate swan
olive osprey
#

bruh

slate swan
#

who likes to code while chilling in this chat ๐Ÿ™‹โ€โ™‚๏ธ

olive osprey
#

๐Ÿคš

little ivy
slate swan
#

show code?

olive osprey
slate swan
#

yes

#

imusing discord_components lib

slate swan
olive osprey
# nova stag can someone help me with this
import os
# ...
for filename in os.listdir("./lib/cogs"):
    if filename.endswith(".py"):
        bot.load_extension(f"cogs.{filename[:-3]}")

Don't make it that hard for yourself

slate swan
#

lol

little ivy
olive osprey
#

๐Ÿ’€

olive osprey
little ivy
olive osprey
clever hamlet
olive osprey
#

Sure

slate swan
slate swan
clever hamlet
slate swan
little ivy
slate swan
slate swan
#

learn python first pls

slate swan
olive osprey
olive osprey
little ivy
#

Yes.

slate swan
#

no way

little ivy
#

Yes

slate swan
#

lie

clever hamlet
#

thx :>

little ivy
#

Whats wrong then

slate swan
little ivy
#

var?

#

what the hell is that

slate swan
#

variable

olive osprey
slate swan
#

all stop ill ask

slate swan
#

u know variable right?

little ivy
#

Ofc

slate swan
#

"ofc"

little ivy
#

give me a sec, i need to do something rq

slate swan
olive osprey
#

Well, if you do know the basics of python

slate swan
olive osprey
#

!d discord.Guild.get_role

unkempt canyonBOT
#

get_role(role_id, /)```
Returns a role with the given ID.

Changed in version 2.0: `role_id` parameter is now positional-only.
slate swan
#

i want to ask something

olive osprey
#

This will help you most likely

little ivy
olive osprey
#

what

slate swan
#

see

#

idk why they use typl there

olive osprey
#

What's authortje supposed to be btw

slate swan
#

and int dont need str

#

and

little ivy
slate swan
#

XD i'm gonna work on a new project, just need a development team so that we can get it done fast. I'm willing to invest into ads and more so if you want to help, just DM me!

olive osprey
#

Is it defined?

little ivy
#

yes

olive osprey
#

As?

little ivy
#

that worked before

slate swan
#

yo?

little ivy
#

thats not the problem

slate swan
#

it does so use it

olive osprey
#

lmao

slate swan
#

or use interaction.guild

#

Is there a way to add multiple images to an embed?

#

dont just put that id in a tuple string

#

HOW TO GET A Guild OBJECT WHICH REPRESENTS A SERVER

@Command
async def foo(ctx: commands.Context):
  guild = bot.get_guild(guild_id) #look for the Guild object in the cache of the bot and may return None of not found
  ''' Now the variable guild represents a Guild object '''
olive osprey
slate swan
#

Bruh what happened

olive osprey
#

We're not laughing about you, we are trying to help for the past 20mins if you didn't notice it

slate swan
#

Itโ€™s getting heated in the discord-bots channel

little ivy
#

We all needed to start somewhere

slate swan
little ivy
#

so just help eachother

#

im trying to learn

slate swan
little ivy
#

i already tried that

slate swan
#

and

little ivy
#

same error

slate swan
slate swan
slate swan
olive osprey
slate swan
#

nobody here is obliged to help you.

#

if you're being a dumbass thats on you

olive osprey
#

Well, we're trying to help

slate swan
olive osprey
#

Then they don't even admint that they don't know the basics, like why

slate swan
#

and this guy pops

#

nice

olive osprey
#

lmao

slate swan
#

no hate*

#

waiting for this jaguar guy to send his message PepeHands

slate swan
olive osprey
#

We never hated on him

slate swan
#

i've no clue why but worked out in the end

#

i knew basic python but nothing advanced

olive osprey
slate swan
#

lmao

#

i've done d.py i think two years now

olive osprey
#

It's normal to be interested in something and then trying to do that without basic knowledge, nothing stupid about that, it's a simple mistake

slate swan
olive osprey
#

Same kinda

slate swan
#

lol

#

๐Ÿ˜Ž

#

if anyone needs help ping me

dense swallow
#

hi im trying to make acknowledgements in userinfo cmd
code: ```py
async def get_acknowledgements(self, member):
bot_guild = self.bot.get_guild(764049436275114004)
staff_role = bot_guild.get_role(849669358316683284)

    if member.id == self.bot.owner_id:
        return [f":owner: Owner of {self.bot.user.name}"]

    if staff_role in member.roles:
        return [f":staff: Staff member in the [support server](link)"]

this in ui cmd

    acks_list = await self.get_acknowledgements(member)
    acks = "\n".join(acks_list)

errorpy
['Traceback (most recent call last):\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped\n ret = await coro(*args, **kwargs)\n', ' File "D:\Projects\PizzaHat\PizzaHat\cogs\utility.py", line 63, in userinfo\n acks = "\n".join(acks_list)\n', 'TypeError: can only join an iterable\n', '\nThe above exception was the direct cause of the following exception:\n\n', 'Traceback (most recent call last):\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke\n await ctx.command.invoke(ctx)\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke\n await injected(*ctx.args, **ctx.kwargs)\n', ' File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped\n raise CommandInvokeError(exc) from exc\n', 'discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only join an iterable\n']

slate swan
#

uh

olive osprey
#

Man I remember i used "input" to get user input in discord ๐Ÿ’€

dense swallow
slate swan
#

also i learned oop from discord cogs

#

HOW TO GET A Guild OBJECT WHICH REPRESENTS A SERVER

@Command
async def foo(ctx: commands.Context):
  guild = bot.get_guild(guild_id) #look for the Guild object in the cache of the bot and may return None of not found
  ''' Now the variable guild represents a Guild object '''

HOW TO GET A Role OBJECT WHICH REPRESENTS A ROLE IN DISCORD

@Command
async def foo(ctx: commands.Context):
  role = bot.get_role(role_id) #returns a Role object from the cache and in-case the Role object is not found in the cache, it returns None
  ''' OR YOU MAY USE A Guild OBJECT TO DO THE SAME '''
  guild = bot.get_guild(guild_id)
  role = guild.get_role(role_id)

@little ivy
I don't know how do I help you more

dense swallow
#

classes?

olive osprey
#

Welp, if you're interested in bot development, you try to start with it right away and there's nothing wrong with it unless you say you know the basics but can't define a variabel which containts an int

slate swan
slate swan
#

ashley

#

bug

#

Jaguar hasnt spoken yet Bruh_Penis

olive osprey
#

what

slate swan
#

pardon? @slate swan

slate swan
#

Ash tutorial point

#

why not capital

#

UGH

slate swan
#

!d discord.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")...
slate swan
#

who use caps var

#

๐Ÿคทโ€โ™‚๏ธ

#

because it just looks better in the little message

strong vector
#

input

@bot.event
async def on_message(msg):
    print(msg.author)
    print("'"+str(msg.content)+"'")
    if not msg.author.bot:
        await msg.channel.send("Hello World")

output

BrianNone#7593

'Webhooker#7983
Hello World
'

what wrong with my code?

slate swan
#

wo

strong vector
slate swan
#

msg.content

olive osprey
slate swan
#

ez

dense swallow
#

just print msg.content

strong vector
olive osprey
#

Oh, he wants to print it out, my bad

slate swan
#

Jaguar just type ๐Ÿ˜ญ

strong vector
slate swan
#

ig

strong vector
slate swan
#

oh back

dense swallow
slate swan
#

hes still here

strong vector
olive osprey
slate swan
slate swan
strong vector
slate swan
#

is that a real error?_

olive osprey
dense swallow
strong vector
#

maybe the problem with me

slate swan
#

..

olive osprey
dense swallow
slate swan
slate swan
olive osprey
#

what

#

it's supposed to make sense Thonk

dense swallow
slate swan
slate swan
olive osprey
#

Well, if it works it works happy

slate swan
strong vector
#

finly

BrianNone#7593
'siiii'
Webhooker#7983
'Hello World'
BrianNone#7593
'Hello world finly it works'
Webhooker#7983
'Hello World'

Thanks @slate swan

olive osprey
#

Have fun working on your bot

dense swallow
slate swan
slate swan
#

someone give me bot ideas ๐Ÿคฃ

dense swallow
strong vector
slate swan
slate swan
#

Your conditions are fine

#

Jaguar type faster pepe_laugh

#

snowyjaguar is gonna finish typing and just say "Ok"

slate swan
#

I was in this one server and this dude typed for a few days, it ended with him just saying "h"

#

lol

#

@flat solstice wake up

olive osprey
strong vector
#

lmao

slate swan
#

key strokes bl:
ctrl + a ctrl + c backspace O K ENTER

slate swan
flat solstice
#

so I have this condition https://paste.pythondiscord.com/cemomojosi which is making my embed value a different thing depending on the below (before and after mean before.afk_channel and after.afk_channel)
arrow_blue if before or after exist then run the rest of the code - this means that as long as one of them exists it will add the embed field but if before or after don't exist or are None then it won't add the embed field
arrow_blue if before and after exist then check if they are not the same thing, if they are not the same thing then add the field
arrow_blue if either before or after exist then change the embed field value depending on what the outcome is.
I'm doing this process 4 times, for guild.afk_channel, guild.system_channel, guild.public_updates_channel and guild.rules_channel so I thought it would be a good idea to make it into a function https://paste.pythondiscord.com/buxidawisi but I'm not sure how to incorporate the function call into my embed construction.
arrow_blue I could just call the function from the value of the embed field without any of the existing conditions (since they exist in the func) but I think I'd have to do that 4 times and wouldn't work since it would still be trying to add the field regardless if one exists or not
arrow_blue I could do the above with a if before or after: check which I think would work
arrow_blue I could move the field construction into the function and just call the function 4 times altho it might need the same logic check as above and I'm not sure how I would name the field, maybe I'd need to pass in a name to the func

slate swan
#

omg

#

OMFG

olive osprey
#

What

dense swallow
#

oh my god

slate swan
#

LMAO

#

uh

#

is it bad i can't understand it

olive osprey
slate swan
#

now read it

#

watch him get no help

#

due to all of the like stuff in it i can't even read it lmfao

slate swan
slate swan
slate swan
#

ye

#

I'm getting a brainfuck trying to understand what he wanna do

#

same

olive osprey
#

lmao

slate swan
#

aight now lets wait 30m more

#

..

#

anyone wanna work on a discord bot together lol

olive osprey
slate swan
#

no clue

gaunt ice
#

me C:

slate swan
slate swan
#

PROMO

#

oh god

#

if u wanna make smthn tho dm yh yh

olive osprey
slate swan
#

uh

slate swan
gaunt ice
slate swan
#

gimme the invite ๐Ÿ˜‰

#

jk dont i'm 14

olive osprey
#

lmao

slate swan
slate swan
slate swan
gaunt ice
slate swan
#

..
..

slate swan
#

who knows right

#

jaguar is typing once again

olive osprey
slate swan
slate swan
slate swan
slate swan
olive osprey
slate swan
#

i just spent $200 on a mobile game

slate swan
olive osprey
slate swan
#

neither

olive osprey
#

Damn thats a waste

slate swan
#

pubg

#

was some tycoon game zbaby_cry

slate swan
olive osprey
#

bruh

slate swan
#

its alr lol i get paid in 7 days anyway

#

..

slate swan
olive osprey
#

"exotic pfps"

slate swan
slate swan
olive osprey
#

Click on the emoji

slate swan
#

ye

#

jaguar is once again typing

supple thorn
slate swan
#

and he didnt get any help on his last message trol

#

look ok i had my resons

supple thorn
#

Is it a good game?

slate swan
olive osprey
#

"decent"

slate swan
#

decent

#

freelancing?

olive osprey
#

man spent 200 dollars on a decent game

supple thorn
slate swan
#

You probably make bank since your a female on discord ffs

gaunt ice
#

ashley is Elon in disguise