#discord-bots

1 messages · Page 821 of 1

nimble plume
#

somhow my bot has auto help command help

#

i didnt add any help command

maiden fable
#

Yea

nimble plume
#

i do !help and it show all the function i make and the argment required and all

maiden fable
nimble plume
#

its pretty cool

kindred drum
#

how do you get the name of a channel from its id

maiden fable
#

!d discord.Client.get_channel

unkempt canyonBOT
nimble plume
#

i want to make help commands

maiden fable
maiden fable
unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
nimble plume
#

is there something for help commands? in discord.py

nimble plume
boreal ravine
nimble plume
#

function.helpcommand?

nimble plume
shrewd inlet
#

@bot.event
async def on_message(message):
   await bot.process_commands(message)
   if message.content == "last.fm":
        await message.reply('1. Create an account on the website https://www.last.fm\n2. Connect it to your spotify music account\n3. Go to bots and link your account by typing `,set (your last.fm username)`\n Run ,np to show what music youre listening to!')  
   if message.content == "i told you i was down bad":
        await message.reply('you hate to see me like that')
   if message.content == "strawberry":
       await message.reply ('![graciestrawberry](https://cdn.discordapp.com/emojis/935526687351898232.webp?size=128 "graciestrawberry")')
   if message.content == "Strawberry":
       await message.reply ('![graciestrawberry](https://cdn.discordapp.com/emojis/935526687351898232.webp?size=128 "graciestrawberry")')  
   if message.content == "berry":
       await message.add_reaction  (r":graciestrawberry:935526687351898232")       if message.content == "our queen":
       embed = discord.Embed(color=0x2f3136)
       embed.set_image(url=random.choice(gracie_images))
       await channel.send
#

why doesn’t the embed part work?

#

i get an error

maiden fable
#

Ah yr indent

valid perch
#

Send is a method, you need to call it

maiden fable
#

Or something idk

zinc surge
maiden fable
shrewd inlet
maiden fable
#

See the if statement

valid perch
#

I c

valid perch
zinc surge
#

simple

maiden fable
valid perch
#

And your if should be on the next line as well inline with the others

maiden fable
#

If statement goes BRRRR

red sundial
maiden fable
#

Discord Mobile

zinc surge
shrewd inlet
#

no i wrote the code with my friend 😭

nimble plume
#

nvmd

shrewd inlet
#

also yes i’m coding on my phone 💀

nimble plume
nimble plume
#

line 158

shrewd inlet
#

IG

#

I FORGOT THE IF

nimble plume
#

no

shrewd inlet
#

IM SO DUMB LOL

nimble plume
#

ur if statement has wrong indents

shrewd inlet
#

oh

nimble plume
#

press enter

#

before if statement

#

then match the if indents with other if indents

shrewd inlet
nimble plume
#

i cant see indents properly cuz its phone

shrewd inlet
nimble plume
#

is it replit?

shrewd inlet
#

yeah

nimble plume
#

listen remove the bot token and ur presonal stuff from code for now

nimble plume
#

ok

#

share the replit link in dm then

shrewd inlet
#

i used a getenv file

nimble plume
#

make sure remove the bot token else u will blame me

tidal hawk
#

has anyone created a task which executes exactly after minute changes in real clock
Basically when flips from 2:44 -> 2:45, then the task executes

#

Got it

maiden fable
#

Got it?

#

Else use the minutes kwarg

tidal hawk
#

Yeah I could, but then If i run it at 14:36:15 it will execute in -> 14:37:15, but I wanted it to execute exactly 14:47:00, and then start looping with 1 minutes. It's basically in sync with real clock then.

#

But I think I found solution for that

sudden agate
tidal hawk
#

Hm okay

#

I use disnake

#

I created before_loop which calculates the time between next minute, and basically sleeps until then

sudden agate
tidal hawk
#

Okay

#

I created this:

red nest
#

can someone help me? i'm trying to make a ticket bot, but it doesn't create the text channel. i am not getting any error, but it doesn't create the channel. my code: if reaction == "📩": await ctx.guild.create_text_channel('ticket-support')

tidal hawk
#

Can you send the full command code pic?

red nest
#

ok

#

wait a minute

#
async def ticket(ctx):
    embed = discord.Embed(
        title='Create a Ticket',
        description='React with 📩 to create a ticket',
        color=discord.Colour.green()
    )
    embed.set_footer(text="Ticket System")
    msg = await ctx.send(embed=embed)
    await msg.add_reaction("📩")

    if reaction == "📩":
        await ctx.guild.create_text_channel('ticket-support')

    ticket_embed = discord.Embed(
        title='This is your ticket channel!',
        description='A supporter will help you as quickly as possible!',
        color=discord.Colour.blurple()
    )
    ticket_embed.set_footer(text="Support System")
    ticket_channel = discord.utils.get(ctx.guild.text_channels, name='ticket-support')
    ticket_msg = await ticket_channel.send(embed=ticket_embed)
    await ticket_msg.add_reaction('\u2705')```
boreal ravine
boreal ravine
tidal hawk
#

Your program needs to wait for the emoji

red nest
#

so how can i fix this?

tidal hawk
#

Example ☝️

boreal ravine
tidal hawk
#

📩

red nest
#

yes

boreal ravine
#

what?

red nest
red nest
tidal hawk
#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
red nest
# tidal hawk

but can i somehow manage to create the channel when someone reacts?

tidal hawk
#

Yes

lost vine
red nest
#

but i don't know how exactly

honest shoal
#

how to set slash command description in disnake

buoyant quail
slim ibex
#

^

honest shoal
#

wait

buoyant quail
#

i am lazy to go docs
it's the same like commands.command
@commands.slash_command(name="", description="")

honest shoal
#

I don't want to set slash command description, I mean option's description in slash command

#

sorry my bad

peak raven
#

Where do u guys code the bot? replit?

slate swan
slate swan
honest shoal
red nest
slim ibex
slate swan
#

!d disnake.Option

unkempt canyonBOT
#

class disnake.Option```
Represents a slash command option.
slate swan
#

Check the properties

peak raven
#

I am new to python what platform should I use? and should I start coding the bot and learn on the way or learn python completely then code?

#

I have made simple programs using java bluej and c++ before

slim ibex
#

learn python

#

too many beginners make teh mistake of not learning python bnefore doing a bot'

honest shoal
# slate swan Could you explain more

there's a parameter in my code channel: disnake.VoiceChannel earlier i was enough to pop up a list of voice channels in the slash command, now descriptions are necessary so how can I set a description for it when its not an option

red nest
peak raven
slim ibex
#

videos aren't the best

honest shoal
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slim ibex
#

!videos

peak raven
#

then?

slim ibex
#

thought there was a command talking about videos

slim ibex
red nest
#

maybe

peak raven
red nest
#

i learned a lot with videos

slim ibex
#

but people tend to just copy from vids

#

and not actually listen, and learn

red nest
#

yeah but if you really listen and break down the code you can learn a lot

peak raven
#

Any book u recommend? 👀

honest shoal
#

please go to general or off-topic channels

tidal hawk
# red nest yeah but if you really listen and break down the code you can learn a lot
import asyncio
@bot.command()
async def ticket(ctx):
    embed = discord.Embed(
        title='Create a Ticket',
        description='React with :envelope_with_arrow: to create a ticket',
        color=discord.Colour.green()
    )
    embed.set_footer(text="Ticket System")
    msg = await ctx.send(embed=embed)
    await msg.add_reaction(":envelope_with_arrow:")

    def check(reaction, user):
        return user == message.author and str(reacion.emoji) == ':envelope_with_arrow:'

    try: 
        reaction, user = await bot.wait_for('reacion_add', timeout=60, check=check)

    except asyncio.TimeoutError:
        await ctx.send('You timed out.')
        return

    channel = await ctx.guild.create_text_channel('ticket-support')     

    ticket_embed = discord.Embed(
        title='This is your ticket channel!',
        description='A supporter will help you as quickly as possible!',
        color=discord.Colour.blurple()
    )
    ticket_embed.set_footer(text="Support System")

    ticket_msg = await channel.send(embed=ticket_embed)
    await ticket_msg.add_reaction('\u2705')```
honest shoal
#

my question just went up

slate swan
#

How do I check if a user id is in a json file?

tidal hawk
tidal hawk
#

^

slim ibex
#

^^

slim ibex
#

context manager

slate swan
buoyant quail
tidal hawk
#

Search how to load data from json

slim ibex
#
with open('file.json', 'r') as f:
  ...
slate swan
#

hmm

#

wait lemme try

slim ibex
#

correct me if its wrong

#

use context managers for this stuff

#

ikt makes sure the file is closed after the operation is done

tidal hawk
#

Don't you need to load it first? data = json.load(f)

slim ibex
#

you put that in the with statement

tidal hawk
#

mhm

slim ibex
#
with open('file.json', 'r') as f:
  data = json.load(f)
tidal hawk
#

yep ☝️

buoyant quail
#

oops, yes

slim ibex
#

not a command ):

tidal hawk
#

How do you guys do that cool up arrow symbol

slim ibex
#

^ this?

tidal hawk
#

yes

buoyant quail
slim ibex
#

shift + 6

tidal hawk
#

&

slim ibex
#

its on the 6 key'

tidal hawk
#

Don't have that

slim ibex
#

tkl?

tidal hawk
#

D:

slim ibex
#

60%*?

tidal hawk
#

yeah

slim ibex
#

unluck

#

you could prolly find it somehwere on the board

tidal hawk
#

ˇ

#

God damn it

slim ibex
#

LMFAO

buoyant quail
#

lol

cold sonnet
#

wtf

slim ibex
#

i dont even see that key WTF

tidal hawk
#

hhahaha

#

it's on ESC button for me

cold sonnet
#

ˇ

#

I have to press alt + 1, then shift + 1

#

or smth

#

no, I have to go alt + 2, then 1

slim ibex
#

shits not even an option for me

slate swan
#

me with android's Google Board

slim ibex
#

i love going into the rust server and seeing the craziest code to exist to mankind

slate swan
#

rust is cool :0

tidal hawk
#

Have 1200 hours on Rust

slate swan
#
@client.command(aliases=["bal", "wallet"])
async def wbal(ctx, user: discord.Member=None):
    if not user:
        user = ctx.author

    with open('mainbank.json', 'r') as f:
        data = json.load(f)
        if user.id in data:
            await get_bank_data()

            users = await get_bank_data()
            user=user

            wallet_amount = users[str(user.id)]["wallet"]
            bank_amount = users[str(user.id)]["bank"]

            embed = discord.Embed(title="Wallet")
            embed.add_field(name="Wallet", value = f"{wallet_amount}")

            await ctx.send(embed=embed)
        
        else:
            return await ctx.send("Create a bank account")```
tidal hawk
#

Remove tabs behind if user.id in data:

#

and from there on

slate swan
#

hmm wait

slate swan
#

Thanks king

#

it worked ☠️

tidal hawk
#

Np :D

#

I do not recommend using JSON as a economy database

#

Do not make the same mistake I did

desert badger
#
/home/container/.local/lib/python3.8/site-packages/disnake/ext/commands/interaction_bot_base.py:722: SyncWarning: Failed to overwrite commands in <Guild id=928434213538119790> due to 403 Forbidden (error code: 50001): Missing Access
  warnings.warn(
#

whats this bananacat

tidal hawk
#

Maybe your bot doesn't have permissions to overwrite

desert badger
#

it has applications.commands on

tidal hawk
#

Hm

desert badger
# tidal hawk Hm

and the only guild id in test_guilds is the one its in (my main server) the guild id displaying in that error is my testing server, it was never in there tho ```py
client = commands.Bot(command_prefix = '.', case_insensitive=True, intents=disnake.Intents.all(), test_guilds=[838739082825564180])

tidal hawk
#

Ughh I remember I had the same problem

desert badger
#

o

#

how did u fix it bananacat

tidal hawk
#

I fixed it accidentally somehow :(

slate swan
#

Oh nvm

#

You didn't invite the bot with application commands scope

modern fiber
maiden fable
#

👀 u became a rin lover too

modern fiber
desert badger
tidal hawk
honest vessel
#

@desert badger try do test_guild=idofserver

slate swan
maiden fable
#

Just add %20application.commands at the end of the invite url and u r fine

modern fiber
slate swan
desert badger
honest vessel
#

is bot serverowner?

desert badger
#

server owner ?

honest vessel
#

created server with bot

desert badger
#

no lol

#

is that even possible

slate swan
#

Yeah

honest vessel
#

yes

desert badger
honest vessel
#

;)

desert badger
desert badger
cloud bison
#

can I msg someone has closed his DM with bot?

velvet tinsel
tidal hawk
#

xD

desert badger
#

Can a Discord Bot create Server invites ?

#

i remember someone told me its not possible / allowed

tidal hawk
#

yes

desert badger
#

yes to not allowed or yes to it can create invites

tidal hawk
#

It's possible and allowed

desert badger
#

oooooo

#

how do i do that lol

tidal hawk
#

!d discord.abc.GuildChannel.create_invite

unkempt canyonBOT
#

await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates an instant invite from a text or voice channel.

You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
desert badger
#
@client.command(pass_context=True)
async def createInvites(ctx, time_in_seconds,uses):
    invitelink = await disnake.abc.GuildChannel.create_invite(ctx.message.channel, max_uses=uses,max_age=time_in_seconds)
    await ctx.send(invitelink)
```?
honest shoal
#

I just made a command to start a watch together activity in the voice channel, and it should only work if a user is in a voice channel and the channel will be the author's voice channel, this is my code py @bot.command(name="watch-together",description="Starts watch together activity in a voice channel.") async def yt(ctx, channel: disnake.VoiceChannel): channel = ctx.author.VoiceState.channel if channel != None: invite = await channel.create_invite( target_type=disnake.InviteTarget.embedded_application, target_application=disnake.PartyType.watch_together) await ctx.send(invite) else: await ctx.send("❎ You are not in a voice channel!") I'm getting an error console disnake.ext.commands.errors.MissingRequiredArgument: channel is a required argument that is missing why I'm getting it when I have a value assigned for voice channel

desert badger
slim ibex
#

the error is clear

honest shoal
slim ibex
#

where is the channel

#

is watch-together

honest shoal
#

the voice channel in which I'm in

slim ibex
#

well you need to specify the channel when invoking the command

#

prolly the channel id

#

unless you make it optional

honest shoal
desert badger
tidal hawk
#

bruh

desert badger
#

since a few days i dont have motivation to do anything anymore lol

honest shoal
#

I think I should remove the parameter

tidal hawk
#

But you wrote the code already..

#

I guess it didnt work

placid skiff
#

how to check when a member joins by an invite link, getting the member of the guild who has invited him?

desert badger
tidal hawk
#

ah alright

placid skiff
#

I'm pretty skilled xD

tidal hawk
desert badger
placid skiff
tidal hawk
#

:D

slim ibex
desert badger
tidal hawk
#

Check docs

desert badger
#

oke

tidal hawk
#

Is it possible to select multiple options from Select menus?

honest shoal
honest shoal
honest vessel
pine crypt
#

how would you be able to spread classes and cogs across multiple files?

slim ibex
pine crypt
#

how to then connect to main file

slim ibex
#

you can load all the cogs by searching the directory where all the cogs are in using a for loop

#

then make sure the filename ends with .py

pine crypt
#

example please?

slim ibex
#

and load the files, and remove the .py at the end

#
for filename in os.listdir("./path_to_cogs_folder"):
  if filename.endswith(".py"):
    bot.load_extension(f"path_to_cogs_folder.{filename[:-3]}")
pine crypt
#

ah ty

honest vessel
#
for filename in os.listdir('./cogs'):
    filename.lower()
    if filename.endswith('.py'):
        filename = filename[:-3]
        try:
            bot.load_extension(f"cogs.{filename}")
        except disnake.ext.commands.errors.ExtensionNotFound as error:
            print(f"[Error]: {error.name}.py is missing, please check so the file exists in ./cogs")
            sys.exit(1)
        else:
            print(f"[+] {filename} has been loaded.")
final iron
hoary cargo
#

Big spoon feeding mm delicious

desert badger
lone lily
#

How i can send file with discord api? without discord.py

dim berry
final iron
#

Why reinvent the wheel

modern fiber
#

Uh? Help?

@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, user: disnake.User):
    for guild in client.guilds:
        mutedRole = disnake.utils.get(guild.roles, name="LARPC Muted")

    if not mutedRole:
        mutedRole = await ctx.guild.create_role(name="LARPC Muted")

        for guild in client.guilds:
            await guild.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    ctx.send(f"{user} is succesfully kicked!")
    await user.add_roles(mutedRole)
    await user.send(f"You have been muted in **{ctx.guild.name}** for **{reason}**!)```
cold sonnet
#

you can't add roles to a User

modern fiber
#

how?

cold sonnet
#

you can only add roles to a Member

final iron
cold sonnet
#

and ctx.send() was never awaited

modern fiber
#

That's the thing. Thanks bud.

desert badger
#

quick question how do i make spaces bigger in vsc? like if i click on spaces and set it to like 4 it changes but these spaces stay like it, what do i do

desert badger
#

oop sry

modern fiber
#

Why these get highlighted?

manic wing
#

who knows

#

just use visual studio code and all your problems will magic away

modern fiber
#

lol

cold sonnet
#

why would you make the for loop

modern fiber
cold sonnet
#

it's only gonna grab the last role named muted anyways

modern fiber
#

how do i fix it?

cold sonnet
#

I think you messed up your indentation

modern fiber
#

how so..

manic wing
cold sonnet
#

stop looking at my about me and help lavox

manic wing
cold sonnet
#

STOP

maiden fable
#

Y'all do know that we have talked about his About Me once in the past too, right?

modern fiber
#

..

#

is someone gonna help me

final iron
# modern fiber

camelCase should never be used in python. snake_case should be used for function and variable names

cold sonnet
#

!e

for number in range(20):
  last = number
print(last)
modern fiber
#
@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member: disnake.Member):
    for guild in client.guilds:
        mutedRole = disnake.utils.get(guild.roles, name="LARPC Muted")

    if not mutedRole:
        mutedRole = await ctx.guild.create_role(name="LARPC Muted")

        for guild in client.guilds:
            await guild.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    await ctx.send(f"{member} is succesfully kicked!")
    await member.add_roles(mutedRole)
    await member.send("You have been muted!")
#

what do I change?

unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your eval job has completed with return code 0.

19
cold sonnet
#

only the last one

maiden fable
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

19
cold sonnet
#
    for guild in client.guilds:
        mutedRole = disnake.utils.get(guild.roles, name="LARPC Muted")

```only returns the last one
modern fiber
maiden fable
maiden fable
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
modern fiber
cold sonnet
#

NO

maiden fable
#

.....?

#

Okay so this all is weird, I'm out

cold sonnet
#

IT RUNS THROUGH THE FOR LOOP AND RETURNS THE ROLE OF THE LAST GUILD IN THE LIST

modern fiber
#

okay im out

cold sonnet
#

me too

modern fiber
cold sonnet
#

bad

modern fiber
#

do I change anything in the code?

cold sonnet
#

indentation

modern fiber
#

WHAT DO I CHANGE OH MY GOD MY FUCKING ARMS

modern fiber
maiden fable
cold sonnet
#
@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member: disnake.Member):
    for guild in client.guilds:
        mutedRole = disnake.utils.get(guild.roles, name="LARPC Muted")

        if not mutedRole:
            mutedRole = await ctx.guild.create_role(name="LARPC Muted")

    for guild in client.guilds:
        await guild.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    await ctx.send(f"{member} is succesfully kicked!")
    await member.add_roles(mutedRole)
    await member.send("You have been muted!")
modern fiber
#

holy fuck me

#

finally

cold sonnet
#

I don't really get why you do that in every guild every time

#

but sure

final iron
#

I had to spoonfeed

#

😔

cold sonnet
#

even that

#

I had to too

#

😔

quick gust
hoary cargo
#

sadFumo guys just use damn timeout instead of mute
More efficient and easier to implement

cold sonnet
#

imagine NOT overcomplicating

cold sonnet
#

lmao what

final iron
#

!d disnake.Member.timeout

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.
cold sonnet
#

you wanna mute for more time???

vale wing
#

You can't permamute with timeout can you

final iron
#

Not unless you time them out every 28 days

modern fiber
# cold sonnet ```py @client.command() @commands.has_permissions(kick_members=True) async def m...

I get this error
await ctx.command.invoke(ctx)
File "C:\Users\korisnik\PycharmProjects\DiscordBot\venv\lib\site-packages\disnake\ext\commands\core.py", line 929, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\korisnik\PycharmProjects\DiscordBot\venv\lib\site-packages\disnake\ext\commands\core.py", line 184, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10011): Unknown Role

hoary cargo
#

I mean what's the point, just ban the member already if you want to perma mute

cloud dawn
slate swan
# maiden fable Uhhh what?

they want to get all the roles named "LAPRC Muted" in all the servers, for that they run a loop py for guild in client.guilds and use utils.get to get the role assigned a variable mutedRole,
what they need : A list of roles named LAPRC Muted,
what they get : A single role named LAPRC from the last guild,
and then they try to edit the role from one server in all the servers ( which is technically not possible )

cold sonnet
#

might wanna put it in a try except

cloud dawn
hoary cargo
slate swan
#

from what i read above

cold sonnet
#

instead of checking if it's None

modern fiber
#

well uhh?

@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member: disnake.Member, *, reason =None):
    for guild in client.guilds:
        muted_role = disnake.utils.get(guild.roles, name="Muted")

    await ctx.send(f"{member} is succesfully muted!")
    await member.add_roles(muted_role)
    await member.send(f"You have been muted in **{ctx.guild.name}** for **{reason}**!")
    channel = client.get_channel(801446246954827808)
    await channel.send(f"{member} has been **muted** by {ctx.author} for **{reason}**!")```
#

there is a role with name "Muted"

slate swan
#

just use timeouts uh

vale wing
#

Why are you iterating all the guilds

modern fiber
#

plus it says it has been muted even the user hasn't

cold sonnet
#

fetch?

modern fiber
#

bot is only for my server 😂

cloud dawn
vale wing
#

Remove that iterator like wtf for do you need to iterate through guilds

cold sonnet
cloud dawn
vale wing
#

You get the muted role for every guild and overwrite it every time

slate swan
#

why are people still using mutes with disnake when timeouts are added 🏃‍♂️

modern fiber
#

so I remove
" for guild in client.guilds:"

#

and just keep
" muted_role = disnake.utils.get(guild.roles, name="Muted")"

#

or?

vale wing
#

Yeah but ctx.guild.roles

hoary cargo
final iron
modern fiber
#

Good?

cold sonnet
#

seems fair

#

you won't have to check if it doesn't exist

#

it's your own server afterall

modern fiber
#

yeah

hoary cargo
slate swan
#

sidenote, if there are multiple roles named Muted your add_roles fails

cold sonnet
#

why would there be... what

#

tho good to know

cloud dawn
slate swan
slate swan
unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
hoary cargo
#

That's why I said the code is full of holes lmao
Missing basic checks

cloud dawn
#

Yeah i assumed, but we got timeout instead so dunno.

cold sonnet
#

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

can't this take a list?

vale wing
#

Args list

slate swan
#
.add_roles(role1, role2) #yes
.add_roles([role1, role2]) #no
modern fiber
#

Can I make it so you can mute for a certain time?

# MUTE COMMAND
@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx, member: disnake.Member, *, reason =None):

    muted_role = disnake.utils.get(ctx.guild.roles, name="LARPC Muted")

    await member.add_roles(muted_role)
    print(member)
    print("has been muted for")
    print(reason)
    await ctx.send(f"{member} is succesfully muted!")
    await member.send(f"You have been muted in **{ctx.guild.name}** for **{reason}**!")
    channel = client.get_channel(801446246954827808)
    await channel.send(f"{member} has been **muted** by {ctx.author} for **{reason}**!")```
vale wing
#
.add_roles(*[role1, role2, role3])```
For the list
#

Idr if you can unpack lists

slate swan
cloud dawn
vale wing
cloud dawn
#

I'll check the source

slate swan
vale wing
#

!e ```py
def f(*args):
print(args)

f(*['bruh', 'brue', 'brebre'])```

unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

('bruh', 'brue', 'brebre')
vale wing
#

Wow you can unpack lists

#

Didn't know

cloud dawn
# slate swan

Then tbf this is coded pretty bad, doesn't take much to take in both list and args.

vale wing
#

Is this python 3.10 feature or it has always been available

modern fiber
slate swan
slate swan
#

cause i saw it on stackoverflow some months back

vale wing
#

Ok works on 3.8 as well

#

Guess gotta rewrite some of my code constructions

cloud dawn
vale wing
#

I mean I thought you can only unpack tuples lol

cloud dawn
#

Well tbf tuples are almost the same.

vale wing
#

!e py a = [1, 2] b, c = a print(b, c)

unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

1 2
vale wing
#

Whoa nice

oblique adder
#
embed = nextcord.Embed(
     colour = 0x983925,
     title =f"NSFW",
     description = self.language[server_language]["Error"]["is_nsfw"]
)
embed.set_footer(text=f"┗Requested by {ctx.author}")
embed.timestamp = datetime.datetime.utcnow()
message= await ctx.send(embed=embed)
await message.add_reaction('✨')```

why doesn't it able to use embed.timestamp = datetime.datetime.utcnow() ? it return NoneType: None
This used to work in discord.py 1.7.2
cloud dawn
#

!e ```py

In that case this would work aswell

print(*[1, 2])

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

1 2
vale wing
#

You can put the timestamp in constructor

#

Also why not use datetime.datetime.now()

cloud dawn
unkempt canyonBOT
cloud dawn
#

Why even have datetime when it's already done for you.

slate swan
vale wing
#

He wants to set the timestamp of the embed waitwhat

cloud dawn
slate swan
#

ctx.message.created_at does the job :p

nimble plume
oblique adder
oblique adder
hoary cargo
# modern fiber how so?

artistic_hmm i might share my old mute/unmute command i don't guarantee it's perfect because when i did it i was still learning

cloud dawn
vale wing
slate swan
slate swan
vale wing
modern fiber
#

leaked, no socks on hot

cloud dawn
vale wing
#

Ah yes ctx

#

Forgot about it

modern fiber
vale wing
slate swan
#

.bm

#

my time converter

modern fiber
#

So I just put that above everything?

cloud dawn
slate swan
#

!pip time-str

unkempt canyonBOT
slate swan
#

this is useful too

vale wing
#

O this thing exists

cloud dawn
vale wing
slate swan
cloud dawn
#

And many more tricks.

vale wing
#

You surely can convert datetime to timedelta with some magic but typically strftime is for getting datetime and not timedelta

cloud dawn
slate swan
#

hm

cloud dawn
vale wing
#

I doubt that module has much of contents tho

#

You can still use the converter like the one I shared

hoary cargo
cloud dawn
vale wing
#

There's just one class and 1-2 methods it seems

cloud dawn
#

Yeah 😂
hence why i said why you need a whole module for that py_guido

vale wing
#

Fun fact I made a module based on sqlite3 but didn't know it already has injections so I built my own injections system which is dumb af 😂

slate swan
#
@client.command()
async def open_account(ctx, user: discord.Member=None):
    if not user:
        user=ctx.author
        users=await get_bank_data()

        if str(user.id) in users:
            return False
        else:
            users[str(user.id)] = {}
            users[str(user.id)]["wallet"] = 0
            users[str(user.id)]["bank"] = 0

        with open("mainbank.json", "w") as f:
            json.dump(users, f, indent=4)
        return True```

The command only creates variables in dictionary for command author and does not make one for the user even when pinged
quick gust
#

json

vale wing
#

😳 oh no

#

Check this out @slate swan

slate swan
cloud dawn
prime bough
#

hello I'm new on this server and I started developping discord bots today and i'm just here for a question, I wanted to mention the author of a message but i don't know how to do it since juste putting an @ doesnt work. Then how can I do it ? (sorry for my englidh im not a native)

slate swan
#

well, my one isn't an exact copy i made some adjustments

cloud dawn
# slate swan 11?

I can help you if you want but i do recommend using a database. Your choice.

unkempt canyonBOT
slim ibex
#

!pypi aiosqlite

unkempt canyonBOT
cloud dawn
slim ibex
#

postgres is relatively easy too. im messing with it also

cloud dawn
#

I do like my interface.

quick gust
#

opposite for me, probably because I had someone helping me when I started aiosqlite

cloud dawn
slate swan
#

if user id is already in json there'd be no reason for the command to proceed

cloud dawn
slate swan
#

It is for creating new acc if you don't already have one

#

so if user.id in json file then command breaks

#

but, if user.id is not in json file, then it creates new acc

cloud dawn
slim ibex
#

^

quick gust
#

it's a command ^, just simply return if u don't want to proceed if user id is in json, i don't understand the point of true and false

slate swan
#

yeah i got confused too lol

prime bough
# cloud dawn !d disnake.Member.mention

thank you but I've tried and just putting the username.mention doesnt work ('tonino#0837'.mention does not work)

I saw a page where somebody suggested getting the real id of the author but i dont understand the command)

cloud dawn
prime bough
slim ibex
#

what is the difference between Disnake's AutoShardedBot, Bot, InteractionBot, and AutoShardedInteractionBot

#

i am making a bot for a server, and want to mainly use slash commands. i would assume one of the interaction bots would be the best?

cloud dawn
slate swan
#

as the name suggests Bot can be used to message commands as well, InteractionBot is based on application commands

sharded bots are used to make clusters of the bot for different servers

slim ibex
#

ahh so since this bot is just a one server, sharded bot wouldn't make sense

prime bough
slate swan
unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
slate swan
#

or if you mean manually, click on COPY ID from the user's profile

prime bough
cloud dawn
# slate swan because its for creating account
@client.command()
async def open_account(ctx, user: discord.Member=None):
    user = user or ctx.author
    users = await get_bank_data()

    if users.get(str(user.id)):
        users[str(user.id)] = {
                "wallet": 0,
                "bank": 0
            }

        with open("mainbank.json", "w") as f:
            json.dump(users, f, indent=4)
``` let's reformat it a bit first
cloud dawn
stark solar
#

Im looking for a web developer to help make a site for my bot.

cloud dawn
stark solar
#

okay

prime bough
cloud dawn
balmy ivy
#

why does it say this i dont have a other command named help

cloud dawn
stark solar
#

I am looking for a web developer to carry my web development for our bot
What does our bot do?
Our bot scans all links sent with a guild, compares them to a database of malicious links and deletes the bad ones, if its not in the database we use keywords to see if the link may be suspicious, and then it sends us a alert and we add it to the blacklist if it is
We are in 100 servers, totaling 265k members

slate swan
balmy ivy
cloud dawn
balmy ivy
#

oh alr

slate swan
#

assuming you would be creating help command for commands and cogs too ( since you are using bot.group) as subcommands, its better to use this

#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
cloud dawn
balmy ivy
slate swan
#

:/

cloud dawn
balmy ivy
stark solar
cloud dawn
slate swan
cloud dawn
stark solar
balmy ivy
slate swan
#

talking about malicious links

unkempt canyonBOT
slate swan
#

pithink this is pog

balmy ivy
slate swan
#

it should be inside commands.Bot

cloud dawn
#

!arg-kwargs

unkempt canyonBOT
#

*args and **kwargs

These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.

Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.

Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.

Use cases
Decorators (see !tags decorators)
Inheritance (overriding methods)
Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
Flexibility (writing functions that behave like dict() or print())

See !tags positional-keyword for information about positional and keyword arguments

balmy ivy
stark solar
cold sonnet
#

setting?

cloud dawn
stark solar
quick gust
stark solar
slate swan
#

command_prefix and help_command are kwargs for the Bot class

cloud dawn
#

Guys no need to say "it's easy" or something similar.

cloud dawn
#

They tell a lot about the person you are working with, experience etc.

stark solar
slate swan
stark solar
#

I mean if someone was joining sure they’d see it
but i’d rather not make our work public domain

cloud dawn
#

Best is to make some friends in this server, that's what @manic wing also did, we had a team of 8.

balmy ivy
#

thanks

slate swan
#

cool, yw

stark solar
#

how

cloud dawn
slate swan
cloud dawn
quick gust
#

including me

slate swan
#

and had no contribution.

manic wing
#

21 just makes it look like its alot when it really wasnt pithink

honest vessel
#

Am odd 😦

manic wing
#

✅ Hates 'EM
✅ Unvaxxed
yup

cloud dawn
honest vessel
cloud dawn
#

Now i know around 4 people here lol

honest vessel
#

hi panda

manic wing
#

ive got huge exams coming up in a month

tidal hawk
#

How do I add administrator check to a slash command?

stark solar
cloud dawn
quick gust
#

how huge

stark solar
#

@sick birch i have befriended you

cloud dawn
tidal hawk
#

so disnake.has_permissions?

slate swan
#

yea for disnake it works

honest vessel
#

Nothing wrong with be lilbit odd tho 😦

manic wing
stark solar
#

Perfect

slate swan
manic wing
#

i love quoting things

manic wing
honest vessel
#

debian or arch ❤️

cloud dawn
#

Be specific tough, sometimes when you say to him make a site. He will make an api instead.

slate swan
manic wing
slate swan
#

so, you have friends now

manic wing
stark solar
#

My dog smells like pee
How to patch bug?

manic wing
honest vessel
#

I can be all your friend

slate swan
cloud dawn
honest vessel
manic wing
slate swan
#

with replit

cloud dawn
manic wing
cloud dawn
#

At python day 7 i did comprehensions.

slate swan
#

🏃‍♂️

quick gust
slate swan
honest vessel
cloud dawn
# manic wing what even is php
<?php
$firstvalid = 0;
$total = 0;

foreach (preg_split("#\n\s*\n#Uis", file_get_contents("input.txt")) as $inp) {
    $data = "";
    foreach (explode("\n", $inp) as $exin2) {
        $data .= preg_replace("/\s+/", "", $exin2);
    }

    foreach (count_chars($data, 1) as $char => $val) {
        $firstvalid++;
    }
    
    if (stristr($inp, "\n")) {
        $answ = array();
        foreach(explode("\n", $inp) as $p) {
            for($i = 0; $i < strlen($p); $i++) {
                if(preg_match('/[a-z]/', $p[$i])) {
                    if(@!$answ[$p[$i]]) {
                        $answ[$p[$i]] = 1;
                    } else {
                        $answ[$p[$i]]++;
                    }
                }
            }
        }
        foreach ($answ as $k => $v) {
            if ($v == count(explode("\n", $inp))) {
                $total++;
            }
        }
    } else {
        preg_match('/[a-z]+/', $inp, $matches);
        $total += strlen($matches[0]);
    }
}
echo "Part 1:<br>" . $firstvalid . "<br><br>Part 2:<br>" . $total;
?>
``` this is what i made before python, for advent of code.
cloud dawn
honest vessel
#

php reminds me of old times

manic wing
#

what is php used for

honest vessel
#

web backend

cloud dawn
#

For smaller companies.

quick gust
#

its a general purpose language

honest vessel
#

communicate with db etc

manic wing
#

yikes

manic wing
cloud dawn
honest vessel
#

webshells 👼🏻

slate swan
#

!Ot 🏃‍♂️

unkempt canyonBOT
#
Did you mean ...

» ot
» off-topic-names

slate swan
#

e

quick gust
#

the fail

cloud dawn
slate swan
#

😔 why didnt they make the commands case insensitive

honest vessel
#

@cloud dawnever tested ASP? 😄

slate swan
#

!D discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

no wait, some of them are

cloud dawn
#

Coding a c# program for a bowling ally.

honest vessel
#

@cloud dawndont even waste ur time with ASP 😄

manic wing
#

ive done a bit of c++, but its so irrelevant and pointless

slate swan
#

am i the only person here who prefers rust over c and c++

honest vessel
#

C# can be good to learn theres alot of jobs with it

manic wing
cloud dawn
manic wing
cloud dawn
honest vessel
#

@cloud dawndo they pay u well for that bowling app?

quick gust
#

lmao u pinged him again

honest vessel
#

@quick gustyes

cloud dawn
#

@quick gust lol

honest vessel
#

oh so you do it for learning / free time

quick gust
cloud dawn
quick gust
#

dont ping! smh!

cloud dawn
honest vessel
#

maybe u get free bowling sessions 😛

quick gust
slate swan
cloud dawn
honest vessel
#

ooh

cloud dawn
#

So i can always bowl for free xd

honest vessel
#

nice cool

slate swan
cloud dawn
honest vessel
#

I get a feeling you are american

slate swan
#

Ah

cloud dawn
#

Who is "you"?

honest vessel
#

you @cloud dawn

cloud dawn
#

I'm dutch

honest vessel
#

cool, sweden here

cloud dawn
#

Imagine controlling the bowling lanes with a discord bot 😏

red nest
#

germany here

slate swan
#

#not-so-discord-bots-chat

quick gust
#

!ot

unkempt canyonBOT
cloud dawn
#

so trap-love-calculator huh

red nest
honest vessel
#

discord bot to blend the drinks too 😛

#

.blend mojito

slate swan
#

.topic

lament depotBOT
#
**Do you think there's a way in which Discord could handle bots better?**

Suggest more topics here!

slate swan
#

yes, gib message intents

quick gust
#

someone suggest more topics!

manic wing
#

.topic

cloud dawn
#

Make the api more friendly towards all coding languages and not java and js

honest vessel
#

i can drop an idea - discord chat 1-on-1 with voicechat/video/only text like strangers/omegle but on discord

cloud dawn
honest vessel
#

i was more thinking of a server+bot doing the matching

#

and bots open channels for the matched onces and deletes em when done

cloud dawn
manic wing
#

its an api, its not really friendly or not friendly

cloud dawn
#

I'm assuming now you have never seen the raw api

honest vessel
cloud dawn
#

Just 9/10 times it is poor execution.

honest vessel
#

true

vague grove
#

how can i detect if my on_message author is a bot?

cloud dawn
nimble plume
#

How to make stuff in pictures like welcome images and stuff

unkempt canyonBOT
cloud dawn
#

Blocking lib though.

#

Best is to use this and make your own api if you know how to.

#

For small bots it's fine ig

nimble plume
#

Can u advice something

cloud dawn
#

Is your bot big or small?

nimble plume
#

Small now...

nimble plume
cloud dawn
#

Well you won't really notice the blocking if it is a small bot.

slate swan
#

run_in_executor exists too btw

vague grove
cloud dawn
slate swan
#

!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:
cloud dawn
unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

tidal hawk
#

Came with Slash command
SyncWarning: Failed to overwrite commands in <Guild id> due to 400 Bad Request (error code: 50035): Invalid Form Body

nimble plume
#

Sarthak nitro gorn

slate swan
#

could be archived thru Bot.loop.run_in_executor

tidal hawk
#

SyncWarning: Failed to overwrite commands in <Guild id=894630645547024536> due to 400 Bad Request (error code: 50035): Invalid Form Body
In 0.options.0.description: This field is required
In 0.options.1.description: This field is required

slate swan
#

use the old disnake method for slash commands

cloud dawn
nimble plume
cloud dawn
nimble plume
tidal hawk
cold sonnet
#

same

cloud dawn
nimble plume
#

But u say create ur own api??

tidal hawk
# cloud dawn ?

Well I had two slash commands, i removed the other one and the problem stands

honest vessel
#

if you use a non asynco with asyncro it will block

slate swan
# cloud dawn ?

they have an option without description,which is no longer supported by discord py @slash_command(description='qerts') async def my_slash(interaction, option): is no longer working

nimble plume
#

Pillow is non asynco??

tidal hawk
#

Bruh it started working randomly

tidal hawk
slate swan
#

check the disnake announcements

cloud dawn
tidal hawk
#

Alright

slate swan
#

and its for some other command, not this one

cloud dawn
honest vessel
cloud dawn
#

If you use the old method you can almost better make a raw api request lol

nimble plume
cloud dawn
honest vessel
nimble plume
honest vessel
#

if alot uses bot it will clog up af

quick gust
nimble plume
#

Oh

cloud dawn
honest vessel
#

you can do ur bot only for that, and have another bot for moderation e.q

slate swan
# cloud dawn Since when is the new one invalid? Since if it is just don't use slash since thi...

Yesterday Discord changed the validation of slash command options. Empty descriptions and descriptions with invisible symbols are no longer allowed. Since disnake inserted \u200b as a default value of slash command descriptions, old versions no longer allow to register commands with options that miss a description. We released a fix that returns everything back to normal.

This is a critical issue, so we updated both 2.2.x and 2.3.x branches in order to give big bots an opportunity to apply the fix without switching to newer versions.

this was the announcement, im sure its related

honest vessel
nimble plume
honest vessel
#

when ur bot gonna process pic, and someone gonna ban or something sametime the ban will take tiime till processed is done

nimble plume
#

Oh

halcyon onyx
#

hey

#

import discord
import random

Token = "nothing"
client = discord.Client()

@client.event
async def on_ready():
print("logged in ;beep boob; as {0.user}".format(client))

@client.event
async def on_message(message):
if message.author == client.user:
username = str(message.author).split("#")[0]
user_message = str(message.content)
channel = str(message.channel.name)
print(f"{username}: {user_message} ({channel})")

    if message.author == client:
        return

    if message.channel.name == "gogogaga":

        if user_message.lower() == "hello":
            await message.channel.send(f'Hello! {username}')
            return

        elif user_message.lower() == "bye":
            await message.channel.send(f'bye! {username}')
            return

        elif user_message.lower() == "!random":
            response = f"This is the random number: {random.randrange(1000000)}"
            await message.channel.send(response)
            return

    if user_message.lower() == '!anywhere':
        await message.channel.send("this message can be used anywhere")
        return

client.run(Token)

cloud dawn
halcyon onyx
#

why that doent work

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

tidal hawk
#

this s$$$ aint working no more

tidal hawk
cloud dawn
honest vessel
#

username = str(message.author).split("#")[0] :S

slate swan
#

or just try to update disnake and see if its fixes the issue

cloud dawn
nimble plume
#

Pls reply or ping me if u are saying to me ...

slate swan
#
$pip install -U disnake```
honest vessel
cloud dawn
honest vessel
#

thats display_name ?

tidal hawk
#

Thanks bro, the update fixed it @slate swan

river flare
#

how can i send in an embed a server's static (not animated) emoji?

slate swan
#

server's emoji?

#

do you mean the icon?

river flare
#

yeah like this one in this server:brainmon

slate swan
#

Bot.get_emoji(id) or \emoji and get the escaped name of the emoji

honest vessel
cloud dawn
#

Imagine the amount of duplicated emoji's in their database lmao

honest vessel
#

copy link of emoji to gets it id's

cloud dawn
#

80% certain they have some kind of imaging filter to remove dupes and merge their id's

nimble plume
#

Ill create a different bot for server design

honest vessel
#
<a:name_of_emiji:id_of_emoji>
stark solar
# sick birch ?

Im looking for someone to join my bot development team and make the website for it

sick birch
#

Already working for one sorry

honest vessel
sick birch
#

^ good learning experience to try it out yourself

cloud dawn
sick birch
#

Though I personally think JavaScript frameworks are better for the job but I never turn down a learning opportunity

honest vessel
#

oh i thought he just wanted a simple website

stark solar
honest vessel
#

but you wanna run a project xD?

stark solar
#

no, I run a project

cloud dawn
stark solar
#

I can market, handle seo n stuff

sick birch
honest vessel
#

i pretty sure all who makes websites knows seo too

stark solar
honest vessel
#

dont you use github for your project tho?

sick birch
#

But tbh it’s mostly just changing or adding entries to a database which I just use PrismaORM for so it’s not too bad

sick birch
cloud dawn
honest vessel
#

@sick birchnah zachry

sick birch
#

Ah

cloud dawn
stark solar
#

wat

sick birch
#

Anything non OSS is cringe

cloud dawn
manic wing
sick birch
cloud dawn
honest vessel
manic wing
#

oh didnt know

#

look at you windows users

cloud dawn
manic wing
#

i have to look down at you guys

honest vessel
cloud dawn
#

Think about the chad who remade windows 98 inside js

honest vessel
#

wish windows10 or 11 was opensource ducky_devil

hardy wing
#

is it possible to make a bot dm someone it's in a server with without that person triggering an event like send message or react?

#

trying to make my bot dm me every time it joins a server

honest vessel
manic wing
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
slate swan
honest vessel
cloud dawn
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

hardy wing
#

so I can keep track of servers it's in

manic wing
slate swan
honest vessel
#

on_guild_join() for when bot joins a new guild

manic wing
slate swan
#

I did not know we needed to repeat all the answers

manic wing
#

😄

hardy wing
#

yes I know that my question is how do I make it dm me when it does that

honest vessel
#

just tell bot to send you a message

cloud dawn
hardy wing
#

but how do I get my user from a server

#

to get it to dm me

honest vessel
#

fetch it by id or something

slate swan
cloud dawn
hardy wing
slate swan
#

remember you don't need a member object, a user object is enough

hardy wing
cloud dawn
unkempt canyonBOT
hardy wing
#

kk thnx

honest vessel
#

yeah or await self.bot.fetch_user(theid)

slate swan
#

I guess something along the lines of _bot.get_user(_bot.owner_id).send("i joined a guild")

slate swan
#

it's most probably in cache, so rather handle that than make an extra API call

cloud dawn
honest vessel
#

ah true

cloud dawn
#

disnake getch guys, revolution.

slate swan
#

g-getch?

honest vessel
#

huh?

cloud dawn
#

!d disnake.ext.commands.Bot.getch_user

unkempt canyonBOT
#

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

Tries to get the user from the cache. If fails, it tries to fetch the user from the API.
honest vessel
#

aah nice

slate swan
#

nice indeed

honest vessel
#

yeah if seen many otherwise use like u = get_user() or fetch_user()

cloud dawn
#

They removed that it will be added to the cache if it wasn't :DDD
Now this function is absolute god

cloud dawn
#

But now i use that.

honest vessel
#

that wasnt bad thinking tho, then u no need worry about what

cloud dawn
#

Yep this function is disnake only tough.

honest vessel
#

basedfork

cloud dawn
#

Partly because me and hunter cried about it lol

honest vessel
#

😄

ripe steppe
#

👋

honest vessel
#

sometimes crying paysoff 😛

honest vessel
ripe steppe
#

how are you guys