#discord-bots

1 messages · Page 771 of 1

slate swan
#

but i didnt understand one thing which is await bot.process_commands(message)

spring flax
#

can i see your task

royal oar
#

I changed the timing from 90 to 300 so it isnt refreshing so often

@tasks.loop(seconds = 300) # repeat after every 90 seconds
async def myLoop():
  channel = client.get_channel(934725310027530260)
  await channel.edit(name=f"Counter: {str(len(client.guilds))}")
cold sonnet
#

client doesn't have commands

boreal ravine
unkempt canyonBOT
#

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

This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.

By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.

This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
royal oar
slate swan
cold sonnet
#

you just named it wrong

boreal ravine
#

not for you

spring flax
cold sonnet
#

wait_until_ready brawl_cry

devout iris
#

i already have on_message event, can i add 1 more?

cold sonnet
#

you can add a listener

#

but there's absolutely no need to do that

devout iris
#

Hmm what can i do then?

cold sonnet
#

put code in your on_message

slate swan
#

How do I check if a message that sent is from a spammer?

spring flax
spring flax
cold sonnet
#

otherwise the get will return None

slate swan
royal oar
limpid thicket
#

That will probably be part of it's moderation settings and client side to those specific members, I don't think you can

cold sonnet
#

!d discord.ext.commands.Bot.wait_until_ready

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.
cold sonnet
#

in your case, await client.wait_until_ready()

slate swan
#

hey i have this command ad i get thir error ```python
@j1mk0l.command()
async def test123(ctx):
r = requests.get(f'http://51.89.34.216:30802/players.json')

events = r.json()
name = str(config['servername'])
em = nextcord.Embed(title=':green_circle: Server Is Online!', description=f"Για να συνδεθείτε στον {name}Ανοίγεται FiveM, πατάτε F8 και γράφεται `connect `", color=color, timestamp=datetime.now())
em.set_author(name=name)
em.add_field(name = '`Online Playes:`', value= int(events['id']), inline = True)
await ctx.send(embed=em)

Command raised an exception: TypeError: list indices must be integers or slices, not str

royal oar
# cold sonnet in your case, await client.wait_until_ready()
@tasks.loop(seconds = 300) # repeat after every 300 seconds
async def myLoop():
  await client.wait_until_ready()
  channel = client.get_channel(934725310027530260)
  await channel.edit(name=f"Counter: {str(len(client.guilds))}")
myLoop.start()
``` like that?
spring flax
#

yes

echo wasp
#

that broke my bot so it won't run

echo wasp
#

should i just remove it

royal oar
#

cool thank you

cold sonnet
echo wasp
cold sonnet
#

so how did it break your code

#

did you use that if statement correctly

echo wasp
echo wasp
cold sonnet
#

no idea what your code looks like now

echo wasp
#
import os
import discord
import time
import datetime
import asyncio
from discord.ext import commands
class Events(commands.Cog):
    def __init__(self,client):
        self.client = client
    @commands.Cog.listener()
    async def on_ready(self):
        for guild in self.client.guilds:
            print(guild.name)
            print(guild.me.guild_permissions)
            print(
            f'{self.client.user} is connected to the following guild:\n'
            f'{guild.name}(id: {guild.id}) \n'
            )
            members = '\n - '.join([member.name for member in guild.members])
            print(f'Guild Members:\n - {members}') 
    @commands.Cog.listener()
    async def on_member_join(self, member: discord.member):
        if member.guild.id == 804864012184977438 : return
        channels = member.guild.channels
        for channel in channels:
            if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name)
                 embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!")
                 embed.set_thumbnail(url=member.avatar_url)
                 if isinstance(channel, discord.TextChannel):
                    await channel.send(embed=embed)
    @commands.Cog.listener()
    async def on_member_remove(self, member: discord.member):
        if member.guild.id == 804864012184977438 : return
        channels = member.guild.channels
        print([channel.name for channel in channels])
        for channel in channels:
            if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()): #or ('testing' in channel.name):
                embed=discord.Embed(title=f"Goodbye, {member.name}", description=f"Bye {member.name} come again soon")
                embed.set_thumbnail(url=member.avatar_url)
                if isinstance(channel, discord.TextChannel):
                   await channel.send(embed=embed)```
echo wasp
cold sonnet
#

so now

echo wasp
#

lol 😆

cold sonnet
#

if channel is a textchannel

#

it will send an embed

echo wasp
#

read code

cold sonnet
#

yeah I read it

echo wasp
#

i had no idea it was there

#

no wonder lol

cold sonnet
#

huh

#

I read this

        channels = member.guild.channels
        for channel in channels:
            if ('welcome' in channel.name.lower()) or ('joins' in channel.name.lower()): #or ('testing' in channel.name)
                 embed=discord.Embed(title=f"Welcome {member.name}", description=f"Thanks for joining {member.guild.name}!")
                 embed.set_thumbnail(url=member.avatar_url)
                 if isinstance(channel, discord.TextChannel):

#

that if statement at the end is always true

echo wasp
cold sonnet
#

so you can remove that isinstance line

echo wasp
# cold sonnet so you can remove that isinstance line

no py @commands.Cog.listener() async def on_member_remove(self, member: discord.member): if member.guild.id == 804864012184977438 : return channels = member.guild.channels print([channel.name for channel in channels]) for channel in channels: if ('leave' in channel.name.lower()) or ('goodbye' in channel.name.lower()): #or ('testing' in channel.name): embed=discord.Embed(title=f"Goodbye, {member.name}", description=f"Bye {member.name} come again soon") embed.set_thumbnail(url=member.avatar_url) if isinstance(channel, discord.TextChannel): await channel.send(embed=embed) find the print line

#

i forgot it was there

#

lol

cold sonnet
#

I SEE IT BUT I'M TALKING ABOUT SOMETHING ELSE 😢

echo wasp
#

i made a mistake

cold sonnet
#

I know

echo wasp
desert ice
#

Where can i host my bot for free?

cold sonnet
#

you see, Evel

#

nothing's free in life

desert ice
#

Ok

#

Where can i host my bot tha doesnt need a credit/debit card to pay

graceful gulch
#

i mean

#

are you willing to pay

#

i guess you can use stuff like paypal

desert ice
#

Ive tried many sites but i cant with paypal

#

Only with card

devout iris
#

seems good?

cold sonnet
#

no

devout iris
#

hm

cold sonnet
#

if message in ...:

spring flax
#

you need to put it in strings

graceful gulch
cold sonnet
#

what's kelimeler

desert ice
graceful gulch
devout iris
graceful gulch
graceful gulch
desert ice
#

Ok

cold sonnet
devout iris
graceful gulch
#

the list is empty so it will always return false

cold sonnet
#

that's a string, yeah

graceful gulch
devout iris
graceful gulch
#

that works

devout iris
#

thx

desert ice
devout iris
#

also i add a for loop for send x4 times, is that true?

graceful gulch
devout iris
#

ah why i returned msg veriable smh

graceful gulch
graceful gulch
#

remote the return btw

pine crown
#

how to make slash commands with 3rd party libraries

devout iris
#

i removed return.

#

also how can i add rate limits?

graceful gulch
graceful gulch
devout iris
#

k

graceful gulch
#

?

slate swan
zinc scroll
#

Hi group. I am trying to find a good place to ask some noobish stuff about GPT-NEO and happytransformer.

devout iris
zinc scroll
#

Is this something you make use of?

devout iris
slate swan
#

Remove those parenthesis

devout iris
#

ah yes smh, ty

edgy lion
#
    @commands.Cog.listener()
    async def on_guild_channel_update(self, before, after):
        async with aiohttp.ClientSession() as session:
            async with self.db.execute(
                    f"SELECT webhook, guild_id from 'logging' where guild_id = {before.guild.id}",
            ) as cursor:
                config = await cursor.fetchone()

            if config is not None:
                webhook = Webhook.from_url(config[0], adapter=AsyncWebhookAdapter(session))
                if before.guild.id == int(config[1]):
                    async for entry in before.guild.audit_logs(action=discord.AuditLogAction.channel_update,
                                                               oldest_first=False):
                        embed = discord.Embed(
                            description=f'Channel was updated ({after.mention})',
                            color=discord.Color.dark_theme()
                        )
                        embed.set_author(name=entry.user, icon_url=entry.user.avatar_url)
                        embed.timestamp = datetime.datetime.utcnow()
                        embed.set_footer(text=f'{self.bot.user}', icon_url=self.bot.user.avatar_url)
                        embed.add_field(name='Creation date', value=f'<t:{round(before.created_at.timestamp())}:D>',
                                        inline=False)

                        if before.overwrites:
                            embed.add_field(name='Overwrite deleted',
                                            value=f'For: role Undefined',
                                            inline=False)
                        if after.overwrites:
                            embed.add_field(name='Overwrite created',
                                            value=f'For: role Undefined',
                                            inline=False)
                        await webhook.send(embed=embed)```does anyone know why the field is not added, although I add a permission to a channel
echo ore
#

OSError: [WinError 10038] An operation was attempted on something that is not a socket. How to fix this error

devout iris
#

:/ hmm

bold sable
#

Can i get help her for my discord bot?

solid summit
devout iris
#

yep i fixed thx

slate swan
bold sable
#

well, i'm trying to get a username from a steamid64 for my bot, not sure how implement the SteamAPI, more here #help-bagel

finite cobalt
#

is there anyway to host your dc bot free on a online cloud?

finite cobalt
#

Whats the best free way to host you bot

graceful gulch
#

host on ur pc

finite cobalt
#

But then my pc needs to run the whole time

graceful gulch
#

yes

finite cobalt
#

is there any other way

slate swan
#

How to define buckettype

boreal ravine
unkempt canyonBOT
karmic lintel
unkempt canyonBOT
#

@karmic lintel :white_check_mark: Your eval job has completed with return code 0.

3
boreal ravine
#

what

#

go to #bot-commands

karmic lintel
#

@boreal ravinethe coding realm ...

boreal ravine
boreal ravine
tacit token
#

hi guys, my problem: This code created Muted role, but not set speak false etc.., and not add to member.

slim ibex
#

just set permissions to 0

tacit token
#
@client.command()
@commands.has_permissions(kick_members=True)
async def mute(ctx,member : discord.Member,*, reason="Not specified"):
    guild = ctx.guild
    mutedRole=discord.utils.get(guild.roles, name="Muted")
    
    if not mutedRole:
        await guild.create_role(name="Muted")
    
    if member==ctx.author:
        await ctx.send("You cannot mute yourself.")
        
        for channel in guild.channels:
            await channel.set_permission(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    embed=discord.Embed(title="Muted", description=f"{member.mention} was muted ", colour=discord.Colour.light_gray())
    embed.add_field(name="reason:", value=reason, inline=False)
    await ctx.send(embed=embed)
    await member.add_roles(mutedRole, reason=reason)
    await member.send(f" you have been muted from: {guild.name} reason: {reason}")
slim ibex
#
perms = discord.Permissions(permissions=0)
muted_role = await context.guild.create_role(name="Muted", permissions=perms)
#

and why is your for loop inside the if where it checks for the author

potent spear
#

there are other problems to discuss

slim ibex
#

mhmm

honest vessel
#

@cloud dawn you here?

round widget
#

so, a quick question, here's my code:

        await inter.response.send_message(embed=embed)
        msg = await inter.original_message()
        await msg.add_reaction(emoji="\U00002705")```
so there's nothing wrong with this, but I'm wondering how do I get a user printed out every time someone reacts to the message? I tried using `msg.users` but for apparently my msg has no attribute users
honest vessel
#

does anyone have the datetime format link for like <t:unixtime:R>

round widget
#

@potent spear oh ok, thanks!

slate swan
#

hellow guys. I have a command with buttons (which works) but when i restart the bot i need to resend the command in order for tha button to work. How can i make it permantly?

reef trail
#

how can i make a command work if someone is replying to something? I keep getting issues where it requires arguments that are missing

devout iris
#

How can i check if message author is bot?

reef trail
devout iris
#

Can I use 3 and inside an if condition?

reef trail
#
if something and something and something:
    do something```
 yes
devout iris
#

Thx

#

but i still have a problem

reef trail
#

what is your problem

potent spear
#

you probably just want
if shit in ['fart', 'new pants', 'flush']:

potent spear
#

not if shit == 'fart' and shit == 'new pants' and ...:

#

which isn't possible anyways, but yeah

reef trail
#

it is

potent spear
#

shit can't be fart AND new pants

devout iris
#

it should work on bots, but when owo bot send message, my bot is not doing anything...

reef trail
#

you should prolly do that in multiple lines

slate swan
#

hellow guys. I have a command with buttons (which works) but when i restart the bot i need to resend the command in order for tha button to work. How can i make it permantly?

potent spear
devout iris
slim ibex
reef trail
#

if something in something:
if something:
etc etc

potent spear
devout iris
#

hmm.. why

potent spear
#

you'll found out why

devout iris
potent spear
#

what you're currently checking is if message.content is any element in that list

reef trail
#

okay what are you trying to do

finite cobalt
#

How do i delete a message

reef trail
cerulean quest
#

hello everyone, i'm working on a basic python bot. its currently setup on my private server just for some testing reasons. i have pip installed the discord module and everything is going great. i'm following some code off a tutorial i found, and currently i'm just trying to get the bot to appear online. when the tutor is executing the code, and once it works, the message "we have logged in as (bot-name#example number) will appear when it runs. the bot will also appear online. i have been trying to do the same thing, although when i use my code, `import discord
import random

TOKEN = "example of token"

client = discord.Client()

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

client.run(TOKEN)` but instead of it saying we have logged in as i specified, it instead floods me with so many errors, so many to even count. can someone tell me what i'm doing wrong? my dms are open btw

devout iris
#

look. i want to check owo bot's messages and if owo bot send messages in my message list, bot will dm me

potent spear
#

hint
if shit_string in shit_list:
is incorrect

devout iris
#

ah

devout iris
#

so what is correct?

potent spear
tacit token
#
async def createMutedRole(ctx):
    mutedRole = await ctx.guild.create_role(name = "Muted",
    permissions = discord.Permissions(False),
    reason = "Creation of the Muted role to mute people.")
    for channel in ctx.guild.channels:
        await channel.set_permissions(mutedRole, send_messages = False, speak = False)
    return mutedRole

async def getMutedRole(ctx):
    roles = ctx.guild.roles
    for role in roles:
        if role.name == "Muted":
            return role
    
    return await createMutedRole(ctx)

This code not set permissions, but created Role. Anybody help ? lemon_infant

potent spear
slim ibex
#

its discord.Permissions(permissions=0)

potent spear
devout iris
cerulean quest
potent spear
slim ibex
#

nothing to do wiht ide

cerulean quest
#

oh shoot, i confused it with an IDE for c

#

mb

potent spear
cerulean quest
#

oh

potent spear
#

instead of
shitting = True while shitting: print("wipe")

#

^^ this is trash

slim ibex
#

what an example of shitting

cerulean quest
#

oh ok, whats the command to use a code block?

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.

cerulean quest
#

example text

#

ah ok, it works

#

let me use codeblocks then

potent spear
#

yup, same question, better format

cerulean quest
#
import discord
import random

TOKEN = "example token"

client = discord.Client()

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

client.run(TOKEN)
modern fiber
#

HOW DO I UNDO SMTH ON PYCHARM

cerulean quest
tacit token
potent spear
#
True```
tacit token
cerulean quest
potent spear
#

best practice is just to use github, in case you messed up yesterday, you can just check a previous commit
it's something to get used to tho

cerulean quest
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.

modern fiber
#

Guys how do I fix this? Like whats wrong

cerulean quest
modern fiber
#

I wanna get rid of embed

potent spear
modern fiber
#

oh

#

so what I do?

potent spear
modern fiber
#

@potent spear

potent spear
#

alright?

#

if a new member joins, how in the world would a bot know to WHICH channel he should send a message?

modern fiber
#

no?

potent spear
#

your second line gets the channel, that's great

modern fiber
#

Yeah,

potent spear
#

channel = client.get_channel(<shit_id>)
await channel.send("hi")

#

your first line should create an embed ofc

#

it's not ctx.send, it's discord.Embed

modern fiber
#

I don't want an embed,

#

thats the problem.

potent spear
modern fiber
potent spear
cerulean quest
potent spear
#

show me the traceback

#

have you read EVERY line of the traceback? something, just reading is enough

cerulean quest
#

btw, the errors are so many, its -774 below the discord character limit

final iron
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

final iron
#

Use this

cerulean quest
#

ok ty

placid zodiac
#

is there any way to modify the author of a message before using bot.process_commands? Or to construct a new context with a different author but the same reference message

slim ibex
#
async def with_commit(func: Callable[..., R]) -> Callable[..., Awaitable[R]]:
    async def inner(*args, **kwargs) -> R:
        await commit()
        return func(*args, **kwargs)

    return await inner 

Isn't this function beautiful?

#

doesn't work properly but 😍

cerulean quest
#

this is the issue, the code is perfect although it gives errors

potent spear
#

are you on MacOS by any chance?

cerulean quest
#

yeah

slim ibex
#

^

#

thats why

cerulean quest
#

oh!

potent spear
#

simple fix

#
Getting [SSL: CERTIFICATE_VERIFY_FAILED] on Python 3 on OS X?
Navigate to your Applications/Python 3.X/ folder and double click the Install Certificates.command to fix this.
Happy coding!```
round widget
#

so I still can't get my reaction list to populate

        await inter.response.send_message(embed=embed)
        msg = await inter.original_message()
        await msg.add_reaction(emoji="\U00002705")

        users = set()
        for reaction in msg.reactions:
            async for user in reaction.users():
                users.add(user)```
what am i doing wrong?
cerulean quest
#
[SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
potent spear
cerulean quest
#

ah that explains it

round widget
potent spear
cerulean quest
#

@potent spear i did as u said, i have installed the certificate and HOLY, IT WORKS, THANK YOU SO MUCH

potent spear
#

gl

round widget
potent spear
#

just print whenever you loop in the for loop

#

that way, you'll be sure there's even something in there

round widget
#

hmm ok let me try

bold sable
#

someone experienced with using steamapi?

potent spear
bold sable
#

welp i'm very new to python lol

potent spear
#

try the basics first

#

like learn OOP (classes, methods attributes, ...) move on from there

slim ibex
#

discord bot is not a good beginner project

potent spear
#

surely not

#

but most people get into python because of a discord bot :/

bold sable
slim ibex
#

I changed it to this @boreal ravine

def with_commit(func: Callable[P, R]) -> Callable[P, Awaitable[R]]:
    async def inner(*args: P.args, **kwargs: P.kwargs) -> R:
        await commit()
        return func(*args, **kwargs)

    return inner 
boreal ravine
#

ot but whats P/R

slim ibex
#

P is a paramspec variable

boreal ravine
#

from typing module?

slim ibex
#

so i can enforce the params of the inner func

bold sable
round widget
# potent spear just print whenever you loop in the for loop

well i did and it remains empty

        await inter.response.send_message(embed=embed)
        msg = await inter.original_message()
        await msg.add_reaction(emoji="\U00002705")

        users = set()
        for reaction in msg.reactions:
            async for user in reaction.users():
                users.add(user)
        print(f"players: {users}")```

returns `players: set()`
potent spear
potent spear
round widget
#

it's there, literally that print(f"players: {users}") line

potent spear
#

"whenever you loop IN the for loop"

bold sable
potent spear
#

like print("looping through reaction")
print("looping through user")

round widget
potent spear
round widget
#

eh ffs I gotta run now, but I'll keep it in mind. cya guys later

bold sable
#

this checks for certain text per line

potent spear
#

not really relevant

#

I just want to know where it saves the steam ID

#

if you can just replace the steam ID with the steam name via an API, it'll be simple

#

the only problem could be: the data gets stored for a long time and someone changes his steam username
that's why people use steamID's, since those can't change
what you CAN do tho, is get the username whenever you print, instead of saving the username, you still save the ID, but get its username

bold sable
#

this saves some infos in a csv

honest vessel
#

error.param <- gives me missing parameters in erorr, but how i get what name of command it was used

potent spear
fresh orchid
#

so I have a list like this with some IDs of discord member

spammers = [id, another id, another id]

And now I want to check if one ID is five times or more in this list
Anyone knows how to do that?

finite cobalt
#

I want that you also can permit roles to join a channel. How can i do that?

potent spear
finite cobalt
potent spear
#

let's start with the first big error
if you try ?permit @finite cobalt when you're not in a voice channel, you'll get a big error

flat solstice
#

Am i right in thinking that this will check if the role id of the after role is in my list of level_rewards but will only start checking from the third item in the list? ```py
level_reward_role = discord.utils.get(after.guild.roles, id = [id for id in self.bot.config.level_rewards[2:]])

potent spear
#

first thing you should check
if the author isn't in a voicechannel, notify him and stop the command (return)

#

that's the VERY FIRST step

potent spear
#

second big thing to fix

#

bot_commands is a terrible variable name
better would be
bot_commands_channel = guild.get_channel(<yourstinkychannelID>)

cerulean quest
#

im working on my bot, everything is going well, but an issue i have come across is that i want the bot to say text, only that it would be covered in because its a spoiler. in my code i do py print ("sample text \r /spoiler suprise!")

#

can somone help?

flat solstice
final iron
potent spear
#

||this is a spoiler||

karmic lintel
#

e

cerulean quest
#

im creating a new line for my spoiler text

fresh orchid
#

why this isnt working?

spammers.append(message.author.id)
spammers = []
a = dict(Counter(spammers))

When I pint a in only get {} with nothing in it
But when I print spammers I get a full list with many IDs two times or more

potent spear
#

||this is a stinky spoiler||

potent spear
fresh orchid
slim ibex
#

lmao

fresh orchid
#

I just want to do it right but idk how to

slim ibex
#

what are you trying to dfo

bold sable
fresh orchid
#

I want to add the message.author id to the list evrytime he sends a message

And then if the id is more then 5 times in the list I want to send something

potent spear
slim ibex
tardy lagoon
#

Is it possible to get a python code from discord
Example command
!execute await ctx.send("test execute")
And execute it like

@client.command(hidden=True
async def execute(ctx,*,snip):
  exec(snip)
slim ibex
#

and use an if to see if they are in there more times

#

🤨

fresh orchid
#

😅

slate swan
#

cof cof

fresh orchid
potent spear
slate swan
#

@fresh orchid you can get the author id and use the append function

slim ibex
#

thats what i said ye'

slate swan
slim ibex
#

might look something like this

slim ibex
#
authors = []
authors.append(context.author.id)
fresh orchid
#

ok

fresh orchid
#

i will try

slim ibex
#

and then do

finite cobalt
#

How do i check if a user is connected to a voice channel?

slim ibex
tardy lagoon
#

K i'll just google

potent spear
slate swan
potent spear
unkempt canyonBOT
#

property voice: Optional[discord.member.VoiceState]```
Returns the member’s current voice state.
potent spear
potent spear
#

it's like
!e py 5+5

#

hmm

#

that's something you could do with your own bot

unkempt canyonBOT
#

@potent spear :white_check_mark: Your eval job has completed with return code 0.

I smell like shit
slate swan
#

Also also

#

I have a question

finite cobalt
potent spear
slate swan
finite cobalt
maiden fable
#

Use pillow or any API (easier way)

potent spear
slate swan
slate swan
#

Lmao oki

maiden fable
#

!pypi pillow

unkempt canyonBOT
keen talon
maiden fable
#

Tho using dagpi API or smth is easier

potent spear
#

it's a python lib, idk why it's called that
that's just them having an existential crisis

slate swan
maiden fable
#

Okay, sorry about that

slate swan
potent spear
#

the bar has to be low nowadays, you don't wanna know what kind of questions get asked here

maiden fable
potent spear
fresh orchid
potent spear
slate swan
#

Lmao

fresh orchid
#

Exactly

slim ibex
#

LMAO

potent spear
#

you don't know what the Counter() is returning obviously

slate swan
#

Thats insulting lol

maiden fable
fresh orchid
#

the counter returns something like {id : 5}

slim ibex
#

dude ends careers day in and day out

potent spear
#

a dict has key value pairs
the key being your member id, the value being how many times it was counted in the list

#

so if I wanted to know how many times I shat it would be
Counter(shit_list)['shat']

finite cobalt
#

How do i check if a user isn^t connected to a voice channel

potent spear
#

shit_list= ['shat', 'shat', 'clean_pants', 'clean_pants']

tardy lagoon
#

How to install jishaku?

potent spear
potent spear
tardy lagoon
#

Nvm

potent spear
#

or even better: their docs

tardy lagoon
#

Pypi

finite cobalt
potent spear
potent spear
fresh orchid
potent spear
slate swan
finite cobalt
slate swan
#

The user voice is none

finite cobalt
#
        print("not connected")```
slate swan
#

Apply brain

potent spear
finite cobalt
#

Im new to programming so i dont know

potent spear
#

in YOUR CASE
this only checks if the member you mentioned is in a voicechannel
it DOESN'T check if the author is in a voicechannel

#

it's logic, not really programming involved

slate swan
#

pithink am i the only one who spent 20 hours learning python

finite cobalt
final iron
#

20 hours really isn't a lot

#

That's a very tiny amount of time

potent spear
slate swan
finite cobalt
#
        print("not connected")```But this is also an error
slate swan
#

Lmaooo

potent spear
#

ctx.author mate, pls

#

you did it before 🧠

finite cobalt
potent spear
#

ABOVE that if statement?

finite cobalt
slate swan
slate swan
potent spear
#

well, your main problem is, even though you print that the author isn't connected, you still process the other code

#

you have to RETURN after finding out the author isn't connected

slate swan
#

mhm makes sense , I don't see anything which may raise an error ( except for if the command was used in dms)

slate swan
#

Lol cute

finite cobalt
slate swan
#

Yeah

finite cobalt
# slate swan the error?

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'channel'

slate swan
#

No

slate swan
#

that's where the error comes from.

keen talon
slate swan
finite cobalt
potent spear
keen talon
#

@slate swan btw what is hikari

slate swan
#

who uses stack when you can just check random git repos and copy code

potent spear
#

^^ main method

slate swan
slate swan
keen talon
slate swan
#

!PyPi hikari

unkempt canyonBOT
maiden fable
slate swan
keen talon
slate swan
slim ibex
#

!pypi pincer

unkempt canyonBOT
keen talon
slim ibex
#

both are in alpha

slate swan
maiden fable
slate swan
#

Hunter the !ot man

#

hello gentlemen and gentlewomen

maiden fable
#

¯_(ツ)_/¯

keen talon
maiden fable
keen talon
slate swan
maiden fable
#

¯_(ツ)_/¯

slate swan
#

something which actually makes me to read the docs again and Again

maiden fable
#

I'm out

#

Also, docs are BOOORING

slate swan
#

not if they have a dark theme with codeblocks and a purple text theme

maiden fable
#

Still they are BOOORING

keen talon
potent spear
#

how can you not make docs boring?
It's not like you get a cookie per page you read

slate swan
#

i have a question: how can i implement a purge command in my bot?
i have discord.py and dislash libraries, and so far i have written this code:

@slash.slash(
    name = "purge",
    description = "Purge a number of messages.",
    guild_ids = [792452919159947315, 878358390131286036]
)
async def purge(ctx:SlashContext):

but after this i have no idea as to how to continue.. i should add an option which stands for the number of messages to be purged i think, but i am not sure how to also because i don't know anything about option types and i haven't found info anywhere (probably just me incapable of searching)
either way, i'd be grateful if someone told me what option types are or where to find info about them, along with a continuation to my code please

maiden fable
slate swan
#

(the guildIDs are test servers so i didn't hide)

potent spear
maiden fable
slate swan
slate swan
potent spear
slate swan
#

yes yes but you can know what servers i'm in, just for that

slate swan
maiden fable
#

The only thing(s) u should hide is/are:
-> Bot Tokens
-> User Tokens
-> Weird Bot Object Names

slate swan
#

docs moment , brb

maiden fable
#

Yea

slate swan
maiden fable
#

Same as bot tokens, but for a user account

slate swan
slate swan
maiden fable
#

@slate swan please use a fork instead, like pycord or disnake

slate swan
#

you suggest that huh? because they're more common?

maiden fable
#

No

keen talon
maiden fable
#

Because they are updated with the latest API features

slate swan
#

they are a lot better than using a 3rd party'library

finite cobalt
#

discord.ext.commands.errors.MissingRequiredArgument: number is a required argument that is missing. How do i fix these kinds of errors

slate swan
#

i see, i will switch then thanks

#

you give that argument while using the command...

quick gust
#

you need to invoke the command with a number in the arguments aswell, do you not know your own code lmao

slate swan
finite cobalt
slate swan
#

uhmm

#

somewhere in your code there's a variable for that

#

a boolean one

rocky trench
#

could anyone here help me with creating warn system? I'm using postgresql, I dont know how to connect it to my file nor how to use it. I tried watching some tutorials but I just cant understand all the things they do

slate swan
#

you see this code? required = True

#

you should have it similar, set it to False (capital F is important)

rocky trench
potent spear
rocky trench
#

yes

potent spear
#

well, postgresql is server sided

#

so you probably have some server already?

rocky trench
#

yes

potent spear
#

use asyncpg

rocky trench
#

asyncpg yes

potent spear
#

it's an async wrapper of postgresql

slim ibex
#

asyncpg

rocky trench
#

can I connect to it without using a function?

potent spear
#

why would you not want a function?

slim ibex
#

ye

rocky trench
#

well I barely use 'self'

#

and I think u need it in there

potent spear
#

false

slim ibex
#

do you not use cogs

potent spear
#

do you know python basics?

rocky trench
slim ibex
#

and no you dont

slim ibex
rocky trench
devout iris
#

can i make a captcha solver and use it for discord bots?

potent spear
rocky trench
#

But I didnt do it the smart way, I'm a self learner and I learnt before I did something each time

potent spear
devout iris
rocky trench
potent spear
rocky trench
#
async def create_db_pool():
    db = await asyncpg.create_pool(database = "mydatabase", user = "myuser", password = "mypass")```
#

this would work right?

potent spear
potent spear
tardy lagoon
#

How to get a user's avatar by id

rocky trench
#

So I probably need to call the function now

potent spear
devout iris
potent spear
#

you need to learn how to solve captcha from a picture first THEN implement it in a bot

final iron
devout iris
#

yes

final iron
#

Lmao

rocky trench
#

what is 'data type' used for?

slim ibex
#

to set the type of the column

devout iris
slim ibex
#

such as int, string, etc\

final iron
#

Not sure if it's against tos but it is extremely inappropriate

slim ibex
#

you should know that if you knmow python basics @rocky trench

rocky trench
#

well, what if I want member.id, amount of warns, reason (list)

quick gust
# rocky trench

there are different datatypes, char, varchar, bigint, int. They each have different things they store

rocky trench
#

well i pretty much explained myself on that... I only learnt what I needed

quick gust
devout iris
potent spear
final iron
#

He's trying to bypass a captcha verification system

potent spear
devout iris
final iron
#

If it's not it's certainly inappropriate

keen talon
rocky trench
#

whats the difference between bigint and bigint[]

slim ibex
#

bigint[] is a list i believe

rocky trench
#

2nd is a list?

#

ah I see

devout iris
#

but there is captcha solvers as chrome extentions

keen talon
rocky trench
final iron
#

Just because people rob banks it doesn't mean it's okay for you to do it

rocky trench
#

I think these are right?

devout iris
#

thx for infos guys 👍

#

i wont

keen talon
rocky trench
#

second is also bigint*

potent spear
slim ibex
#

postgres

potent spear
rocky trench
tardy lagoon
#

How to send an Asset object?

potent spear
#

all I know is that
ID -> int
warns -> int
reasons -> list(str)
just convert that to whatever datatypes postgresql uses

slate swan
rocky trench
#

I see

potent spear
#

there's also a small flaw
if your warns is basically a count of reasons, then it's too much

slate swan
#

!d discord.Asset.url

unkempt canyonBOT
tardy lagoon
#

Ol

#

Does renaming or changing tag affect the user ID?

slate swan
#

no

#

if you mean the user tag

honest vessel
#

what decoration permission does this have?

slim ibex
#

not sure if its supported yet

#

oh wait

honest vessel
#

i use disnake

slim ibex
#

i cant spell

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

that

honest vessel
#

thanks bud

tardy lagoon
#

In any way?

final iron
slim ibex
#

a user id cant be changed

final iron
#

The id is impossible to change

honest vessel
#

discrimination is changeable

#

the numbers after nick#

slate swan
tardy lagoon
#

So that means if bot.get_user() returns a NoneType
The user has been deleted???????

slate swan
potent spear
potent spear
#

like, if the user isn't in any guilds the bot is in, it would return None too

tardy lagoon
#

Hmmmm

slate swan
#

Or if you provided a string

potent spear
#

mmh

finite cobalt
#

How can i mention the everyone role

cerulean quest
#

hi, im working on my bot and have given it many commands. how do i make it give you an input where u can fill in details?

potent spear
final iron
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**...
tardy lagoon
#

I do @ everyone without the space

potent spear
limpid thicket
#
@slash.slash(
  name="private",
  description="Manage a private voice.",
  guild_ids=[798251886951399487],
  options=[
    create_option(
      name="create",
      description="Create a private voice.",
      option_type=1,
      required=False
    ),
    create_option(
      name="remove",
      description="Remove a member.",
      option_type=1,
      required=False
    ),
    create_option(
      name="add",
      description="Add a member.",
      option_type=1,
      required=False,
      options=[
        create_option(
          name="member",
          description="Choose the member you want to add.",
          option_type=6,
          required=True
        )
      ]
    ),
    create_option(
      name="transfer",
      description="Transfer private voice leadership.",
      option_type=1,
      required=False
    ),
    create_option(
      name="list",
      description="List added members.",
      option_type=1,
      required=False
    )
  ]
)```
Can anyone help? I'm receiving back: ``create_option() got an unexpected keyword argument 'options'``. I'm using discord-slash-commands and want to add options which only apply to my subcommand.
potent spear
#

I guess you don't have an options kwarg in the create_option method

limpid thicket
#

How would nest into the sub command then?

slate swan
quaint scaffold
slate swan
slate swan
quaint scaffold
slate swan
#

lmao

#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

quaint scaffold
#

lol

#

Mod commands w/ media storage for attachments/urls

#

most useful for sure

quaint scaffold
#

hahah me too. I tend to prefer making small community bots

quaint scaffold
restive tide
#

Hello, I have been trying to do a function witha python bot, which gets the input of the discord user and takes a specifc character out of it, and sends it in the title of an embed

tardy lagoon
#

One question

restive tide
#

but it sends like <!324324443243> ths kinda thing

maiden fable
#

Bro, just make a ban command which is a message command

quaint scaffold
#

^

restive tide
#

okay ill show picture

maiden fable
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**...
tardy lagoon
maiden fable
unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
restive tide
maiden fable
#

I told u tho

quaint scaffold
#

You followed the freecodecamp tutorial, didn't you?

tardy lagoon
potent spear
maiden fable
unkempt canyonBOT
tardy lagoon
#

Man, I'm so confused

potent spear
maiden fable
#

And if this returns None, then

slate swan
maiden fable
#

!d discord.Client.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.get_user "discord.Client.get_user") instead.
quaint scaffold
tardy lagoon
maiden fable
#

No

#

It isn't in any mutual guilds

wary ice
maiden fable
#

!d disnake.Client.getch_user if u r using disnake

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.
tardy lagoon
#

Hmmmm

quaint scaffold
restive tide
#

okay

maiden fable
maiden fable
vale wing
# wary ice why ?

Have you put on the checkmark "Add Python to PATH" on python setup?

maiden fable
#

Once or twice is okay, but u sending it repeatedly is just cluttering the chat

wicked atlas
# tardy lagoon Man, I'm so confused

get_user() check the bot's user cache, which is stored in memory, for a user object. If a user object is not found in there, it returns None. fetch_user() makes an actual call to the Discord API, and will almost always return a user object unless they don't exist.

honest vessel
#

from datetime import datetime, timedelta
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'

vale wing
#

Weird

#

!e

from datetime import datetime, timedelta```
unkempt canyonBOT
#

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

[No output]
quick gust
#

Had that happen to me before, I'm guessing it's because of the package and the class name being similar

wicked atlas
wicked atlas
#

also, not really the right channel

honest vessel
#

ah it was not the import that was wrong

tardy lagoon
#

Fetch user gets id as arg?

quaint scaffold
#

No, your social security number

tardy lagoon
#

Ok lemme try that

honest vessel
#

i fixed it

#

i had datetime.timedelta in the code it should just been timedelta

maiden fable
#

Ah gotcha

potent spear
tardy lagoon
#

It returns a coroutine object
i don't how to work with

potent spear
#

await

quaint scaffold
#

You always need to await coroutines

honest vessel
#

making a timeout command, duration: Optional[Union[float, timedelta]] it works great with just give seconds but how i give like 2022-01-23 18:19:00

vale wing
#

Strftime or whatever

honest vessel
#

no like !timeout @vale wing 2022-01-23 18:19:00

#

that took it as i passed none to duration and that went as reason instead

vale wing
#

Calculate the ending time and strftime it

honest vessel
#
async def timeout(self, ctx, member: Member, duration: Optional[Union[float, timedelta]], *, reason="No reason was given.") -> None:
        """Timeout a member."""
        print("Timeout member.")
        await ctx.guild.timeout(member, duration=duration, reason=reason)```
vale wing
#

You want to convert the time?

slate swan
#

!d datetime.datetime.strptime

unkempt canyonBOT
#

classmethod datetime.strptime(date_string, format)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") corresponding to *date\_string*, parsed according to *format*.

This is equivalent to:

```py
datetime(*(time.strptime(date_string, format)[0:6]))
```  [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised if the date\_string and format can’t be parsed by [`time.strptime()`](https://docs.python.org/3/library/time.html#time.strptime "time.strptime") or if it returns a value which isn’t a time tuple. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
vale wing
#

Then there's this thing ^

wicked atlas
#

!pypi dateparser

unkempt canyonBOT
wicked atlas
#

theres also this

maiden fable
#

!pypi humanize also exists

unkempt canyonBOT
slate swan
#

it's a class , so .Guild

wicked atlas
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI.

x == y Checks if two guilds are equal.

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

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
slate swan
#

i'm gonna go read and rewrite the few commands that were there now

#

thanks for the suggestion

#

on_member_join not working, what could be the problem?

#

If you need a code, I'll send it

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.

slate swan
#

send the code sir yes

#

Simply enable the members intent and you're good to go.

#

hey could the problem have to do with the invite link?

#

i remember that unless specified when creating the invite link the bot couldn't do some things

#

and write intents in the main file or in cogs, the code is in cogs?

#

@slate swan

#

The message above says all

#

Okay

#

You need to give it when your instantiate the bot class.

#

So when you do

bot = ...
honest vessel
#

is there an event for when timeout is released/cancled

bold sable
#

how would i make a bot that tells me who just pinged me? 🤔

maiden fable
unkempt canyonBOT
maiden fable
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

maiden fable
#

There are a few ways to do so in on_message

tardy lagoon
#

Aaaaaaahhhhhhhhhh, I'm sooo stupid

maiden fable
#

.

tardy lagoon
#

Figured out the code and then closed the dm

maiden fable
#

Lol

kindred epoch
#

my bot just raised a missing access error for fetching a channel, i dont get it, anyone know why?

tardy lagoon
#

Does unknown user mean deleted

#

?

kindred epoch
tardy lagoon
kindred epoch
#

!d disnake.ext.commands.Bot.fetch_user

#

did it raise NotFound?

slate swan
kindred epoch
#

@tardy lagoon did it raise NotFound or HTTPException?

slate swan
kindred epoch
#

yea thats prob it

slate swan
#

it is ```py
raise NotFound(response, data)
disnake.errors.NotFound: 404 Not Found (error code: 10013): Unknown User

#

similar error , right mr nickname?

tardy lagoon
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/jishaku/features/python.py", line 145, in jsk_python
    async for send, result in AsyncSender(executor):
  File "/home/container/.local/lib/python3.10/site-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "/home/container/.local/lib/python3.10/site-packages/jishaku/repl/compilation.py", line 140, in traverse
    async for send, result in AsyncSender(func(*self.args)):
  File "/home/container/.local/lib/python3.10/site-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "<repl>", line 1, in _repl_coroutine
    await _ctx.send(await _bot.fetch_user(897147305042538506))
  File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 1384, in fetch_user
    data = await self.http.get_user(user_id)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 250, in request
    raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 10013): Unknown User 
#

Sooooo, deleted?

kindred epoch
#

ye, the user with that id does not exist

tardy lagoon
#

Aw man

#

Well, he's gone

limpid thicket
#

What's the best library to use for slash commands?

forest beacon
#

If I put my command description in a doc-string can I loop over the functions in a cog and create a custom help command?

maiden fable
#

hikari, pycord, nextcord and disnake are a few

maiden fable
final iron
maiden fable
#

!d discord.ext.commands.Command.help

#

!d discord.ext.commands.Command.short_doc does that @forest beacon

unkempt canyonBOT
#

property short_doc: str```
Gets the “short” documentation of a command.

By default, this is the [`brief`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.brief "discord.ext.commands.Command.brief") attribute. If that lookup leads to an empty string then the first line of the [`help`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command.help "discord.ext.commands.Command.help") attribute is used instead.
forest beacon
#

I wish the documentation had more examples.

maiden fable
#

Wym

forest beacon
#

It’s in the command section. Meaning the commands decorator right?

bold sable
#

very nice, got the steamapi working now

manic wing
#
@bot.command(
  short_doc="abc",
  description="abcabc",
  aliases=['a', 'b', 'c'],  
)```
native wedge
#

is pebblehost discord bot hosting any good?

#

+1gb of ram

forest beacon
#

I host using vultr for 2.50. Half a gig of ram and 10gb ssd with 1 vCore. The bot is in less than 15 servers so it’s good enough.

manic wing
#

!d discord

unkempt canyonBOT
#

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.

manic wing
unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

forest beacon
forest beacon
#

Actually 7. I forgot I went for the IPv4 and IPv6 so it’s 3.50 a piece.

native wedge
maiden fable
forest beacon
#

I have my bots listed on the bot website. Whatever it is lol. Should definitely be fine with the 2.50 plan. Maybe even a pi zero 2 lol.

slim ibex
#

Use vultr vps

maiden fable
native wedge
manic wing
unkempt canyonBOT
#

get_command(name)```
Get a [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command") from the internal list of commands.

This could also be used as a way to get aliases.

The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.
forest beacon
manic wing
#

shit bot @unkempt canyon

maiden fable
#
2 AMD based Compute VMs with 1/8 OCPU and 1 GB memory each

4 Arm-based Ampere A1 cores and 24 GB of memory usable as one VM or up to 4 VMs

2 Block Volumes Storage, 200 GB total

10 GB Object Storage – Standard

10 GB Object Storage – Infrequent Access

10 GB Archive Storage

Resource Manager: managed Terraform

5 OCI Bastions
#

A friend of mine just got one, a few days back

forest beacon
#

Thanks.

maiden fable
#

!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.
maiden fable
#

U using this?

forest beacon
# maiden fable U using this?

I currently don’t even have a help command. I disabled the default one and have been physically looking at my code to use the commands lol.

maiden fable
#

Ah haha

#

Just use the above class

manic wing
#

!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.
quaint epoch
#

how do i convert a disnake.Attachment object to a python file?

manic wing
quaint epoch
# manic wing `f = io.StringIO(await attachment.read())`

i got this error Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\shake\AppData\Local\Programs\Python\Python310\Lib\site-packages\disnake\client.py", line 515, in _run_event await coro(*args, **kwargs) File "C:\Users\shake\AppData\Local\Programs\Python\bot.py", line 390, in on_message saved_file = io.StringIO(await file.read()) TypeError: initial_value must be str or None, not bytes

#

btw the file variable is an attachment

slate swan
pliant gulch
unkempt canyonBOT
#

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

Converts the attachment into a [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") suitable for sending via [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send").

New in version 1.3.
manic wing
quaint epoch
manic wing
pliant gulch
#

not a real file

quaint epoch
manic wing
#

i think

#
file = open(io.StringIO(str(await attachment.read())))```
#

something like that

pliant gulch
unkempt canyonBOT
#

await save(fp, *, seek_begin=True, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Saves this attachment into a file-like object.
manic wing
pliant gulch
#

You can pass a filename or filepath to here

#

Then it creates a new file

manic wing
quaint epoch
#

been there done that

quaint epoch
#

idk why tho

pliant gulch
#

Your python program doesn't have permissions to save files ig

manic wing
#

it doesnt return a file-like object

pliant gulch
#

It saves into a file-like object

#

The return is irrelevant

manic wing
#

but opening it is an extra step

pliant gulch
quaint epoch
#

!d disnake.Attachment

unkempt canyonBOT
#

class disnake.Attachment```
Represents an attachment from Discord.

str(x) Returns the URL of the attachment.

x == y Checks if the attachment is equal to another attachment.

x != y Checks if the attachment is not equal to another attachment.

hash(x) Returns the hash of the attachment.

Changed in version 1.7: Attachment can now be casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") and is hashable.
quaint epoch
#

when you use os.remove('text_file.txt'), can you pass a file path?

quaint epoch
quaint epoch
slate swan
summer halo
#

Hello , [ !calce apr apy ] I want to do that but i can't

summer halo
slate swan
#

Gib context

modern fiber
#

why is everybody telling me to stop using discord.py bc its gonna be canncelled?

#

is like disnake okay or?

manic wing
modern fiber
#

Okay great I did and using it

manic wing
#

good

maiden fable
#

Is it just me or Ashley has changed pfp

summer halo
manic wing
#

whos ashely

maiden fable
#

👀

slate swan
#

Is there any way to timeout members with discord.py?

maiden fable
#

No

slate swan
manic wing
#

oh hey ashley....

slate swan
#

Alr, guess I gotta make muted role

slate swan
maiden fable
slate swan
maiden fable
#

Nah, imma pass that one ¯_(ツ)_/¯

slate swan
slate swan
sacred sigil
#
ctx.voice_client.stop()
#

NoneType error

maiden fable
#

It isn't connected

sacred sigil
#

AttributeError: 'NoneType' object has no attribute 'stop'

slate swan
#

Or it isnt playing anything

summer halo
maiden fable
#

!d discord.ext.commands.Context.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
sacred sigil
maiden fable
#

!d discord.VoiceProtocol

unkempt canyonBOT
#

class discord.VoiceProtocol(client, channel)```
A class that represents the Discord voice protocol.

This is an abstract class. The library provides a concrete implementation under [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient").

This class allows you to implement a protocol to allow for an external method of sending voice, such as [Lavalink](https://github.com/freyacodes/Lavalink) or a native library implementation.

These classes are passed to [`abc.Connectable.connect`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").
sacred sigil
#

but I wanna make sure it stops playing before it plays another

#

how do I check for that

maiden fable