#discord-bots

1 messages · Page 689 of 1

timber crescent
#

Does it give one exception and just quit or keep trying?

slate nymph
#

ur bot responds twice

timber crescent
#

I meant like two different scripts don't we get an error for that?

slate nymph
#

nope

sullen shoal
#

if not interactions, no

timber crescent
#

Oh-

sullen shoal
#

but i had issues with interactions, maybe there are work arounds to them but i dont see the point of doing it at all

slate nymph
#
class Cog2(commands.Cog):
    def __init__(self,bot):
        self.bot = bot
    @commands.Cog.listener()
    async def on_guild_join(self,guild:discord.Guild):
        for channels in guild.channels:
            global channel_list
            channel_list = await channels.create_webhook(name="Lemontree bot hook")

    @commands.command()
    async def sudo(self,ctx:commands.Context,member:discord.Member,*,message):
        hook = Union(channel_list)
        async with ClientSession() as session:
            await hook.send(content=message,avatar_url=member.display_avatar,username=member.display_name) ```
#

channel_list not defined?

sullen shoal
#

use the bot instance

#

for variables

#

like that

#

!botvar

unkempt canyonBOT
#

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

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

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

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

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

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

maiden fable
slate nymph
#

bot.channel_list?

maiden fable
#

Yea

slate nymph
#

ayt tysm

sullen shoal
#

you can also use the cog instance

maiden fable
#

Read the above tag about botvars

slate nymph
#

oh-

sullen shoal
#

also please setup black code formatter for your IDE

slate nymph
#

typing.Union

maiden fable
#

U can't use it like that

#

It's only for typehinting

slate nymph
#

oh-

sullen shoal
#

its just for typehints, it has no actual use

maiden fable
#

It will raise an error if u try making an instance

slate nymph
#

ic

#

what should be inplace of that?

sullen shoal
#

you can make your own function for that

maiden fable
#

If u explain your use case, I could help u better

frail mesa
#

Okay, I've swapped over everything to bot.commands instead of discord.client. Everything is working fine, except when I try to use the command it tells me I don't have the necessary role, even though I definitely do. Have triple checked the environment variables to make sure they're correct. Any clue what I could be doing wrong?

import os
from keep_alive import keep_alive
from discord.ext import commands

bot = commands.Bot(command_prefix='!')
token = os.environ['TOKEN']

@bot.command()
@commands.has_any_role('Admin', 'Server Owner')
async def scosa(ctx):
  await ctx.channel.send(os.getenv('VerifiedBMHour') + ' +9 in 30 minutes hosted by ' + os.getenv('scosa') + '!')
  await ctx.message.delete()

@scosa.error
async def info_error1(ctx, error):
  if isinstance(error, commands.errors.MissingAnyRole):
    await ctx.channel.send('You must be an Admin or higher to use this command.')
slate nymph
#

so i have made webhooks for all the channels in a server. I want it so if the author runs the command in a specific channel the webhook of that paticular channel only responds.

maiden fable
dapper cobalt
maiden fable
#

Names will work

#

!d discord.ext.commands.has_any_role

unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
frail mesa
#

oooh i see, i thought those were using my environment variables, brainfart

maiden fable
#

Hahaha

sullen shoal
slate nymph
maiden fable
slate nymph
#

so there is no other way?

unkempt canyonBOT
#

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

Gets the list of webhooks from this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
maiden fable
#

U'll have to fetch them

sullen shoal
#

there are but i would say to use a database

maiden fable
#

Facts

slate nymph
#

um

maiden fable
#

or just use discdb

slate nymph
#

will see, thanks!

#

i am tryna learn asqlite

sullen shoal
#

learn sqlite then just put await

maiden fable
#

Yea

sullen shoal
#

i like deta's new async sdk for python tho

#

works pretty well even if its in alpha stage

frail mesa
#

ty for the help, works great now 😄

sullen shoal
#

its like the replit database, easy and for basic use it works

sullen shoal
#

so i had to convert to int and str all the time for storing ids

severe field
#

how to make this buttons?

rugged marsh
sullen shoal
severe field
#

disnake?

sullen shoal
#

yeah

spark sentinel
#

can someone say me how this works (i will grab the description out of an embed)

#

!d discord.Embed.description

unkempt canyonBOT
maiden fable
#

embed.description = "Hi There!"

cerulean osprey
#

.

maiden fable
#

Any error?

cerulean osprey
#

Nope

maiden fable
#

Weird...

#

Can u post the message again? It's wayyy too up

cerulean osprey
#

The code?

maiden fable
#

The whole message with the code

cerulean osprey
#

So Im trying to make a simple thing that makes the bot greet you when you say "hello" and its name. As of right now.. I have this

if msgl.startswith('hello chimera') or msgl.startswith('hi chimera'):
        channel = message.channel
        await channel.send('Hello! What is your name?')
        print('Check 1')

        def check(m):
            return m.content == 'hello' and m.channel == channel
        print('Nice')
        msg = await client.wait_for('message', check=check)
        await channel.send(f'Hello {msg}!')
        print('Check 2')
 ```Naturally the prints are to see exactly where its going wrong. It printed both "Check 1" and "Nice" but not "Check 2".. what am I doing wrong?
#

I have an update tho

maiden fable
#

?

cerulean osprey
#

I got it to do this

#
    if msgl.startswith('hello chimera') or msgl.startswith('hi chimera'):
        channel = message.channel
        await channel.send('Hello! What is your name?')
        print('Check 1')

        def check(m):
            return m.channel == channel
        print('Nice')

        msg = await client.wait_for('message' , check=check)
        print('Check')
        await channel.send('Hello {.content}!'.format(msg))
        print('Check 2')
``` Code I used to do it
maiden fable
#

Yea thanks

#

So it's not sending the Hello message?

cerulean osprey
#

Oh wait is it activation itself?

#

*activating

maiden fable
#

Yea...

cerulean osprey
maiden fable
#

on_message triggers for the bot itself too, haha

cerulean osprey
#

So itll send it, but then not take any input

cerulean osprey
maiden fable
#

Weird...

#

Try adding that in the check too

slate swan
#

how i stop a command for 10s

maiden fable
#

and not message.author == client.user

maiden fable
#

!d discord.ext.commands.cooldown

slate swan
#

yes

unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
cerulean osprey
#
def check(m):
            return m.channel == channel and not message.author == client.user
``` Like that?
maiden fable
#

Yea

#

No wait

#

m.author*

cerulean osprey
#

:o Alright lemme try

#

IT WORKS

#

Bro ive been sitting here for 2-3 hours trying to figure this out 😭

maiden fable
#

🤣

slate swan
maiden fable
#

Cool

twin moon
#

'YTDLSource' is not defined

upbeat otter
#

anyways

#

!ytdl

unkempt canyonBOT
#

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

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

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

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

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

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

¯_(ツ)_/¯

maiden fable
tiny ibex
#

BRUH

upbeat otter
#

better option

maiden fable
tiny ibex
upbeat otter
tiny ibex
#

googleapis are shit anyways

upbeat otter
#

anyways, this doesnt belong here

tiny ibex
maiden fable
maiden fable
upbeat otter
tiny ibex
maiden fable
#

U can go on, scrape the website and use most of your resources ;D

tiny ibex
upbeat otter
tiny ibex
#

Uploader

maiden fable
#

That's API problem 🤷‍♂️

tiny ibex
#

Like count

upbeat otter
tiny ibex
maiden fable
#

The only legal way, afaik, is to use the API provided by Google and not scraping the website yourself

upbeat otter
tiny ibex
#

Well let's just stop

#

This is off topic

upbeat otter
#

....

maiden fable
#

¯_(ツ)_/¯

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

It's written in YouTube ToS itself

#

scrapers

upbeat otter
#

Stop now

tiny ibex
maiden fable
#

Just clarified my argument ¯_(ツ)_/¯

upbeat otter
tiny ibex
#

Many people use scrapers tho-

upbeat otter
maiden fable
upbeat otter
#

!ot

unkempt canyonBOT
tiny ibex
#
  @commands.command()
  async def recipe(self, ctx, *, food_name):
    food = food_name.replace(" ", "+")
    api_url = f"https://api.edamam.com/api/recipes/v2?type=public&q=" + food + "&app_id={app_id}&app_key={app_key}"
    async with aiohttp.ClientSession() as session:
        async with session.get(api_url) as resp:
            res = await resp.json()
    ing = res['hits'][0]['recipe']['ingredients']
    naam = res["hits"][0]["recipe"]["label"]
    url = res["hits"][0]["recipe"]["url"]
    image = res["hits"][0]["recipe"]["image"]
    inge = ""
    for ingredient in ing:
        inge += f"{ingredient['text']}\n-------\n"
    embed = disnake.Embed(title=naam, url=url, description=inge, color=bot_embed_color)
    embed.set_thumbnail(url=image)
    await ctx.reply(embed=embed)```
#

Can someone tell why this doesn't work

maiden fable
#

Error?

tiny ibex
#

The json says unauthorized request

quick gust
#

invalid key?

maiden fable
#

Imagine using f strings and concatenation

tiny ibex
quick gust
#

woah calm down

maiden fable
#

Remove the + food + and use placeholders and it will work

tiny ibex
#

It works when using the key directly

tiny ibex
maiden fable
#

Cz the url is taking the API key as app_key={app_key}

visual island
maiden fable
#

But why use concatenation with f strings 😐

upbeat otter
maiden fable
maiden fable
maiden fable
#

Imagine using GIFs instead of nitro emojis smh

tiny ibex
quick gust
#

mhm 100w8Copy

visual island
maiden fable
maiden fable
visual island
upbeat otter
quick gust
#

no use f strings

upbeat otter
#

lol

upbeat otter
quick gust
#
name = "smh"
age = 00
a = f"{name}'s, age is {age}"
maiden fable
#

Readability 0

visual island
#
message = "hi" 
a = name + "'s, age is {}.".format(age) + f"{message}!"
quick gust
visual island
#

there's another way with the % sign thing

maiden fable
#

Didn't I tell that only lmao

quick gust
#

U both sent it at almost the same time

maiden fable
#

Facts

visual island
#

maybe

#

!e

name = "icy"
age = 14
message = "hi" 
a = name + "'s, age is {}.".format(age) + f" {message}" + " %s, how are you?" % (name,) 
print(a) 
twin moon
unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

icy's, age is 14. hi icy, how are you?
tiny ibex
upbeat otter
twin moon
tiny ibex
unkempt canyonBOT
visual island
#

!pypi spotipy

unkempt canyonBOT
visual island
#

late 0.2 secs :(

tiny ibex
tiny ibex
#

Cuz spotify is highly encrypted

#

spotipy is just a wrapper around spotify api which can get you music details

maiden fable
twin moon
#

how can I stream

#

on spotipy

upbeat otter
upbeat otter
twin moon
#

can I stream spotify somehow?

upbeat otter
#

spotify's data is highly encrypted

twin moon
#

EHM

#

capslock

upbeat otter
#

I've a question

twin moon
tiny ibex
upbeat otter
#

i'm using the on_message_delete event, and I want to check the deleter of the message

tiny ibex
#

Buy the whole company

#

Then you can stream as you wish

upbeat otter
upbeat otter
twin moon
#

async def on_message_delete(message)

upbeat otter
tiny ibex
#

That's wrong

upbeat otter
tiny ibex
twin moon
# upbeat otter oof\
@commands.Cog.listener()
  async def on_message_delete(self,message):
    channel = nextcord.utils.get(message.guild.text_channels,name="reports")
    await channel.send(f"{message.author} deleted the message: {message.content}")``` in class
tiny ibex
upbeat otter
twin moon
#

well my code will search for a channel named reports

visual island
#

it's the author of the message

#

not deleter

tiny ibex
# upbeat otter huhhhh

Just check audit log for deleted message if it was recorded then just get the user who deleted the message if it wasn't recorded get message.author

twin moon
#

ohh

tiny ibex
twin moon
tiny ibex
upbeat otter
twin moon
#

how do I stream spotify music on discord

visual island
#

you can't stream it

upbeat otter
upbeat otter
#

Unreliable

visual island
#

"message deleted by bots doesn't get to audit log (most of the time)"
~ Umbra

slate swan
#

simple truth, there is no 100% reliable way to get who deleted the message

twin moon
#
@commands.command()
  async def meme(self,ctx,Subreddit="memes"):
    try:
      reddit.read_only=True
      post = reddit.subreddit(Subreddit).random()
      embed = nextcord.Embed(description=f"**[{post.title}]({reddit.config.reddit_url + post.permalink})**")
      embed.set_image(url=post.url)
      embed.set_footer(text=f"By {post.author}")
      await ctx.send(content=None, embed=embed)
    except:
      await ctx.send("Subreddit not found.")``` why does this send 2 images
slate swan
#

import dad 😔

shadow wraith
#

💀

verbal cairn
#

Why so many ppl make Reddit bots

maiden fable
#

🤷‍♂️

mild raft
#

@bot.event
async def on_member_join(member):
channel = bot.get_channel(channel_id)
await channel.send(f'{member} just joined')

i change a id channel to channel_id because I don't want to give it but in my code it is.
Problem: It don't sends a message in the channel

#

help

maiden fable
#

Any error?

mild raft
#

no

#

its just not sending messages in discord

slate swan
#

is on_member_join triggered

maiden fable
#

!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.

maiden fable
#

U need members intent

mild raft
#

i invites a probot and it don't send the message @slate swan

mild raft
maiden fable
#

Read the embed

mild raft
#

ok

slate swan
#

AttributeError: 'Member' object has no attribute 'message'

@bot.event
async def on_reaction_add(user, reaction):
    if reaction.message.author.bot:
      if reaction.emoji == ':white_check_mark:':
        return
    if reaction.message.author.user:
      if reaction.emoji == ':white_check_mark:':
        await user.send("hello")
```?
maiden fable
#

ah

#

It should be reaction, user

#

Rn, user is the Reaction object and reaction is the member object

#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
maiden fable
#

See

mild raft
maiden fable
#

!intent read this embed

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.

mild raft
#

can you send me a code to make it works?

#

@maiden fable

#

i'm from poland and i don't know English

maiden fable
#

The embed has the code

mild raft
#

i know only basics

maiden fable
#

Well the embed gave u the code above

mild raft
#

i dont know how this works!

maiden fable
#

!d intents

unkempt canyonBOT
#
maiden fable
#

This can also help u

#

It's the docs page for intents

cedar stream
#

They said they dont know english

maiden fable
#

Well I don't know any other language except English. They can translate the page, that's why gave the docs link

cedar stream
#

Idk how ur supposed to code w/o knowing English

mild raft
#

i've got in my school lessons

#

@cedar stream

cedar stream
mild raft
#

I found on the internet solution but its not work

mild raft
cedar stream
mild raft
#

but im coding bot from the tutorials

cedar stream
#

Which tutorials

#

Is it from lucas?

mild raft
#

yes

#

but few is from other youtubers

cedar stream
#

He doesnt rly have the best tutorials

#

Try just using dpy docs

#

They are rly nice and easy to understand

mild raft
#

ok thanks for help

upbeat otter
quick gust
#

the rewrite ones are ~1 year old but still they aren't really great

boreal ravine
upbeat otter
boreal ravine
#

they aren't though?

upbeat otter
#

Docs save time always

#

Nvm, im out

quick gust
tiny ibex
quick gust
#

and vcokltfree's article thingy

tiny ibex
#

Yup

boreal ravine
#

where did you learn python from

tiny ibex
boreal ravine
#

@upbeat otter

upbeat otter
#

And an hour tutorial which i discontinued

boreal ravine
obsidian ledge
#

how do i add multiple buttons onto a message?

tiny ibex
#

I learnt python from my friend

boreal ravine
upbeat otter
boreal ravine
upbeat otter
obsidian ledge
quick gust
#

ysah

#

yeah*

obsidian ledge
#

it didnt work for me

boreal ravine
obsidian ledge
#

only one button came up

boreal ravine
#

it overwrites the old buttons/functions

obsidian ledge
#

oh

#

can u give me a code example, i tried what u said and it still didnt work

tiny ibex
upbeat otter
slate swan
#
intents = discord.Intents.all()
intents.members = True

How to use this if my bot don't have privilege intent

#

And i want to use only member intent

upbeat otter
slate swan
upbeat otter
slate swan
#

!d discord.Guild.create_custom_emoji

unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

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

It takes a image keyword, which must be a byte type object

#

I dont know whats to write while applying

obsidian ledge
upbeat otter
#

Use io.BytesIO

boreal ravine
slate swan
slate swan
#

Uf

upbeat otter
#

!pypi io

unkempt canyonBOT
boreal ravine
#

create a discord.File object

#

!d discord.File <=

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
slate swan
boreal ravine
#

gj

slate swan
#

What is it doing in your cor then.

#

Code*

upbeat otter
slate swan
slate swan
slate swan
upbeat otter
#

.......

#

Best of luck bhaiya @slate swan

slate swan
#
intents = discord.Intents.default()
intents.members=True```
Enjoy
slate swan
upbeat otter
#

My god

slate swan
slate swan
#

!d await bot.wait_for_reaction

unkempt canyonBOT
slate swan
#

To kaise hai aap logyert

slate swan
#

how do I make the bot wait for a reaction?

upbeat otter
#

Okay so, First use PIL and use the open method, read the output, convert it to Bytes using io.BytesIO

slate swan
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**...
slate swan
upbeat otter
#

.........fine, bye

slate swan
#

Well,. There are always multiple ways to do something....
Using PIL for doing is better since that's what pillow is meant for

upbeat otter
#

I-

barren oxide
#

HI

unkempt canyonBOT
slate swan
#

Stunning , you can use pastebin to show the code

slate swan
#

Byy going to apply

slate swan
#

I don't want to be the person but

#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

slate swan
#

Ufff

upbeat otter
#

@slate swan I can provide you with the code

slate swan
#

Like it not banning me while i am creating channel or deleting

upbeat otter
#

But I wont

slate swan
#

discord.ext.commands.errors.MissingRequiredArgument: user is a required argument that is missing. ?

async def emb(ctx, *, user):
upbeat otter
#
from PIL import Image
from io import BytesIO

Welcome

#

,-, Ok then help yourself

#

I'll simply ignore you if you keep doing that

slate swan
#

Eevee literally told you what to do

upbeat otter
#

But I am invisible so uhhh

slate swan
#

@slate swan hows your issue related to discord bots ?

maiden fable
#

@slate swan what u wanna do

upbeat otter
#

Eh?

#

File path

slate swan
#

if its on the discord bot it doesn’t mean its related to discord-bots and check os to define your file path, its really basic stuff i think you should learn some python

upbeat otter
#

10 minutes*

maiden fable
#

!d discord.Emoji.url_as

unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

slate swan
maiden fable
#

istg sometimes Python sucks

slate swan
#

if your here to get spoon fed this isnt the place PES2_WarDuck

maiden fable
#

!d discord.Asset.save then this

unkempt canyonBOT
#

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

Saves this asset into a file-like object.
slate swan
#

They want to upload an image ( for emoji ) from their device

slate swan
tiny ibex
#

Hmm

maiden fable
#

!d discord.Guild.create_custom_emoji then

unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

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

So did you get it to work with is?

#

*os

maiden fable
#

😐

#

What's gonna be the image

#

Okay thanks for ignoring my previous message, appreciate it

slate swan
maiden fable
slate swan
#

My man literally ignoring everyone

maiden fable
#

And yea, Eevee told the correct way

maiden fable
slate swan
maiden fable
#

Then u can't do anything else afaik

#

It's literally the easiest way dude

slate swan
#
  1. It's io.BytesIO
  2. That's the only way around
#

other than using Some lib

maiden fable
slate swan
#

Lmao

obsidian ledge
#

how do i make another button after someone clicks a button

lament mesa
#

Edit the message

obsidian ledge
#

no, like a new button in a new message

lament mesa
#

Send a new message with a button

obsidian ledge
#

i did try that but this error came up

maiden fable
#

Code

#

U r using an instance method on the class itself

#

Well we can surely help u if u r willing to cooperate and not ignore us (;

obsidian ledge
maiden fable
#

If you dk about io.BytesIO, then learn about it. We are willing to help u but u keep on ignoring us, sooo, uhhh idk what to do 🤷‍♂️

lament mesa
#

Io.BytesIO is a file like object

slate swan
#

is there someway I can get the permissions required to run a command?

maiden fable
#

Idts, nope

tiny ibex
slate swan
#

I asked in discord.py server it was a straight "No"

shadow wraith
#

then make an add role command

maiden fable
shadow wraith
obsidian ledge
# maiden fable Code
class Section1(View):

    @discord.ui.button(label="VIP #1", style=discord.ButtonStyle.red)
    async def section1outof1(self, button, interaction):
        await interaction.response.send_message("` #1  ")

class Sections(View):

    @discord.ui.button(label="Section #1", style=discord.ButtonStyle.green)
    async def button_callback1(self, button, interaction):
        await interaction.response.send_message("` SECTION #1`", view=view)                                 
maiden fable
slate swan
#

I didn't mean to get the perms on discord

shadow wraith
snow flare
#

if I stop the view, will it delete the message that it was sent with?

heavy folio
maiden fable
slate swan
#

discord.ext.commands.has_permissions , I supplied the perms in the decorator
Now I have the Command object
How do I know what perms did I mention there

tiny ibex
snow flare
#

Is there any way that I would be able to delete the message that the view is attached to, using button callbacks?

maiden fable
heavy folio
obsidian ledge
# maiden fable In which line

like there was an embed, then the embed had 5 buttons, if you clicked a button for example button 1, section 1 would come up and there would be 4 more buttons to chose from

lament mesa
maiden fable
#

!d discord.ext.commands.Command.checks

unkempt canyonBOT
tiny ibex
slate swan
#

Ah I see

heavy folio
#

my favourite: ?tag tutorials

maiden fable
slate swan
#

Thanks I'll look into it

tiny ibex
slate swan
#
    if str(reaction.emoji) == emoji_yes:
        msg_s = await channel.send(embed=emb2)
        await msg_s.add_reaction(emoji_1)
        await msg_s.add_reaction(emoji_2)
        await msg_s.add_reaction(emoji_3)
        await msg_s.add_reaction(emoji_4)

        if str(reaction.emoji) == emoji_1:
            await msg_s.edit("hi")

how do I edit emb2?

heavy folio
#

make your changes then

#

god

#

just await message.edit(**kwargs)

maiden fable
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
heavy folio
#

python bot is pain

maiden fable
#

Haha true tho

heavy folio
#

in r danny theres fuzzy so

maiden fable
#

Hola

serene lynx
#

Excuse me, I want to ask, why is this false but it keeps raising?

#

wait i send my code

heavy folio
#

and error

maiden fable
#

Sure

serene lynx
# serene lynx Excuse me, I want to ask, why is this false but it keeps raising?
@commands.command()
async def sell(self, ctx, item: str, amount):
        if akun := await self.get_account(ctx.author.id):
            print(akun[item])
            try:
                item = akun[item]
            except KeyError:
                raise ItemNotFound
            try:
                amount = int(amount)
            except:
                pass
            if isinstance(amount, int):
                print(amount < akun[item])
                if akun[item] < amount:
                    raise ExcessAmount
                elif amount == 0:
                    raise NotZero
                elif amount < 0:
                    raise SmallerZero
                else:
                    barang = {}
                    for i in Economy.mainshop:
                        name = i["name"]
                        price = i["price"]
                        barang[name] = price
                    for nama, harga in barang.items():
                        if item == nama:
                            harga_total = harga * amount
                            if harga_total > akun["wallet"]:
                                raise YourMoneyIsNotEnough
                            else:
                                await self.update_wallet(
                                    ctx.author.id, akun["wallet"] + harga_total
                                )
                                await self.update_item(
                                    ctx.author.id, item, akun[item] - amount
                                )
                                await ctx.send(
                                    f"{ctx.author.mention} you bought {amount} {item} for {harga_total}$"
                                )
                                return
        else:
            raise AuthorNotHaveAccount```
heavy folio
#

!tag 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.

maiden fable
#

No

serene lynx
#
1
False
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "d:\dittttbotbeta\.env\lib\site-packages\discord\client.py", line 359, in _run_event
    await coro(*args, **kwargs)
  File "d:\dittttbotbeta\error\error.py", line 83, in on_command_error
    raise error
  File "d:\dittttbotbeta\.env\lib\site-packages\discord\ext\commands\bot.py", line 970, in invoke
    await ctx.command.invoke(ctx)
  File "d:\dittttbotbeta\.env\lib\site-packages\discord\ext\commands\core.py", line 904, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "d:\dittttbotbeta\.env\lib\site-packages\discord\ext\commands\core.py", line 88, in wrapped
    ret = await coro(*args, **kwargs)
  File "d:\dittttbotbeta\data\economy.py", line 191, in sell
    raise ExcessAmount
data.economy.ExcessAmount```
heavy folio
#

goodness the indents are wrird on mobile

maiden fable
#

Ik

#

Yeaaa

serene lynx
heavy folio
#

yes

#

discord\ext\commands

#

excuse me wtf

#

stop recommending forks

#

no. just no.

#

and?

#

so what

maiden fable
#

Me. Anything else?

heavy folio
#

me too

#

im not sarthak, neither is hunter

maiden fable
#

Everyone has preferences, no need to tell anyone else what u use, as long as they don't ask it

heavy folio
#

stop recommending forks

snow flare
#

How can I make a private command?

heavy folio
#

????

maiden fable
#

Okay okay we are just saying no to go OT or smth

heavy folio
#

@snow flare make your own check or use the default checks

#

bruh private dossnt mean administrator perms

maiden fable
#

!d discord.ext.commands.guild_only exists

unkempt canyonBOT
#

@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.

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

would I place that after the bot.command() decorator?

heavy folio
#

yes

#

iirc before is fine as well? idrk bout this but after the decorater works

snow flare
#

ok, thanks

#

yeah, I can see that it says administrator=True

unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

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

#bot-commands

#

#bot-commands

slate swan
#

yea , but random

heavy folio
#

#bot-commands

#

channel description says "For questions and discussions"

slate swan
#

pithink you hab no idea what the bot is saying tho

#

gg ( no gg after edit)

heavy folio
#

read the docs when

#

no

tiny ibex
#

You guys stuck with the same problem for an hour

heavy folio
#

dont know how to use it, dont want to read the docs

tiny ibex
#

If you dk how to use it now is the time learn how to use it

heavy folio
#

by asking people to spoonfeed yes

tiny ibex
#

Docs

lunar quail
tiny ibex
#

That's spoonfeeding

snow flare
#

How can I delete or edit the message that a view is connected to, through button interactions?

velvet tinsel
#

? Which module are you using?

snow flare
#

pycord

#

I'm doing it through classes

velvet tinsel
#

Oh

#

Well idk then

#

Sorry

snow flare
#

because it would work perfectly fine if I was able to pass the message into the view, but the actual message is supposed to be sent after the view is made, because then I wouldn't be able to add the view to the message lol

slate swan
#

hello

velvet tinsel
#

Greetings

slate swan
#

how do I create such a rule, If the reaction was not pressed by the author == return

#

in on_reaction_add

#

on_reaction_add gives you a user object too , you can compare it to any discord.User / discord.Member object

maiden fable
snow flare
#

is there anyway that I can grab the message that a view is attached to from the view class?

slate swan
#

now since you want to use it with author , using wait_for is the only choice for you :) cause you wont get your author in the on_reaction_add

obsidian ledge
#

how do i use 2 views?

#

for example, if i used a view on a embed, then i wanted to use another view on another embed, how do i do that?

maiden fable
#

show yr imports

#

wait nvm

#

os.path u don't change it yourself

obsidian ledge
maiden fable
#

what u even tryna do

#

Better

upbeat otter
#

guys....what was the method for uploading an emoji again

obsidian ledge
upbeat otter
#

discordpy

unkempt canyonBOT
#
Not likely.

No documentation found for the requested symbol.

upbeat otter
#

....

#

like this ^^

maiden fable
unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

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

ah thenku

maiden fable
#

!d discord.Emoji.url

upbeat otter
maiden fable
slate swan
upbeat otter
#

....

quick gust
#

that's not what they are asking sir

upbeat otter
#

I want to upload an emoji not get the emoji's address

#

thanku hunter

maiden fable
#

👍

maiden fable
upbeat otter
#

lol

#

good morning btw

maiden fable
#

:stare: I have to complete some stuff today, let's hope I won't be asleep till 2 tonight haha

maiden fable
maiden fable
#

as long as u don't post that cat gif repeatedly

quick gust
#

!OT

maiden fable
#

Ik u were gonna say that ngl

quick gust
snow flare
#

Is there a way to add custom id's to messages?

maiden fable
#

No

#

u can do those yourself for your code locally, but u cannot change IDs on discord

snow flare
raw latch
#

What discord.py fork do you recommend between pycord and nextcord? Which one si the most stable and the best alternative to discord.py?

maiden fable
#

ah I thought u wanted to change IDs on discord, sorry

maiden fable
raw latch
#

Hikari?

maiden fable
#

disnake

snow flare
raw latch
craggy cloak
#

is there something that you can import discord.py? like import discord.py?

quick gust
#

just import discord

craggy cloak
#

ok thx i have one more question

slate swan
#

even though the bot is online and working fine i am still gettting dis error in console
raise NotFound(r, data)
discord.errors.NotFound: 404 Not Found (error code: 0): 404: Not Found

craggy cloak
#

how can i update to the latest version? I don't understand

honest vessel
#

it sais in ur pic

maiden fable
honest vessel
#

python3 -m pip install --upgrade pip

craggy cloak
#

O_O

unkempt canyonBOT
#

Hey @slate swan!

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

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

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

https://paste.pythondiscord.com

upbeat otter
#

guys while uploading it says, unsupported image provided ,-, what do I do?

maiden fable
#

requests goes brrrr

upbeat otter
maiden fable
#

Why u overwriting the image file tho

upbeat otter
maiden fable
#

.png

upbeat otter
upbeat otter
maiden fable
#

u r writing to the image file

#

u r editing the image file's binary data with the response content?

upbeat otter
honest vessel
#

but isnt prob he needs to use discord.file to prep it?

maiden fable
#

Why?

upbeat otter
maiden fable
#

You shouldn't do that

honest vessel
#

oh ok

upbeat otter
maiden fable
#

Or could be that can work 🤨

valid barn
#

how do i do the help command so that, it automatically gets, all the command names and description and fills it in the embed desc
(that it'll get the command name and desc from here:)

@client.command(name="acommandname"...blablabla)
maiden fable
#

Try passing in a discord.File object there

upbeat otter
#

there

#

clarified

maiden fable
#

in the file arg smh

sinful pasture
#

So why does this not work

if message.content.startswith(!remove5):
 count = count - 5

Doesnt work with -= either or am I being stupid

honest vessel
maiden fable
#

Yea ik

upbeat otter
maiden fable
#

in the create_custom_emoji's file arg smh

#

or it was image I forgot

#

!d discord.Guild.create_custom_emoji

unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
upbeat otter
#
@client.command()
async def emoji(ctx, url: str, emoji_name: str=None, *,upload_reason="No Reason Provided"):
    try:
        response = requests.get(url)
        with open(f"{random_name}.png", "wb") as f:
            f.write(response.content)

        im = Image.open(f"{random_name}.png")
        data = im.tobytes()
        await ctx.guild.create_custom_emoji(name=emoji_name, image=data, reason=upload_reason)
  

this is my current func

valid barn
maiden fable
#

try passing in a discord.File object to the file arg

sinful pasture
maiden fable
maiden fable
sinful pasture
upbeat otter
boreal ravine
#

everytime a button is clicked, does it the call the class (where the button was from)?

maiden fable
boreal ravine
#

thanks

maiden fable
#

not the whole class, but some methods

upbeat otter
#

indeed

slate swan
boreal ravine
#

how do we get the buttons of a certain class

maiden fable
#

@upbeat otter just use io.BytesIO. Don't do all the other things

boreal ravine
#

self.children isnt working and I thought it would

maiden fable
unkempt canyonBOT
#
Out of the question.

No documentation found for the requested symbol.

maiden fable
#

Oh hmm

#

!d discord.ui.View.children

unkempt canyonBOT
maiden fable
#

it works tho

upbeat otter
maiden fable
boreal ravine
upbeat otter
valid barn
maiden fable
#

u can just do

with open(file, "rb") as f:
    await ctx.guild.create_custom_emoji(name=..., file=f)

This should work

quick gust
boreal ravine
#

hm

maiden fable
upbeat otter
vague grove
#

so I tried creating a channel in a category with ints and strings but nothings working? how can i do it?

this is my current code:

        await guild.create_voice_channel('test',category=886768521768489040)

maiden fable
#

:stare: Why did I even write all that then

boreal ravine
maiden fable
boreal ravine
maiden fable
#

did u call super().__init__(...)?

boreal ravine
#

ye

maiden fable
#

Interesting

boreal ravine
#

should I send code?

maiden fable
#

yea

boreal ravine
#
b = 1
class v(disnake.ui.View):
  def __init__(self):
    self.edit()
    super().__init__()

  @disnake.ui.button(label=b)
  async def c(self, bu, i):
    await i.response.defer()
    b += 1
    self.edit()

  def edit(self):
    self.children[0].label = b

await ctx.send("0", view=v())
maiden fable
#

Ah u should call it at the top

#

the super line

#

u r accessing self.children before dpy made that variable

boreal ravine
#

hm

boreal ravine
maiden fable
#

before the edit method, yes

boreal ravine
#

o ok brb

#

im getting a namerror even though its defined

maiden fable
#

show

boreal ravine
#
b = 1
class v(disnake.ui.View):
  def __init__(self):
    super().__init__()
    self.edit()
 
  async def on_error(self,error,item, i):
    await i.response.send_message(error)

  @disnake.ui.button(label=b)
  async def c(self, bu, i):
  #  await i.response.defer()
    global b
    b += 1
    self.edit()

  def edit(self):
   # global b
    self.children[0].label = b

await ctx.send("0", view=v())
maiden fable
#

???

#

imagine using globals in a class pithink

boreal ravine
#

i didnt wanna use it inside the class

#

and idk how to access an attr inside the class without using self since i wanna use it inside label

maiden fable
#

well why not just use b instead of global? It should work since the scope is the main one

slate swan
boreal ravine
maiden fable
#

yea

#

the root scope ig

slate swan
#

ah

boreal ravine
maiden fable
#

u can do self.b = b and just take b as an init param

boreal ravine
snow flare
#

How can I delete an interaction message?

#

if I have the interaction message object

faint monolith
#

My bot doesn't sends welcome to new member. I put it after my commands. And it doesn't work

#

What should I do?

honest vessel
#

await message.delete()

snow flare
snow flare
faint monolith
untold token
boreal ravine
#

hey acey

snow flare
# untold token Code?
async def close_button_callback(interaction):
            button1 = Button(label="Cancel")
            view = View()
            view.add_item(button1)
            close_message = await interaction.response.send_message("Are you sure that you want to close the ticket?", view=view)
            async def button1_callback(interaction):
                await close_message.delete()

I have deleted all the unnecessary stuff, but this is what it looks like ^^

boreal ravine
#

〰️

main cedar
boreal ravine
#

!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.

snow flare
#

how can I delete the close_message interaction message?

potent fog
#

Am I not allowed to use the !close command?

boreal ravine
#

!close

#

wut command

potent fog
#

In a help channel

boreal ravine
#

i think you need to own the channel first

potent fog
#

Oh so only the person who asked the question can close it?

valid barn
#

why does it do this? code:

  serverid = ctx.guild.id
  try:
    serverrid = str(serverid)
  except:
    await ctx.send("Make sure **server id** is a number!")
  with open("info.json","r") as f:
    servers = json.load(f)
  if serverid in servers:
    return False
  else:
    servers[serverrid]["chanid"] = 0
    print("yeassss")```
error:
sullen shoal
#

is it alright to use wait_for in on_message listener with a very specific predicate that will only be true some time

boreal ravine
slate swan
#

yes

#

so what you would want to do first

#

is servers[serverid] = {} i think

#

then update the json file

cinder horizon
#
async def on_voice_state_update(self, before, after):
        member = self.bot
        if before.voice.channel is not None and after.voice.channel is None:
            vc: wavelink.Player = before.guild.voice_client
            await vc.disconnect(force = True)
        if voice_state is not None and len(voice_state.channel.members) == 1: # If bot is alone
            await vc.pause()
```is this ryt or wrong?
#

more or less will this work ever?

boreal ravine
#

try it and see

cinder horizon
#
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Wavelink_Music' raised an error: TypeError: Music.on_voice_state_update() missing 2 required positional arguments: 'before' and 'after'

boreal ravine
#

weird, you already put 2 arguments

snow flare
#

to delete a channel would I just do: some_channel.delete()?

cinder horizon
heavy folio
#

hmm

valid barn
#

do i use await with asyncio.sleep()?

heavy folio
heavy folio
valid barn
valid barn
cinder horizon
faint monolith
heavy folio
#

ur in a cog am i right

faint monolith
#

I don't get any error for that

heavy folio
#

self.bot

#

send code @faint monolith

faint monolith
heavy folio
#

yeah then before after

junior terrace
#

hey, im using this to find the number of textual channel in my server py CanaliT = (len(ctx.guild.text_channels)) but how do i exactly see the number of textual channels in a determined category only?

#

is it possible?

maiden fable
#

!d discord.CategoryChannel.channels

unkempt canyonBOT
#

property channels: List[GuildChannelType]```
Returns the channels that are under this category.

These are sorted by the official Discord UI, which places voice channels below the text channels.
junior terrace
#

thx

cinder horizon
faint monolith
heavy folio
#

wrong argument passed

#

ugh brb

faint monolith
#

Ahem

maiden fable
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
maiden fable
heavy folio
#

oo ty

#

i hate this bot

faint monolith
#

???

faint monolith
#

What should I do now?

maiden fable
#

!d discord.on_voice_state_update

unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
maiden fable
#

It takes in 3 args

cinder horizon
#

cog...

maiden fable
#

self, member, before, after

cinder horizon
maiden fable
#

That's how it should be

heavy folio
faint monolith
#

That's what i typed dude...

faint monolith
slate swan
heavy folio
#

?

untold token
cinder horizon
#

bot.event doesnt have ()

faint monolith
heavy folio
#

no.

#

literally wrong argument passed

cinder horizon
#
bot.event
async def blublublub```
heavy folio
#

!d discord.on_member_join

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
slate swan
#

yeah you have to pass in a member

heavy folio
#

tskes member as an arg not ctx

slate swan
#

not ctx

honest vessel
#

ctx should be member, n member object has no send need to grab n spec a channel to send to

heavy folio
#

yeah

slate swan
heavy folio
#

NO PARANTHESIS

#

and ctx isnt defined

slate swan
#

theres no () in bot.event

honest vessel
#

oh really @slate swan does it dm?

slate swan
#

yes

faint monolith
#

@slate swan hmmmm

cinder horizon
slate swan
#

yesh

#

would this work ```py
if file.read() in message.guild.channels():


can't test before I'm sure it works cuz otherwise it will remove all my channel files
slate swan
#

file.read contains a channel id

slate swan
#

question is does message.guild.channles output list of channel ids?

slate swan
sinful pasture
#
@client.event
async def on_message(message):
  count = 100
  if message.content.startswith('!remove5'):
    count = count - 5 
    print(count)

how can i make it so the new value is saved every time and so,
!remove5 output is 95
!remove5 output is 90

slate swan
heavy folio
#

lemme try out smt and get back

sinful pasture
slate swan
#

;-;

sinful pasture
#

;-;

slate swan
sinful pasture
#

ah

slate swan
#

always when you need to update it, make it change the value inside the file, when you need to use it then just use file.read()

#

variables = overrated

valid barn
#

how to get a user from their id?

slate swan
#

bot.get_user(id_here)

#

or client

valid barn
#

k ty

slate swan
#

or discord.Member

faint monolith
faint monolith
slate swan
#

/ commands trash

faint monolith
#

For my bot

slate swan
#

inline=True

#

in await

#

probably cuz that works in embeds so probably in slash commands too lol

heavy folio
#

inline mode?

faint monolith
sullen shoal
#

wtf is inline mode

heavy folio
#

theres no inline mode

#

theres no inline kwarg or some

faint monolith
heavy folio
sullen shoal
#

slash commands

faint monolith
#

I want it. Where should I make that boolean True?

heavy folio
#

what do you want

#

idk what ur trying to do

faint monolith
heavy folio
#

wtf is inline mode

sullen shoal
#

you have to use forks like disnake for slash commands

heavy folio
#

what is inline mode even...

sullen shoal
#

!pip disnake

unkempt canyonBOT
slate swan
#

inline = value would be next to the command

heavy folio
#

inline for embed field?

sullen shoal
#

it has examples for slash commands in the repo/examples folder

heavy folio
#

idk how "inline mode" is related to slash commands

maiden fable
heavy folio
#

nah not that

heavy folio
faint monolith
#

...

#

I searched a lot in Google for that

valid barn
#

what check do i use if i want only the bot owner to use the command?

heavy folio
#

idk what ur trying to do

faint monolith
heavy folio
unkempt canyonBOT
#

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

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

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

As you know, any bot has its own commands

heavy folio
#

you wanna make slash commands?

faint monolith
valid barn
faint monolith
#

I already created them

heavy folio
#

and? what u trying to do now

faint monolith
sullen shoal
tawdry perch
boreal ravine
sullen shoal
#

its not JavaScript tho

boreal ravine
#

even though defined

sullen shoal
#

show the tracebrack

tawdry perch
#

undefined what? the b

boreal ravine