#discord-bots

1 messages ยท Page 148 of 1

vocal snow
#

where you originally getting warn_id from

#

im asking where you're getting that warn id from

#

it would be helpful if you sent the code

#

the full code for the View or whatever it is

trim shadow
#
# Why i cannot connect to channel ? pls help, write in class extends discord cog
@commands.command(name="join")
async def join(self, ctx):
 channel = ctx.author.voice.channel
 voice = get(self.client.voice_clients, guild=ctx.guild)

 if voice and voice.is_connected():
    await voice.move_to(channel)
 else:
    voice = await channel.connect()
naive briar
#

What's the problem exactly

timid spade
#

Thanksss

vocal snow
#

voice = get(self.client.voice_clients, guild=ctx.guild) -> ctx.voice_client btw

#

and you should also check if channel is None or not

trim shadow
vocal snow
#

yes

#

actually I think ctx.author.voice can also be None

trim shadow
#

this full function

    @commands.command()
    async def p(self, ctx: commands.Context):
        if ctx.author.voice is None:
            await ctx.send("You are not connected to a voice channel")
            return
        
        channel = ctx.author.voice.channel
        if channel is None:
            await ctx.send("You are not connected to a voice channel")
            return
        voice = await channel.connect()

        # 
        voice.play(discord.FFmpegPCMAudio(executable="/asset/ffmpeg/ffmpeg.exe", source="/song.mp3"), after=lambda e: print('done', e))
        voice.source.volume = 1
vocal snow
#

and you're not getting any errors? Do you have an error handler?

vocal snow
#

can you set up logging and see?

trim shadow
#

no, but ```py
voice = await channel.connect()
print(f"voice: {voice}")

#

no have voice

trim shadow
vocal snow
#

yes

trim shadow
#

oh, that work ๐Ÿ˜…

slate swan
#

bruv

#

Give pic of the command where u used this class

#

warn_id is required

#

view=EditWarn(warn_id) u have to call this

#

Does anyone know what he is talking about?

#

He said "just normal ftp and ssh"

glad cradle
#

to do what

slate swan
#

make bot's requests faster

#

We have the same bot my bot take 10s for a request and his take only 0.6s

glad cradle
#

btw why you would want to make requests faster, if you're doing everything right you shouldn't take 10s

slate swan
#

because its slow and I want to do multiple requests

trim shadow
#
def after_song(err):
    try :
        if len(queue) > 0:
            next_song = url_queue.pop(0)
            queue.pop(0)
            song_manager = Song()
            _video_title = song_manager.do_both(next_song)  #downloads song and returns video_title
            voice.play(discord.FFmpegPCMAudio("song.mp3"), after=after_song)
        else :
            url_queue.pop(0)
            queue.pop(0)
            return
    except IndexError :
        pass

voice.play(discord.FFmpegPCMAudio("song.mp3"), after=after_song)
#

should i use after to call the next song??

#

Is this good for my program?

#

and, ... one bot can run multi voice channel ?

#

hi, hello

austere solstice
trim shadow
slate swan
#
import discord
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.message_content = True
#prefix for commands


rijalbot = commands.Bot(command_prefix='!',intents=intents,activity=discord.Game(name="!rijalhelp"))


#commands
@rijalbot.command()
async def rijalhelp(ctx):
    await ctx.channel.send("")

@rijalbot.event
async def on_message():
    if message.content.startswith("!rijal"):
@rijalbot.event
async def on_ready():

    print("RijalBot online")
TOKEN = ''
rijalbot.run(TOKEN)```
#

Getting "unresolved reference 'message'"

slate swan
#

Ah

#

Thanks

#

Show full code

#

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

timid spade
#

its it working fine but its not giving response
it says interaction failed on discord without any errors in terminal

#

can someone help?

naive briar
#

select.values is a list

slate swan
#

As catgal said

slate swan
#
import discord
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.message_content = True
#prefix for commands


rijalbot = commands.Bot(command_prefix='!',intents=intents,activity=discord.Game(name="!rijalhelp"))


#commands
@rijalbot.event
async def on_message(message):
    unreliable = ["Mufaddal b. Umar"]
    if message.content.startswith("!rijal"):
        if str(message) in unreliable:
            await ctx.send("This hadith is Da'if")

@rijalbot.command()
async def rijalhelp(ctx):
    await ctx.send()

@rijalbot.event
async def on_ready():

    print("RijalBot online")
TOKEN = ''
rijalbot.run(TOKEN)```

Getting an unresolved reference 'ctx'
No traceback, because the command itself doesnt run
slate swan
#

message.channel.send it will be

#

Not ctx.send, ctx use for in prefix commamds

#

Did i even check docs?

#

I forgor

#

Now theres no errors, but when I type "!rijal" then the string in the list, nothing happens

slate swan
#

Still nothing

#

What did u type?

#

Nvm

#

It will be
if unreliable in str(message.content):

#

Xd

#
import discord
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.message_content = True
#prefix for commands


rijalbot = commands.Bot(command_prefix='!',intents=intents,activity=discord.Game(name="!rijalhelp"))


#commands
@rijalbot.command()
async def rijalhelp(ctx):
    await ctx.send()

@rijalbot.command()
async def rijal(ctx):
    unreliable = ["Mufaddal b. Umar"]
    if str(ctx.content) in unreliable:
     await ctx.send("This hadith is Da'if")

@rijalbot.event
async def on_ready():

    print("RijalBot online")
TOKEN = ''
rijalbot.run(TOKEN)```

ERROR    discord.ext.commands.bot Ignoring exception in command rijal
Traceback (most recent call last):
  File "C:\Users\intel\Desktop\rijalbot\venv\lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\intel\Desktop\rijalbot\main.py", line 20, in rijal
    if unreliable in str(message.content):
AttributeError: 'Context' object has no attribute 'content'

The above exception was the direct cause of the following exception:
shrewd apex
#

ctx.message.content

slate swan
trim shadow
#

u can change function like this:

@rijalbot.command()
async def rijal(ctx, name: str):
    unreliable = ["Mufaddal b. Umar"]
    if name in unreliable:
     await ctx.send("This hadith is Da'if")
slate swan
#
@rijalbot.command()
async def rijal(ctx):
    unreliable = []
    if str(ctx.message.content) in unreliable:
        return
    await ctx.send()
    elif:
     await ctx.send("e")```
Statement expected, found Py:ELIF_KEYWORD
shrewd apex
naive briar
#

lol

untold iron
#

hey all im struggling on how to implement buttons, instead of typing a command to run a chunk of code e.g. !newchannel to make a new channel, how can i get it so its a button instead that runs the code?

regal cove
#
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        await interaction.response.edit_message(content=f"This is an edited button response!")
``` I get this error with it:
#
  File "main.py", line 37, in gray_button
    await interaction.response.edit_message(content=f"This is an edited button response!")
AttributeError: 'Button' object has no attribute 'response' ```
naive briar
regal cove
untold iron
#
    @client.tree.command(name = "test")
AttributeError: 'Bot' object has no attribute 'tree'
#

@client.tree.command(name = "test")
async def test(interaction: discord.Interaction):
    await interaction.response.send_message(content = "this msg has a button on it", view = TestButtons())```
#

not sure why i cant use @client.tree.command anymore

#

has it changed?

naive briar
untold iron
naive briar
#

Can you show the code

untold iron
#

import discord
from discord.ext import commands
from discord.ui import Button, View, button
from discord.interactions import Interaction

intents = discord.Intents.all()
client = commands.Bot(command_prefix = '!', help_command=None, intents=intents)


class TestButtons(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
    @discord.ui.button(label = "TEST")
    async def test(self, interaction: discord.Interaction, Button: discord.ui.Button):
        pass

@client.tree.command(name = "test")
async def test(interaction: discord.Interaction):
    await interaction.response.send_message(content = "this msg has a button on it", view = TestButtons())
hushed galleon
#

the command tree only exists in discord.py 2.0, so your error would suggest you either have an alpha version of discord.py or some other library like pycord/nextcord

slate swan
#

!d discord.interactions.Interaction ( checking path)

#

hm the commands.Bot should have a tree added by default

waxen granite
#

avatar_url_as changed to?

hushed galleon
slate swan
#

btw spooky.exe thank you so much it worked

tough rose
#

YP

slate swan
#

how to make a avatar command with embed?

timid spade
tropic estuary
#

is there a thing called on_member_join

slate swan
#

yes

#

its an event

#

it triggers when a member join

#

!d discord.on_member_join

unkempt canyonBOT
#

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

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

how do i add a role on a event

slate swan
#

how to make a avatar command with embed?

#

all tutorials are outdated

slate swan
tropic estuary
#

Member.add_role("member")

#

like this?

slate swan
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

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

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

takes Role objects as argument

slate swan
tropic estuary
#

hmm

#

alright thanks

reef shell
unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
reef shell
#

url= avatar url

tropic estuary
slate swan
slate swan
#

how can i create an event that punish a member when he adds a bot ?

#

i just need the event , and the member getting code

reef shell
unkempt canyonBOT
#

discord.on_integration_create(integration)```
Called when an integration is created.

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

New in version 2.0.
reef shell
#

and

#

!d discord.Integration.user

unkempt canyonBOT
slate swan
#
@sistanibot.command()
async def ruling(ctx):
    rulings = {("a","b"): "c"}
    for key in rulings:
        if ctx.message.content in key:
            await ctx.send(rulings.value)```

I do !ruling a, but I get no output, theres no error message, im trying to do a command where if you do !ruling a, you get the value outputted, which is c
#

how do i make my bot only wait for discord user ids instead of any number

alpine oar
#

yo

#

anyone down to make an bot?

shrewd apex
shrewd apex
#

!d discord.ui.UserSelect

unkempt canyonBOT
#

class discord.ui.UserSelect(*, custom_id=..., placeholder=None, min_values=1, max_values=1, disabled=False, row=None)```
Represents a UI select menu with a list of predefined options with the current members of the guild.

If this is sent a private message, it will only allow the user to select the client or themselves. Every selected option in a private message will resolve to a [`discord.User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").

New in version 2.1.
alpine oar
#

no i meant wanna do a bot toghether

#

like we code both bruh

shrewd apex
#

sure i believe u... ๐Ÿ—ฟ either ways this is not a place for recruitment

alpine oar
#

just dont care then

slate swan
#

or for a number with 18 digits

shrewd apex
#

idc thats why i didn't go in depth wether u know python or not i checked ur messages in the server b4 thats why I dont even bother if u have sone discord bot related questions u can ask

alpine oar
#

ok just dont bother still lol

shrewd apex
slate swan
shrewd apex
#

UserSelect and yes their selection will be visible to u in the callback

slate swan
#

and thats possible through discord.ui.select

shrewd apex
#

... yes and also b4 u ask me how to do it i suggest u check the docs

#

if u dont get which part u can ask

#

discord.py 2.1+

How to use?
You can NOT filter the members, roles or channels shown.
You can set the min/max amount of options the user can or must choose using the min_values and max_values kwargs.

  • Members, Roles or both:```py

import the correct class...

Only members?

from discord.ui import UserSelect

Only roles?

from discord.ui import RoleSelect

Members and roles in one?

from discord.ui import MentionableSelect

import for the decorator and callback...

from discord import ui, Interaction

using...

this example uses the UserSelect

class MyView(ui.View):
# @ui.select(cls=type_we_want, **other_things)
@ui.select(cls=UserSelect, placeholder="Select a user please!")
async def my_user_select(self, interaction: Interaction, select: UserSelect):
# handle the selected users here
# select.values is a list of User or Member objects here
# it will be a list of Role if you used RoleSelect
# it will be a list of both Role and Member/User if you used MentionableSelect
users = [
f"Name: {user.name}, ID: {user.id}"
for user in select.values
]
print(
f"{interaction.user} selected the following users:",
"\n".join(users)
)

use MyView like any other view.

these can also be subclassed like the others.

- Channels:
You can use the `ui.ChannelSelect` class, and limit the type of channels shown with the `channel_types` kwarg:```py
# All channels?
@ui.select(cls=ui.ChannelSelect, ..., ...)
# Only text channels?
@ui.select(cls=ui.ChannelSelect, ..., channel_types=[discord.ChannelType.text], ...)
# etc, channel_types takes a list of discord.ChannelType.

Docs: https://discordpy.readthedocs.io/en/latest/interactions/api.html#select-menus

slate swan
shrewd apex
#

yes send that with ur response to the command

slate swan
shrewd apex
#

dont see the point of a message event in a slash command u can use a modal instead ig coz if u take from message event u will have to do a bunch of extra handling to make sure validation of the id ยฏ_(ใƒ„)_/ยฏ

#

just use the UserSelect makes life easier

shrewd apex
#

also since check is supposed to be sync if the user is not in bot cache u have to write a few more lines to fetch the user and check

shrewd apex
#

u can test it and check

#

i am going for dinner

slate swan
maiden fable
naive briar
#

The error is telling what's the exact problem is ducky_vader

shrewd apex
#

print(groupreq)

shrewd apex
shrewd apex
slate swan
#

discord.ext.commands.bot Ignoring exception in command sistanifatwa
Traceback (most recent call last):
File "C:\Users\intel\Desktop\rijalbot\venv\lib\site-packages\discord\ext\commands\core.py", line 229, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\intel\Desktop\rijalbot\main.py", line 20, in sistanifatwa
kyword = dict.get(key)
TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'str' object

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\intel\Desktop\rijalbot\venv\lib\site-packages\discord\ext\commands\bot.py", line 1349, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\intel\Desktop\rijalbot\venv\lib\site-packages\discord\ext\commands\core.py", line 1023, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\intel\Desktop\rijalbot\venv\lib\site-packages\discord\ext\commands\core.py", line 238, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: descriptor 'get' for 'dict' objects doesn't apply to a 'str' object

@sistanibot.command()
async def sistanifatwa(ctx,key):
    rulings = {("a","b"): "c"}
    kyword = dict.get(key)
    if kyword is not None:
         return
    await ctx.send(kyword)```
maiden fable
slate swan
#

I did !sistanifatwa a

shrewd apex
#

be4 creation = add this

groupreq = groupreq['data'][0]
shrewd apex
maiden fable
#

til

slate swan
#

Wassup

maiden fable
#

Why do I get a feeling that u both know each other?

slate swan
#

?

maiden fable
#

Not u

#

endo and Asher

slate swan
#

๐Ÿ’€

shrewd apex
shrewd apex
slate swan
#

He is a mind reader ๐Ÿ—ฟ

shrewd apex
slate swan
slate swan
#

Don't tell if personal xd

shrewd apex
#

india

slate swan
#

SHEEESH

#

app_commands also from india

slate swan
shrewd apex
slate swan
#

Cul, only me is from a alien country sad

shrewd apex
#

sarthak to be precise

slate swan
shrewd apex
#
@sistanibot.command()
async def sistanifatwa(ctx, key):
    rulings = {"a": "c", "b": "c"}
    kyword = rulings.get(key, None)
    if kyword is None:
         return
    await ctx.send(kyword)```
call command like this
`prefix[command_name] b`
#

spoon feeding be like

slate swan
#

He is really a OG, should have got bug hunter role xd

#

I mean badge ;-;

shrewd apex
#

damn

slate swan
#

asher

slate swan
#

spoon feed me im confused ;-;

slate swan
#

๐Ÿ’€

shrewd apex
slate swan
#

U were on bad moon before eating XD

shrewd apex
slate swan
#

Haha

shrewd apex
#

after sometime i need to go study so rn my break time ducky_drawing

slate swan
#

xd

#
      def check(message):
            return message.author == interaction.user and message.channel == interaction.user and message.content.isdigit() and client.get_user(int(message.content))
        msg = await client.wait_for('message', check=check)
        await msg.channel.send(f'USER ID IS {msg.content}')```
#

Today i had my physics xm ๐Ÿ’€๐Ÿ’€

#

Tmrw is bio, so hard ahhh

#

its what im tryna do i said earlier

shrewd apex
#

also interaction.channel == message.channel

slate swan
#

what do i change to this to make it work

i want to send my discord bot a users id and then for my to send that id back to me

slate swan
slate swan
#

Idk ig i am just bad

shrewd apex
#
      def check(message):
            return message.author == interaction.user and message.channel == interaction.channel and message.content.isdigit() and client.get_user(int(message.content))
    msg = await client.wait_for('message', check=check)
    await msg.channel.send(f'USER ID IS {msg.content}')```
shrewd apex
#

cant think on an empty stomach

slate swan
#

;-;

#

Brain?

#

U think from brain not stomach tho ๐Ÿ—ฟ

shrewd apex
slate swan
#

Sedge

maiden fable
shrewd apex
slate swan
shrewd apex
#

time to go study cya

shrewd apex
#

bio kek

slate swan
#

Too much shit to read

maiden fable
slate swan
#

Ok

#

anyone know how i can make it so it send a random joke when no argument is specified and when a category is passed it send from this category?


    @commands.command("oof")
    async def joke(self, ctx, category):
        randomurl = "https://api.chucknorris.io/jokes/random"
        categoryurl = f"https://api.chucknorris.io/jokes/random?category={category}"
        response = httpx.get(randomurl).json()["value"]
        await ctx.send(response)
slate swan
slate swan
naive briar
#

The commands wasn't loaded

slate swan
#

it say it was

#
/home/infinimonster/Documents/Privat/Python/discord-bot/main.py:15: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  try: bot.load_extension(f"Cogs.{filename[:-3]}"); print(f"{colorama.Fore.RED}[>] {colorama.Fore.GREEN}Cogs.{filename[:-3]} loaded")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[>] Cogs.fun loaded
[>] Bot is ready!

It give this await warning but the cog still loads

naive briar
#

It's just warning, not error(or exception)

#

And you should await it if you already know you have to

slate swan
naive briar
#

Of course there is

slate swan
#

HOW TO EDIT AN EMBED DESCRIPTION ?

slate swan
#

but the issue is the commands not found issue

#

and it not seem to be cog loading issue

naive briar
#

So the commands in that cog won't be loaded

slate swan
#

Sure

slate swan
slate swan
slate swan
#

it loaded the cog

slate swan
# slate swan yep

i think its like
your_var = await ctx.send(embed=yourembedvar) await your_var.edit(embed=newembed)

naive briar
slate swan
#

Ok

slate swan
naive briar
#

!e

from asyncio import run


async def coro():
    pass

async def main():
    coro()
    print("owo")

run(main())
slate swan
#

!e
print("hi")

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.10 eval job has completed with return code 0.

hi
naive briar
slate swan
naive briar
slate swan
#

the time will be -1 in each second

#

you'll get rate limited

#

@sistanibot.command()
async def sistanifatwa(ctx,key):
rulings = {}
kyword = rulings.get(key, None)
if kyword is None:
return
await ctx.send(kyword)
elif kyword is not None:
return
await ctx.send("Not found!")

File "C:\Users\intel\Desktop\rijalbot\main.py", line 34
elif kyword is not None:
^^^^
SyntaxError: invalid syntax

slate swan
naive briar
#

Do you know basic Python

slate swan
#

aah

slate swan
#

Pro code

slate swan
naive briar
#

What error

slate swan
#

RuntimeError: asyncio.run() cannot be called from a running event loop
sys:1: RuntimeWarning: coroutine 'Client.run.<locals>.runner' was never awaited

#

u have to make a async function for to run the client

naive briar
#

Or just load the extensions in setup_hook

slate swan
#
async def r():
   await client.run()

asyncio.run(r())```
#

await giveaway.edit(embed=embed.description=....

slate swan
#

idk i dont use discord 2.0.0 i use pycord

naive briar
unkempt canyonBOT
#

run(token, *, reconnect=True, log_handler=..., log_formatter=..., log_level=..., root_logger=False)```
A blocking call that abstracts away the event loop initialisation from you.

If you want more control over the event loop then this function should not be used. Use [`start()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.start "discord.Client.start") coroutine or [`connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.connect "discord.Client.connect") + [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login "discord.Client.login").

This function also sets up the logging library to make it easier for beginners to know what is going on with the library. For more advanced users, this can be disabled by passing `None` to the `log_handler` parameter.

Warning

This function must be the last function to call due to the fact that it is blocking. That means that registration of events or anything being called after this function call will not execute until it returns.
slate swan
naive briar
#

It's not a coroutine

slate swan
#

im playing word bomb

naive briar
slate swan
#

Fuck logitech g502

#
import colorama; colorama.init(autoreset=True)
import discord
import os, sys
import traceback
import asyncio
from discord.ext import commands


# load all cogs in the cogs folder
if __name__ == '__main__':
    TOKEN = "secret"
    bot = commands.Bot(command_prefix='>', self_bot=True)

    async def runbot():
        for filename in os.listdir("Cogs"):
            if filename.endswith(".py"):
                try: await bot.load_extension(f"Cogs.{filename[:-3]}"); print(f"{colorama.Fore.RED}[>] {colorama.Fore.GREEN}Cogs.{filename[:-3]} loaded")
                except Exception as e: print(f'Failed to load extension {filename}', file=sys.stderr); traceback.print_exc()

        try: print(f"{colorama.Fore.YELLOW}[>] {colorama.Fore.LIGHTGREEN_EX}Bot is ready!"); bot.run(TOKEN)
        except discord.errors.LoginFailure: print(f"{colorama.Fore.YELLOW}[>] {colorama.Fore.LIGHTRED_EX}Improper token has been passed!")

    asyncio.run(runbot())
naive briar
#

My god

slate swan
#

?

naive briar
#

Just run the bot normally and set the bot's setup_hook to load extension function

#

Like

bot = commands.Bot(...)

async def load_ext_setup_hook():
    # load the extensions here
    pass
bot.setup_hook = load_ext_setup_hook


if __name__ == "__main__":
    bot.run(...)
#

Or subclass the bot class

slate swan
#

i now changed it to this:

asyncio.run(bot.load_extension(f"Cogs.{filename[:-3]}")); print(f"{colorama.Fore.RED}[>] {colorama.Fore.GREEN}Cogs.{filename[:-3]} loaded")

but now i got another weird issue:
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.fun' raised an error: TypeError: object NoneType can't be used in 'await' expression

naive briar
#

Why

#

Just why

slate swan
#

i don't want to load them manually so suggesting me to do so is not helpful, i simply want to fix the errors and then move on.

naive briar
#

And it's just creating a function and setting attribute

#

That's it

slate swan
#

I need code for this

unkempt canyonBOT
#

examples/views/link.py lines 21 to 33

# Define a simple View that gives us a google link button.
# We take in `โ€‹query`โ€‹ as the query that the command author requests for
class Google(discord.ui.View):
    def __init__(self, query: str):
        super().__init__()
        # we need to quote the query string to make a valid url. Discord will raise an error if it isn't valid.
        query = quote_plus(query)
        url = f'https://www.google.com/search?q={query}'

        # Link buttons cannot be made with the decorator
        # Therefore we have to manually create one.
        # We add the quoted url to the button, and add the button to the view.
        self.add_item(discord.ui.Button(label='Click Here', url=url))```
slate swan
naive briar
#

Then what is it

slate swan
#
[>] Bot is ready!
/home/infinimonster/Documents/Privat/Python/discord-bot/Cogs/fun.py:16: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
  bot.add_cog(FunCog(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Failed to load extension fun.py
Traceback (most recent call last):
  File "/home/infinimonster/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 788, in _load_from_module_spec
    await setup(self)
TypeError: object NoneType can't be used in 'await' expression

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/infinimonster/Documents/Privat/Python/discord-bot/main.py", line 15, in loadext
    try: await bot.load_extension(f"Cogs.{filename[:-3]}"); print(f"{colorama.Fore.RED}[>] {colorama.Fore.GREEN}Cogs.{filename[:-3]} loaded")
  File "/home/infinimonster/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 854, in load_extension
    await self._load_from_module_spec(spec, name)
  File "/home/infinimonster/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 793, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.fun' raised an error: TypeError: object NoneType can't be used in 'await' expression
 cd /home/infinimonster/Documents/Privat/Python/discord-bot/Cogs
naive briar
#

You would have known the issue if you read the error

#

!d discord.ext.commands.Bot.add_cog

unkempt canyonBOT
#

await add_cog(cog, /, *, override=False, guild=..., guilds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a โ€œcogโ€ to the bot.

A cog is a class that has its own event listeners and commands.

If the cog is a [`app_commands.Group`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Group "discord.app_commands.Group") then it is added to the botโ€™s [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") as well.

Note

Exceptions raised inside a [`Cog`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog "discord.ext.commands.Cog")โ€™s [`cog_load()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog.cog_load "discord.ext.commands.Cog.cog_load") method will be propagated to the caller...
naive briar
#

add_cog is a coroutine, await it

hushed galleon
#

that message also includes a second error indicating that setup() isnt an async function

slate swan
#

Hello, one question, in this example how can you call a function without adding the parameter (ctx), I try it and it gives me an error, maybe it's something very stupid but I can't find the logic

#

Ok, I realized, all this is thanks to the click with the click.pass_context, I thought that maybe there would have to be something related to ctx -> commands.Context but I was wrong, thanks for your attention

hushed galleon
#

yeah its just how click works, you're actually calling a Command object returned by the command() decorator and that doesnt require any arguments

slate swan
hushed galleon
#

click is a library for building command line interfaces

hushed galleon
slate swan
#
        while duree > 0:
            duree = int(duree - 1)
            embed = discord.Embed(title=ctx.guild.name, description=(
                        "**Time left: " + str(duree) + " seconds\nWinners: " + str(
                    winners) + "\nPrize: " + prize + "**"))
            await giveaway.edit(embed=embed)
            sleep(60)
            if duree == 0:
                await ctx.send("visca barca")
            else:
                continue```


error : discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'duree' referenced before assignment
#

i need dev for bot

naive briar
#

!e

def main():
    if 0:
        string = "owo"
    else:
        pass

    print(string)

main()
unkempt canyonBOT
#

@naive briar :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 9, in <module>
003 |   File "<string>", line 7, in main
004 | UnboundLocalError: cannot access local variable 'string' where it is not associated with a value
naive briar
slate swan
#

i had an error about the error name

#

it was 'value error' not 'index error'

karmic delta
#

!e

unkempt canyonBOT
#
Missing required argument

code

karmic delta
#

!e print('Hi')

slate swan
#

how to get the members who reacted to a message in discord.py

kind trellis
#

How do I get the bot's avatar via interaction?

naive briar
unkempt canyonBOT
naive briar
#

!d discord.Reaction.users

unkempt canyonBOT
#

async for ... in users(*, limit=None, after=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.11)") representing the users that have reacted to the message.

The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

Changed in version 2.0: `limit` and `after` parameters are now keyword-only.

Examples

Usage...
shrewd apex
#

u cant

hushed galleon
#

too many people are hosting their bots on replit's datacenters so they all hit the same ratelimit

shrewd apex
#

not on replit also its not cloudflare ratelimit but discord

shrewd apex
unkempt canyonBOT
#

property client```
The client that is handling this interaction.

Note that [`AutoShardedClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient "discord.AutoShardedClient"), [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot"), and [`AutoShardedBot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.AutoShardedBot "discord.ext.commands.AutoShardedBot") are all subclasses of client.
timid spade
#

await interaction.response.send_message is only working in the indent marked with green
its not working anywhere else
can someone tell me why?

shrewd apex
#

!indents

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

shrewd apex
#

indentation over curly braces anyday

timid spade
#

huh

timid spade
shrewd apex
#

the if statement exists ducky_drawing

timid spade
#

i tired but it still gave errors

sick birch
#

hello

shrewd apex
#

read up on indentations and if elif chains/blocks

sick birch
#

am here

shrewd apex
#

hello sir

timid spade
#

it worked
i placed the response before for loop
its wasnt working after for loop

#

but yeah worked

slate swan
#

ur loop is failing

sick birch
#
if ctx.channel.id == (
    ):
        ...
        # Allows bot to use @bot.command() commands along with on_message event
        await client.process_commands(ctx)
#

See an issue here?

quick axle
#

Like nextcord is updated

sick birch
#

It's got all the newest features

quick axle
#

It does?

sick birch
quick axle
#

I heard it was discontinued?

naive briar
#

They also did continue

quick axle
#

Oh i didnt know that

#

Thanks for the info

loud flicker
slate swan
#

!print('spam')

if name == 'main':
print('eggs')

#

!eprint('spam')

if name == 'main':
print('eggs')

fading marlin
#

#bot-commands and you gotta use codeblocks
!e ```py
print("Hello World!")
```

naive briar
#

!code

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.

rare echo
#

either code, an error, or somethin else

#

preferably both of those lmao

loud flicker
rare echo
#

i mean theres tons of people here to help but if its sensitive then ig

slate swan
#

'Attachment' object has no attribute 'fp'

unkempt canyonBOT
#

Hey @slate swan!

It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

slate swan
#
@ad.event
async def on_guild_join(guild):
  with open(f"{guild.id}.json", "w") as f:
    f.write("{}")
  with open(f"{guild.id}.json", "r") as f:
    guilds = json.load(f)
  await saveguild(guilds, guild)
  with open(f"{guild.id}.json", "w") as f:
    json.dump(guilds, f, indent=4)

This wont make the file, anyone help?

hexed dagger
#

Anybody know why this is synrax erorr

slate swan
#

If anyone needs the CTX combined with TREE COMMANDS with COGS to get official slash commands on their bot I put a sample to download just click my server profile link or DM me for any help .

dense coral
hexed dagger
slate swan
#

ill test ty

#

thank you sm

abstract kindle
#

when syncing commands, does it wipe all the permissions set in the guild settings > integrations > command > permissions

slate swan
#

{"1048657638369525811": {"channel": "", "ad": "welcome\nto\ntest"}}

#

is there a way to make this multi line?

winged linden
#

Inside string

slate swan
#

I did

winged linden
#

Show me

slate swan
winged linden
#

I meant the code lol

abstract kindle
#

@winged linden is there a way to set those permissions in discord.py?

winged linden
slate swan
#
@ad.tree.command(name='ad', description='Set your ad to advertise!')
@app_commands.describe(adv = 'Put your ad!')
async def advertise(ctx: discord.Interaction, adv: str):
  with open(f"{ctx.guild.id}.json", "r") as f:
    guilds = json.load(f)
  guilds[f'{ctx.guild.id}']['ad'] = adv
  with open(f"{ctx.guild.id}.json", "w") as f:
    json.dump(guilds, f, indent=4)
winged linden
#

I do not know of a way to set them in discord py

abstract kindle
#

Okay, I did that before but somehow they got reset

#

My issue tho, thanks

winged linden
slate swan
#

none

winged linden
slate swan
#

yet

winged linden
slate swan
#

wym?

#
@ad.command()
async def myad(ctx):
  with open(f"{ctx.guild.id}.json", "r") as f:
    guilds = json.load(f)
  ad = guilds[f'{ctx.guild.id}']['ad']
  await ctx.send(ad)
winged linden
#

Oh

#

ctx is a slash command?

#

In

slate swan
#

yea

#

ctx: discord.Interaction

winged linden
#

What do you want it to send

grand willow
#

F

winged linden
slate swan
winged linden
grand willow
winged linden
slate swan
#

{
"1048657638369525811": {
"channel": "",
"ad": "hi\n__guys__ crazy innit"
}
}
output:
hi
guys crazy innit

winged linden
#

The top is what its sending

#

And the bottom is what you want it to send

slate swan
#

ad is sending

#

no I loaded ad and sent it

winged linden
#

I assume the top parameter is the guild Id?

slate swan
#

channel id

winged linden
slate swan
#

wait stop im confused

#

let me explain again

winged linden
#

What does it post when you run it

#

Then in a separate message tell me what you want it to send

slate swan
#

basically I want \n to do its job as its not doing that

#

its sending hi\nguys

#

not
hi
guys

winged linden
#

this is how \n works

#
print(โ€œBaller \n Is Goodโ€)

Output:
Baller
Is Good

slate swan
#

ik

#

but when you load it from json it doesnt work

winged linden
#

Print what is being loaded from json

grand willow
#
        b = Button(label=f"Apply for Staff",style=discord.ButtonStyle.green)
        async def form(interaction : discord.Interaction):
            await interaction.response.send_modal(Feedback())
        b.callback = form
        view = View(timeout=None)
        view.add_item(b)
        await ctx.send(f"Click on this button to apply for Staff", view=view)

So I just have this code where it should send a Modal and every time I press the button I get this error: raise ValueError('could not find open space for item') ValueError: could not find open space for item I never got it before and tried to google it but couldnt find anything

slate swan
cloud dawn
winged linden
#

Ur formatting

#

Scam

cloud dawn
#

!e print("Baller \n Is Good")

unkempt canyonBOT
#

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

001 | Baller 
002 |  Is Good
sick birch
#

iphone user spotted

winged linden
#

Lol

cloud dawn
#

I was like whot are those.

winged linden
#

โ€œ

winged linden
cloud dawn
#

!charinfo โ€œ

unkempt canyonBOT
cloud dawn
#

:3

winged linden
#

Just an iphone user trying to help ๐Ÿ˜ญ

cloud dawn
sick birch
cloud dawn
slate swan
#

nah bruh IO just fixed it

#

ad = guilds[f'{ctx.guild.id}']['ad']
ad = ad.replace('\\n', '\n')

sick birch
winged linden
#

Lol

sick birch
#

I have a puzzle idea! Can I send it to you? Please don't. Because of legal issues like copyright and attribution, I don't accept puzzle ideas, and I won't even read your email if it looks like one just in case I use parts of it by accident.
https://adventofcode.com/2022/about

sick birch
winged linden
#

Or ill somehow make an easter event

sick birch
#

Still working out a finks kinks in the codebase

winged linden
#

Noice

#

Im moving on to making websites for a little bit kekw

slate swan
#

Traceback (most recent call last):
File "main.py", line 39, in <module>
@ad.command()
AttributeError: 'Command' object has no attribute 'command'

#

@ad.command()

slate swan
winged linden
#

This is in a slash command

slate swan
#

not anymore

winged linden
#

So whh @torn wigeon.command()

#

Rip bro called ad

#

What is @ ad

#

What is ad =

cloud dawn
#

Hasn't chat in 2 years dw

slate swan
#

ad = commands.Bot(command_prefix='--', intents=discord.Intents.all())

winged linden
#

Command object

slate swan
#

?

winged linden
#

Commands.bot does not have commands as an attribute?

#

Im looking at code rn

cloud dawn
#

Gonna need more info chief since ad isn't a Bot.

winged linden
#

ad is commands.Bot

#

Did you import commands

cloud dawn
#

Then why is the TB saying it's a Command object?

slate swan
#

yea

#

nothing should be wrong

winged linden
cloud dawn
#

Honestly cannot say without more references to code.

winged linden
#

Yeah

#

Do you have ad.add_command

slate swan
#
import discord
from discord.ext import commands
import json
from discord import app_commands

ad = commands.Bot(command_prefix='!a', intents=discord.Intents.all())

async def saveguild(guilds, guild):
  if not f'{guild.id}' in guilds:
    guilds[f'{guild.id}'] = {}
    guilds[f'{guild.id}']['channel'] = ''
    guilds[f'{guild.id}']['ad'] = ''

@ad.event 
async def on_ready():
  synced = await ad.tree.sync()
  print(f"Logged in as {ad.user}.\nSynced {len(synced)} commands.")

@ad.event
async def on_guild_join(guild):
  with open(f"{guild.id}.json", "a") as f:
    f.write("{}")
  with open(f"{guild.id}.json", "r") as f:
    guilds = json.load(f)
  await saveguild(guilds, guild)
  with open(f"{guild.id}.json", "w") as f:
    json.dump(guilds, f, indent=4)

@ad.command()
async def ad(ctx, *, adv):
  with open(f"{ctx.guild.id}.json", "r") as f:
    guilds = json.load(f)
  guilds[f'{ctx.guild.id}']['ad'] = adv
  with open(f"{ctx.guild.id}.json", "w") as f:
    json.dump(guilds, f, indent=4)
  adv = adv.replace('\\n', '\n')
  await ctx.author.send(f"**Set your ad to**:\n{adv}")

@ad.command()
async def myad(ctx):
  with open(f"{ctx.guild.id}.json", "r") as f:
    guilds = json.load(f)
  ad = guilds[f'{ctx.guild.id}']['ad']
  ad = ad.replace('\\n', '\n')
  await ctx.author.send(ad)
cloud dawn
#

Or a more clear explanation why ad is a Command object.

winged linden
#

I cant lie ad is not the best name for your bot

slate swan
#

its the same as client or bot

winged linden
#

It is

#

But its more confusing since you also have variables named ad

slate swan
#

smart

#

now it works since its bot

#

i never thought about vars

cloud dawn
#

Also are you making a json for each guild?

winged linden
slate swan
#

is there anyway to delete messages in dm channel

winged linden
slate swan
#

also is there a way to check if the channel id is in the same guild?

winged linden
#

Just make a while loop that constantly ads 1 to a variable per second and then display the variables value when someone runs the command

slate swan
#

like
--setchannel id
and it will see if the id provided is a channel in the same guild the command was run

winged linden
#

I think that wokrs

cloud dawn
winged linden
tribal horizon
#

How do I create an unban command in Discord.py? Here's mine:

@commands.command()
    @commands.has_permissions(ban_members=True)
    async def unban(self, ctx, member: discord.Member, *, reason = "not specified"):
        await member.unban()
        await ctx.send(f"Unbanned: {member}")
slate swan
#

could you point me in the write direction?

tribal horizon
winged linden
#

Assuming channel is a textchannel

winged linden
cloud dawn
winged linden
#

If they are banned they arenโ€™t a member anymore

winged linden
tribal horizon
winged linden
tribal horizon
cloud dawn
winged linden
#

So if someone gets banned in a different server you want to un ban them from a specific server?

tribal horizon
#

I am trying to unban a banned member in my server with an unban command

winged linden
#

You cant use member

#

They arent a member of the server like i stated

tribal horizon
#

Should I use guild.unban()?

slate swan
#
Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 60, in setchannel
    if ctx.guild.id != id.guild:
AttributeError: 'int' object has no attribute 'guild'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'int' object has no attribute 'guild'
    if ctx.guild.id != id.guild:
winged linden
#

what is id.guild

slate swan
#

channel id

winged linden
#

What

slate swan
#

id=0
--setchannel 1048657953948962888

winged linden
#

Your comparing guilds not channels

#

If you have the channel id then you will need to get the guild of the channel

#

Or get the channel that your looking for in the original guild

#

Little confused on your goal

winged linden
#

I think

tribal horizon
winged linden
#

Wait no you donโ€™t have to actually

#

@cloud dawn can i spoonfeed or no

winged linden
cloud dawn
winged linden
#

Will tell you whos banned

cloud dawn
winged linden
#

I was going to spoonfeed code to him LOL

cloud dawn
#

lel

winged linden
#

can you spoonfeed me a robot that can send me to the moon k thz

tribal horizon
cloud dawn
#

Not stackoverflow but that code.

#

Depending on the size await ctx.guild.bans() can be a heavy request.

winged linden
#

Is it depreciated

#

Oh true

#

For a big guild that might stall the bot for a while

tribal horizon
#

Thanks for the help Fiery and Pandabweer

winged linden
#

Alwayss happy to help as much as I can

cloud dawn
winged linden
#

Yeah but the limit would mean if they have more then 1000 bans

#

Some people arenโ€™t getting unbanned lol

#

But your code solves the issue so its chilling

slate swan
#

so close to finishing this i think

#
    with open(f"{guildid}.json", "r+") as f:
      guilds = json.load(f)
    channel2 = guilds[f'{guildid}']['channel']
    ad2 = guilds[f'{guildid}']['ad']
    channel = guilds[f'{ctx.guild.id}']['channel']
    ad = guilds[f'{ctx.guild.id}']['ad']
    if channel2 or ad2 or channel or ad == "":
      await ctx.send("Cant partner as there configs arent setup.")
#
Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 101, in partner
    channel = guilds[f'{ctx.guild.id}']['channel']
KeyError: '1048657638369525811'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: '1048657638369525811'
#
{
    "1048657638369525811": {
        "channel": "1048657953948962888",
        "ad": "test"
    }
}
winged linden
#

KeyError

#

The id is probably in the wrong format

slate swan
#
Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 109, in partner
    await channel.send(ad)
AttributeError: 'NoneType' object has no attribute 'send'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'
winged linden
#

Are you sure its a integer

slate swan
#

i got it

#
    else:
      channel = bot.get_channel(channel2)
      await channel.send(ad)
      channel = bot.get_channel(channel)
      await channel.send(ad2)
winged linden
#

Check that channel2 is an integer

slate swan
#

ill int them

winged linden
#

Where do you get the value of channel2 btw

slate swan
#

omg it works

#

channel2 = int(channel2)
channel = int(channel)
channel2 = bot.get_channel(channel2)
await channel2.send(ad)
channel = bot.get_channel(channel)
await channel.send(ad2)

vague cliff
winged linden
#

I just saw

#

Lol

sand sphinx
#

hey yoo
how I can fix this?

vague cliff
vague cliff
winged linden
#

idk what your doing with process.env

fading marlin
winged linden
#

Simpler

#

Just dont share your source with nobody you dont trust no?

#

I guess

#

I local host when I test so

vague cliff
#

The same problem

winged linden
#

Reverse your change i was wrong

sand sphinx
vague cliff
#

I fix it but

fading marlin
#

command_prefix, not commands_prefix

winged linden
#

yeah

sand sphinx
vague cliff
#

The same problem

winged linden
#

command_prefix=โ€˜+โ€™

#

Do not copy and paste

fading marlin
winged linden
#

Im on mobile

winged linden
slate swan
#

seconds = str(x % 60)

slate swan
vague cliff
winged linden
sand sphinx
winged linden
#

And rexecute

slate swan
#

try
rand.randint(1, 20)

fading marlin
slate swan
#

wait

#

x = error.retry_after

winged linden
fading marlin
winged linden
fading marlin
winged linden
#

So whh is variable named seconds

vague cliff
#

Ahhh why

slate swan
#

x = error.retry_after
minutes = str(x // 60)
seconds = str(x % 60)
await ctx.send(f"Minutes: {minutes} | Seconds: {seconds}")

fading marlin
#

none of those should return a decimal value

sand sphinx
# fading marlin send your entire code please, and obfuscate the token if its visible
import discord
from discord import player
from discord.ext import commands
from discord.ext import tasks
from mcstatus import MinecraftServer
import asyncio
import random

token = 'oya oya'

cliente = commands.Bot(command_prefix= '-', case_insensitive = True)

server = MinecraftServer.lookup("188.80.167.41")


@tasks.loop(seconds=40)
async def changepresence():
  global x
  game = iter(
  [f"em Alcanena Shenanigans!", " no servidor de Minecraft!", " | Em desenvolvimento!", " | -help"])
  for x in range(random.randint(1, 4)):
    x = next(game)
  await cliente.change_presence(activity=discord.Game(name=x))

@cliente.event
async def on_ready():
  print('Entramos como {0.user}' .format(cliente))
  changepresence.start()

@cliente.command()
async def players(ctx):
  query = server.query()
  if status.players.online > 0:
    embed = discord.Embed(title = 'Status', description = f'Players Online: {status.players.online}', colour = 2523174)
    embed.set_author(name = ctx.message.author.name, icon_url = ctx.message.author.avatar_url)
  else:
    embed = discord.Embed(title = 'Status', description = f'Players Online: {status.players.online}\nThe server has the following players online: {query.players.names}', colour = 2523174)
    embed.set_author(name = ctx.message.author.name, icon_url = ctx.message.author.avatar_url)
  await ctx.send(embed = embed)

@cliente.command()
async def status(ctx):
  status = server.status()
  query = server.query()
  latency = server.ping()
  
  embed = discord.Embed(title = 'Status', description = f'Players Online: {status.players.online}\nNicks: {query.players.names}\nPing: {latency}', colour = 2523174)
  embed.set_author(name = ctx.message.author.name, icon_url = ctx.message.author.avatar_url)
  await ctx.send(embed = embed)
  
cliente.run(token)```
slate swan
#

its in the code

winged linden
#

Yeah i saw it

#

It shouldnโ€™t return a decimal

vague cliff
slate swan
#

we gucci i got it

#

bot should be Bot

#

commands.Bot

winged linden
winged linden
vague cliff
fading marlin
fading marlin
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, 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

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

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

slate swan
#

x = error.retry_after
x = int(x)
minutes = x // 60
seconds = x % 60
minutes = int(minutes)
seconds = int(seconds)
await ctx.send(f"Please wait {minutes} minutes and {seconds}{'' if seconds == 1 else 's'}")

#

idk i int it

winged linden
#

Oh bruh

sand sphinx
sand sphinx
#

for that I was updating the discordpy's package and this...

#

upgraded the requirements file and doesn't exist

#

@fading marlin

slate swan
#

how do I open original message with videos

desert hatch
#

(I am very very very new to all of this, so I apologize if I act as such by not knowing what you may be saying at times, and if this is the wrong place for this.)

I have been stuck for a couple days now just trying to bring my bot online for Discord. I keep returning this error message for "Improper Token has been passed" when I run the module. (Picture one)
I have been using the Bot Token under the Bots tab in the Application. I've also reset the token numerous times, updating my code with the new token every time.
I have completely deleted the application all together, created a new one, created a new bot and even then it doesn't give me the option to "Copy" at the very start, I always have to Reset the token before being able to copy it. (Picture two) (NEWLY created bot)

Is there something that I did that could have caused this issue?

desert hatch
#

I whited out the token obviously

grand willow
# desert hatch Absolutely!

It would be better for you to use command instead of using on_message
This is the example from the Github page of discord.py

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>', intents=intents)

@bot.command()
async def ping(ctx):
    await ctx.send('pong')

bot.run('token')
desert hatch
#

Ok, so I copy and pasted that, and put my token in but still got the same error message lol. I might be in over my head maybe

rare echo
#

remove the <>

#

should just be ('ashdaisuhdgasnjdgal')

grand willow
#

Yes without the < >

desert hatch
#

You guys are the BEST! Thank you โค๏ธ

abstract kindle
#

yo how do i stop tasks from restarting when i reload the cog

#

I think every time i reload the cog it adds a new task loop

fading marlin
#

you cancel the task once you unload the cog

abstract kindle
#

can i just pause the task?

fading marlin
#

sure

#

though you'd have to keep track of the cog instance for it not to start once you reload it

abstract kindle
#

like on unload, pause the task

#

and then I'd have to track the task to start it up again on reload? and also stop a new one from starting on reload

fading marlin
#

yup

abstract kindle
#

how do i access all running tasks?

fading marlin
#

I don't think that's stored anywhere, pretty sure you have to save that yourself

abstract kindle
#

ah okay. if I have multiple running in the background, would I check it someone in my ide?

fading marlin
#

wdym?

abstract kindle
#

like how would I check the loops that have built up if I haven't been stopping them on cog unload

fading marlin
#

they aren't stored anywhere apparently

abstract kindle
#

then where would they be running?

fading marlin
#

it just runs as an asyncio task

unkempt canyonBOT
#

discord/ext/tasks/__init__.py line 398

self._task = asyncio.create_task(self._loop(*args, **kwargs))```
desert hatch
#

What should I do if I can't find the FFmpeg .zip file this person is using in the tutorial I'm watching? It seems to be older than what I can find on github

slate swan
desert hatch
#

I've been there, when I click on BtbN it takes me to github to download from a list of zip files. But the Auto-Build thread is from early Feb 2021, and I can't go past late Feb 2021 lol

#

(I'm brand spankin new to this, I'm just super excited I got my bot to join my vc lmao)

tribal horizon
#

I tried to test the ban command on an alt account with my Discord.py bot. I removed the ban on my alt account. I cannot invite my alt account back to my test server. How do I fix this issue?

desert hatch
#

I'm assuming you tried going to Discord's "Moderation" settings in the server settings?

tribal horizon
desert hatch
rare echo
#

typically a one time vpn will help

#

enable, rejoin, then disable

tribal horizon
tribal horizon
rare echo
tribal horizon
rare echo
#

no

tribal horizon
#

That server is a private test server

rare echo
#

only when you are bypassing something that isnt yours would it be technically breaking tos

patent lark
#
def is_owner(self):
    def predicate(self, ctx):
      return ctx.author.id == self.owner
    return commands.check(predicate)```

i have taken a decently long break from discord.py, and im attempting to create a decorator, am i making an obvious mistake here?
tribal horizon
slate swan
#

Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 245, in setup
    guilds = json.load(f)
  File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
io.UnsupportedOperation: not readable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnsupportedOperation: not readable
@bot.command()
async def setup(ctx):
  try:
    f = open(f"{ctx.guild.id}.json", "r")
  except:
    f = open(f"{ctx.guild.id}.json", "a")
    f.write("{}")
    guilds = json.load(f)
    await saveguild(guilds, ctx.guild)
    with open(f"{ctx.guild.id}.json") as f:
      json.dump(guilds, ctx.guild)
slate swan
#

"not readable"

#
    for guild in bot.guilds:
      if guild.name != "Advertising Bot":
        count += 1
        embed.description += f"{count} - {guild.name} - {guild.id}\n"
      await ctx.send(embed=embed)
#

i think i indented wrong

slate swan
#

yea got it

#

perfect

limber bison
#

how can i crerate a on_message event with reply to each message ?

slate swan
slate swan
#
Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 284, in addword
    json.dump(guilds, ctx.guild)
  File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/json/__init__.py", line 180, in dump
    fp.write(chunk)
AttributeError: 'Guild' object has no attribute 'write'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1349, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/home/runner/cross-ad-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Guild' object has no attribute 'write'

limber bison
#

my mind damn

slate swan
limber bison
#

how can i store embeds in db ?

slate swan
#

u can store the data for title and desc

#

stuff like that

#

idk about just one var for the whole thing

limber bison
#

ohhhk k thanks

slate swan
#

maybe try in where your storing it
this = discord.Embed()

#

then load this and make it a var

#

then await ctx.send(embed=var)

shrewd apex
desert hatch
#

Back again with another dumb question. The tutorial I've been following ended up at a point where the person moved from discord.py to Nextcord. Do I HAVE to move away from discord.py to add my bot to the slash commands list? I'd also like to create buttons for my bot so I can play a specific audio file with the click of a button

shrewd apex
#

no

unkempt canyonBOT
#

json.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)```
Serialize *obj* as a JSON formatted stream to *fp* (a `.write()`-supporting [file-like object](https://docs.python.org/3/glossary.html#term-file-like-object)) using this [conversion table](https://docs.python.org/3/library/json.html#py-to-json-table).

If *skipkeys* is true (default: `False`), then dict keys that are not of a basic type ([`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`int`](https://docs.python.org/3/library/functions.html#int "int"), [`float`](https://docs.python.org/3/library/functions.html#float "float"), [`bool`](https://docs.python.org/3/library/functions.html#bool "bool"), `None`) will be skipped instead of raising a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError").

The [`json`](https://docs.python.org/3/library/json.html#module-json "json: Encode and decode the JSON format.") module always produces [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") objects, not [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. Therefore, `fp.write()` must support [`str`](https://docs.python.org/3/library/stdtypes.html#str "str") input.

If *ensure\_ascii* is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If *ensure\_ascii* is false, these characters will be output as-is.
shrewd apex
#

json.dump(guilds, f, indent=4)

desert hatch
#

How would I go about adding my bot to the slash commands, and adding buttons for a soundboard?

shrewd apex
slate swan
#

got it all

simple niche
#

hello

#

can anyone help me with gateway events?

mighty yarrow
#

How to check Send Message permission of bot in my Discord Channel?

naive briar
#

!d discord.TextChannel.permissions_for

unkempt canyonBOT
#

permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role").

This function takes into consideration the following cases...
rare echo
slate swan
#

helping a friend start a discord bot but I forgot what I did to fix this problem. Created an venv and installed the imports on both venv and the main pc but the imports still wont read. restart did not work

#

pip install aiohttp?

naive briar
#

!pip aiohttp ๐Ÿˆ

unkempt canyonBOT
slate swan
#

it is installed on venv

#

and on pc

vale wing
#

Is venv selected

#

CTRL + SHIFT + P -> "Python: Select Interpreter"

slate swan
#

Im about to retry to interpreter part maybe did wrong

vale wing
#

What are you even trying to do

vale wing
slate swan
#

Helping my friend start venv for discord bot

#

I know how to do that part but maybe he did it wrong

vale wing
#

Open your project root and do what I said

slate swan
unkempt canyonBOT
#
Virtual Environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
slate swan
#

;-;

#

Yo sarth wassup

#

chemistry class

#

ahh sedge

vale wing
#

I am on unesco international forum

slate swan
#

Do it then

slate swan
#

bored

vale wing
#

Same actually

slate swan
#

You guys down to any project xd

#

Imma just bored

vale wing
#

I'll be back in a week and will probably be busy anyway

slate swan
#

;-;

vale wing
slate swan
#

yessir :]

#

I'd like to.

#

Ur bot verified? O.o

vale wing
#

Yea

vale wing
#

Yeah

slate swan
#

I am down on ur project after i finish my final xm ๐Ÿ’€

vale wing
slate swan
#

ahhh classic Disnake

#

Ah

vale wing
#

I am shortcuts fan

slate swan
vale wing
unkempt canyonBOT
#

utils/bot.py lines 134 to 142

def auto_setup(self, module_name: str):
    module = sys.modules[module_name]
    members = inspect.getmembers(
        module, lambda x: inspect.isclass(x) and issubclass(x, commands.Cog)
    )
    for member in members:
        self.add_cog(member[1](self))

    self.log.ok("%s loaded", module_name)```
slate swan
#

Who doesn't love shortcuts ๐Ÿคท

#

Cul

vale wing
#

Damn there's literal minister of culture of El Salvador speaking and I am here chatting ๐Ÿ’€

slate swan
#

xd

#

๐Ÿ—ฟ

vale wing
#

She spoke spanish anyway I didn't understand a thing

vale wing
#

K

slate swan
#

i notice typos, ded

vale wing
#

In your lib or in my bot?

slate swan
#

my lib

#

overriding here

vale wing
#

Ah yes overring

slate swan
#

it doesn't load the cogs, but setup calls in modules
kinda same approach tho

slate swan
#

Cool* teach me this hax ๐Ÿ—ฟ

slate swan
unkempt canyonBOT
#

wyvern/utils.py lines 47 to 57

@attrs.define
class Hook:
    """Hooks for per-module setup. They can be loaded using `โ€‹GatewayClient.load_hooks`โ€‹"""

    callback: typing.Callable[..., typing.Any]
    """Callback of the hook."""
    name: str
    """Name of the hook."""

    def __call__(self, *args: typing.Any, **kwargs: typing.Any) -> typing.Any:
        return self.callback(*args, **kwargs)```
slate swan
#

pros of using this is you can have more than one for each file

#
# module.py
from wyvern import Plugin
from wyvern.utils import hook
plugin = Plugin()

@hook(name="load")
def load():
   bot.add_plugin(Plugin())

@hook(name="unload")
def unload():
   bot.unload_plugin(Plugin()/Plugin/just the name of plugin)
``` ```py
# bot.py
import wyvern 

bot = wyvern.GatewayClient("token")

bot.load_hooks("module")
bot.hooks["load"]()

bot.run()
#

is how i plan to implement it

timid spade
#

my bot is getting rate limited by discord
any solution ?
i just made self roles and after selection 3 or 4 roles at once i get this message by the hosting website

slate swan
#

replit?

timid spade
#

is it issue with host?

slate swan
#

can be, cannot be

timid spade
#

also i wanna ask
is there any limitations on discord about bot checking if someone has a role
like if it checks for like 20 roles if user has them
will discord rate limit it?

slate swan
#

if its a cache operation, you shouldn't be facing any issue

slate swan
timid spade
slate swan
timid spade
slate swan
upbeat basalt
#

Hi, I have a bot with a functie. With an infinite loop in a try catch statement so every error gets caught en function gets called again, that works fine but sometimes the function just stops running(see picture) without giving an error, I have a global restockkk variable thatโ€™s set to true once the function starts running and set to false if an error is caught (in case the call in the catch fails) and on_ready checks if the restockkk value is false, if so it calls the function. But it stops without an error. How can I make something that checks if the infinite loop / function is still running?

#

As you can see it stopped at 9:08 without an error (I catch the errors and send them to the discord channel)

naive briar
unkempt canyonBOT
#

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

The default error handler provided by the client.

By default this logs to the library logger however it could be overridden to have a different implementation. Check [`on_error()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_error "discord.on_error") for more details.

Changed in version 2.0: `event_method` parameter is now positional-only and instead of writing to `sys.stderr` it logs instead.
vale wing
upbeat basalt
upbeat gust
upbeat basalt
vale wing
#

Btw about infinite loops

upbeat basalt
#

Not the bot itself

vale wing
#

In most of cases in dpy you can do then as background tasks

#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
upbeat gust
upbeat gust
upbeat basalt
#

And Iโ€™m not sure if i would be able to use with the way I use it

#

Every 2 minutes it scrapes a list of sites append something in a list and then compares them.

upbeat gust
upbeat gust
#

You can set it to run every 2 mins, then use mytask.start() and stop

upbeat basalt
#

Could you maybe help me if I canโ€™t figure it out?

#

Iโ€ll try it in half an hour when Iโ€™m home

upbeat basalt
upbeat basalt
upbeat gust
upbeat gust
vale wing
#

If your loop is in on_ready event it might get called several times and you will have several loops running at the same time for no reason

trim shadow
#

hello everyone

#
@commands.command()
    async def play(self, ctx: commands.Context, id: str):
        id = id.strip()

        if self.queue.get(ctx.guild.id) is None:
            self.queue[ctx.guild.id] = []

        song = self.api_zing.get_song_info(id)
        self.queue.get(ctx.guild.id).append(song)

        # check connect voice
        voice = await self.join(ctx)

        # check is playing
        if ctx.voice_client.is_playing():
            await ctx.send("ฤรฃ thรชm vร o hร ng chแป")
            return

        # play
        FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'option': '-vn'}
        voice.play(
            discord.FFmpegPCMAudio(
                executable="./asset/ffmpeg/ffmpeg.exe",
                source=self.api_zing.get_song_url(
                    self.queue[ctx.guild.id][0]["id"]),
                after=lambda e: asyncio.create_task(self.next_song(ctx))),**FFMPEG_OPTIONS)
        # volum
        voice.source = discord.PCMVolumeTransformer(voice.source)
        voice.source.volume = 1
        return

    async def next_song(self, ctx: commands.Context):
        if len(self.queue.get(ctx.guild.id)) > 0:
            voice = ctx.voice_client
            FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'option': '-vn'}
            voice.play(
                discord.FFmpegPCMAudio(
                    executable="./asset/ffmpeg/ffmpeg.exe",
                    source=self.api_zing.get_song_url(
                        self.queue[ctx.guild.id][0]["id"]),
                    after=lambda e: asyncio.create_task(self.next_song(ctx))),**FFMPEG_OPTIONS)
            voice.source = discord.PCMVolumeTransformer(voice.source)
            self.queue.get(ctx.guild.id).pop(0)
        else:
            await self.leave(ctx)
#
Exception ignored in: <function AudioSource.__del__ at 0x000001F718132E80>
Traceback (most recent call last):
  File "C:\Users\Admin\Desktop\Discord Music\.venv\Lib\site-packages\discord\player.py", line 117, in __del__
    self.cleanup()
  File "C:\Users\Admin\Desktop\Discord Music\.venv\Lib\site-packages\discord\player.py", line 225, in cleanup
    self._kill_process()
  File "C:\Users\Admin\Desktop\Discord Music\.venv\Lib\site-packages\discord\player.py", line 190, in _kill_process
    proc = self._process
           ^^^^^^^^^^^^^
AttributeError: 'FFmpegPCMAudio' object has no attribute '_process'
#

i can not play music

slate swan
#

@vale wing maybe u ?

slate swan
slate swan
#

Cool, didn't know about that ๐Ÿ’€

#

yes

#

Thx :]

slate swan
# slate swan yes

Do u know how to use setup_hook? It's like calls one time after every restart but on_ready calls several time, ig setting setup_hook is same as on_ready event?

slate swan
slate swan
#

on_ready?

slate swan
#

Ig so, not sure enough

#

well its meant to get called on every READY event

#

Btw is there anything like i can do if any gateway triggered like resume or warning then i can handle it?

#

hi , would this work ?

slate swan
slate swan
unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

slate swan
#

๐Ÿคท

naive briar
#

!d discord.Asset.save

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.
naive briar
#

!d discord.Member.avatar

unkempt canyonBOT
#

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

Cul

slate swan
timid spade
#

anyone know about a youtube channel or something to learn discord.py? ๐Ÿคก
or docs is the better way?

naive briar
slate swan
#

so how may i do it ?

slate swan
#

But i recommend "Civo", "Glowstik" and "Swastik"

trim shadow
#

hi anyone

slate swan
#

Civo is lik bit backdated, but he uses dpy v2

trim shadow
#

pls, can i help me

slate swan
timid spade
slate swan
slate swan
naive briar
#

You'll get used to it eventually

slate swan
timid spade
#

yep i am trying
took me 3 whole days just to make a drop dow menu command ๐Ÿคก

slate swan
#

Also u will not find all the stuff in a SINGLE video or a example site

vale wing
#

Why clown emoji

slate swan
#

Beside the docs

trim shadow
#

plsss

slate swan
timid spade
trim shadow
#

thank

slate swan
#

V2 is full of with new stuffs

#

U will not find any video covering this stuff xd

timid spade
#

well docs ftw ig ๐Ÿ—ฟ

slate swan
#

command is not define

slate swan
# slate swan

How it can be defined if udoesn't import it ? ๐Ÿคท

slate swan
#
from discord.ext import commands
naive briar
#

That's a thing?

slate swan
#

.ext

naive briar
#

Never seen that one before ngl

slate swan
#

Oh shut forgot

slate swan
#

idk i got distracted xd ๐Ÿ˜‚

#

!e

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval [python_version] <code, ...>
Can also use: e

Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

By default your code is run on Python's 3.11 beta release, to assist with testing. If you run into issues related to this Python version, you can request the bot to use Python 3.10 by specifying the python_version arg and setting it to 3.10.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!

trim shadow
#

hello, how to implement like this

naive briar
#

Slash commands

#

Look at the 3rd pin

trim shadow
naive briar
#

No

trim shadow
#

ok, thanks!

upbeat basalt
primal token
#

beautiful

full valley
#

how can I have the on_submit for a modal return the answer of a field to be used elsewhere

#

all these people just sending the responses in an embed, I just want to store the answer and use it elsewhere

#

this doesnt work

shrewd apex
#

instead of returning make the result an instance var of the class

#

then acess it through that coz i dont think its possible to return in on_submit

vale wing
upbeat basalt
vale wing
#

Also show restock() code

upbeat basalt
vale wing
#

Not a good idea

upbeat basalt
vale wing
#

Better would have used it in another tense