#discord-bots

1 messages · Page 769 of 1

leaden jasper
#

february or april?

slate swan
#

You mean the message content privileged intent?

leaden jasper
#

Yes

slate swan
#

That's April 2022.

leaden jasper
slate swan
#

No precise date, so can be anytime in April.

#

No, nothing else; maybe the new way to ask for user input or slash commands permission system.

potent spear
slate swan
#

Although I'd guess they're in very early stage so won't happen that soon, but you never know.

leaden jasper
#

So by then, we cant use command prefixes anymore?

#

and only use the / slash prefix

potent spear
#

on small bots, surely you will

slate swan
#

If you get access to the intent, yes you can.

#

Otherwise no. And the change only affects verified bots.

leaden jasper
#

Ok then there is no reason to use a library other than discord.py

slate swan
#

?

#

How would that matter?

leaden jasper
#

Since commands will still work

final iron
slate swan
potent spear
slate swan
#

It's the API of Discord and it doesn't matter which library you use.

final iron
slate swan
#

API wrappers have no influence on intents privileges.

slate swan
# leaden jasper is there something else happening

just that discord will make message intent privileged so if your bot is verified you must ask for the intent so the bot can check a messages content if not your bot cannot read a msg and thats why some verified bots use slash commands since their bot doesnt have the intent btw privileged intents only affect verified bots which people hate what will happen since getting intents is a trouble

leaden jasper
#

Ok thanks

potent spear
slate swan
#

yw

slate swan
#

Then you're good to go.

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

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

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

Which is much better than using some additional plugin inside.

potent spear
#

or are you just simply not able to install it on v1.7.3? idk

final iron
#

I think its finally time for me to subclass my help command

slate swan
#

Best of luck

final iron
#

So if I wanted to create the help command with drop down menus for the cogs would I have to hardcode that bit?

slate swan
#

No, you can get a list of cogs.

#

!d discord.ext.commands.Bot.cogs

unkempt canyonBOT
potent spear
#

preferably the loaded ones

slate swan
#

Then you can use walk_commands() etc. But I'd guess that's in the Gist tutorial.

final iron
#

I should probably actually make some commands with drop down menus before making my help command

#

totally not just stalling

potent spear
#

yeah, testing first, you don't hear it often

final iron
#

Any ideas for commands that would use them?

slate swan
rocky trench
#
@bot.event
async def on_member_join(member):
    welcomechannel = bot.get_channel(934556383033065523)
    embed = discord.Embed(colour=discord.Colour.blue())
    guild = bot.get_guild(934554396975575061)
    role = discord.utils.get(guild.roles, name="Member")
    req = PreparedRequest()
    req.prepare_url(
        url='https://api.xzusfin.repl.co/card?',
        params={
            'avatar': str(member.avatar.url.with_format("png")),
            'middle': 'welcome',
            'name': str(member.name),
            'bottom': str(f'Member #{guild.member_count}'),
            'text': '#CCCCCC',
            'avatarborder': '#CCCCCC',
            'avatarbackground': '#CCCCCC',
            'background': '#000000' #or image url
        }
    )
    embed.set_image(url=req.url)
    await welcomechannel.send(embed=embed)
    await member.add_roles(role)``` is someone able to tell me what is wrong in the code?
#

Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\bert\Downloads\discord bots\bertie's discord bots.py", line 44, in on_message_delete
await logs.send( embed=embed)
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1422, in send
data = await state.http.send_message(
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 335, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required

slate swan
#

** This field is required**

slate swan
#

In the on_message_delete event.

final iron
slate swan
final iron
#

among us api doesn't exist

#

😭

slate swan
#

make one😠

rocky trench
slate swan
#

Error says the opposite :)

rocky trench
#
@bot.event
async def on_message_delete(message):
    embed = discord.Embed(title="Message deleted from {}".format(message.author.name+'#'+message.author.discriminator),
                          description="", color=0x3498db)
    embed.add_field(name='**Deleted message:**', value=message.content,
                    inline=True)
    logs = bot.get_channel(934554464042487848)
    await logs.send(embed=embed)```
slate swan
#

And errors don't lie.

rocky trench
#

is it the description part?

slate swan
#

The field value=message.content is empty when you delete images and embeds.

slate swan
#

So make sure to handle that correctly.

rocky trench
#

ah thats the reason

#

how would I handle that error?

slate swan
#

Well, check the value of message.content when you delete an image.

rocky trench
#

I see

slate swan
#

Debug it; print the value and try it out.

#

Then you know what check to add to not get the same issue.

#

And instead of doing .name and .discriminator you can just do ctx.author.

#

It will return the same.

rocky trench
#

yh ik

#

handled the error, now this: AttributeError: 'NoneType' object has no attribute 'send'

#

await welcomechannel.send(embed=embed)

#

welcomechannel = bot.get_channel(924753718895865917)

slate swan
#

Well you need to get the channel before trying to send a message.

rocky trench
#

Its before it

#

just didnt send it in the right order

slate swan
#

Then you need to use

channel = ...get_channel(id) or await ...fetch_channel(id)
final iron
#

Yall got any idea of commands I can create that use dropdown menus?

#

I want to learn how to use them before I create a help command

slate swan
#

You need to make an API call when the channel is not in cache, therefore the or ...fetch_channel(id)

slate swan
rocky trench
#

but like

#

I use the same type of code in my log parts and they do work

slate swan
#

It basically tries get_channel and if it returns None, which is your case, then it tries fetch_channel.

rocky trench
#

well the channel isnt None...

slate swan
rocky trench
#

uh

slate swan
rocky trench
#

it isnt Nonetype

slate swan
#

!e
print(type(None))

unkempt canyonBOT
#

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

<class 'NoneType'>
rocky trench
#

so why doesnt the other one work

slate swan
#

As I said.

#

It's in cache..

rocky trench
#

not sure what cache is...

slate swan
#

So when it won't be in cache anymore, it also won't work.

slate swan
rocky trench
#

I see

slate swan
#

If it's not in that memory, then it's None.

rocky trench
#

so is there a way to bypass that

slate swan
#

Therefore you need to fetch it from the API.

rocky trench
#

alr

rocky trench
#

I see

#

await bot.fetch_channel(id)

#

right?

slate swan
#

It will first try from the cache, then use fetch_channel.

slate swan
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
slate swan
#

You shouldn't always make API calls so you need to check the cache first.

rocky trench
#

thanks for the help, it works now!

slate swan
#

So let's suppose get_channel returns None, it will be like that.

rocky trench
#

yeahhh

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

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

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

!e
channel = None or 12345566
print(channel)

unkempt canyonBOT
#

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

12345566
rocky trench
slate swan
#

That's bascially how it looks.

rocky trench
#

like how do I make smthng like that? if welcomechannel == None?

slate swan
#

None would be the return of get_channel.

#

use is and not operators

#

You don't need to do any check here since fetch_channel will always return a channel.

rocky trench
#

yh I'm using fetch atm

slate swan
rocky trench
#

but not cache anymore

rocky trench
rocky trench
#

ah that way

slate swan
#

The entire line is meant to be used.

slate swan
#

Not option 1 or option 2

#

wait

#

Yeah you need to set what you need.

#

i think theirs no getch for channels?

#

nothing

#

Yeah just member and user if I remember correctly.

#

Should be added for channels though..

#

yes

#

Back at working I go

#

gl

#

I need help with select Menu

#

Im trying to make it reply

#
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle

class Command(commands.Cog):
    def __init__(self, Client):
        self.bot = Client 
        
    @commands.command()
    async def test(self, ctx):
        print("ok")
        await ctx.send(f'test', components=[Select(placeholder="Test", options=[
            SelectOption(
                label="Test",
                value="test",
                description="e",
                emoji="😂"
            )
        ])])

def setup(Client):
    Client.add_cog(Command(Client))```
potent spear
slate swan
#

Im failing horribly

final iron
#

Anyone got any ideas for commands that use dropdown menus? I want to learn how to use them before I actually make my help command

slate swan
slim ibex
#

select event?

#

do you just want an event listener

dry kelp
#

is there a way to make a "pagination" help menu in d.py v2?

slate swan
slim ibex
unkempt canyonBOT
#

class discord.ext.commands.Paginator(prefix='```', suffix='```', max_size=2000, linesep='\n')```
A class that aids in paginating code blocks for Discord messages.

len(x) Returns the total number of characters in the paginator.
slim ibex
dry kelp
#

huh

#

dude what

#

im talking ab this but w buttons

#

LOL

slim ibex
#

yes that’s what pagination is

dry kelp
#

ik

#

i switched to d.py 2.0 and it's weird af

slim ibex
#

Don’t use dpy

dry kelp
#

what else should i use?

slate swan
#
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle

class Command(commands.Cog):
    def __init__(self, Client):
        self.bot = Client 
        
    @commands.command()
    async def Menu(self, ctx):
        print("ok")
        await ctx.send(f'test', components=[Select(placeholder="Test", options=[
            SelectOption(
                label="Test",
                value="test",
                description="e",
                emoji="😂"
            )
        ])])

    @commands.Cog.listener.on_select_option
    async def Event(Interaction):
        print(Interaction.values[0])

def setup(Client):
    Client.add_cog(Command(Client))``` ?
slim ibex
#

Nextcord or some other fork

#

or even a non fork like Hikari or Pincer

#

dpy doesn’t have any new features

dry kelp
#

ok so let's say

slim ibex
dry kelp
#

what nextcord has "new" ?

slim ibex
#

views, buttons, slash commands (soon), application commands (context menus, slash commands, etc)

dry kelp
slim ibex
#

prolly a few more things too

dry kelp
#

it has buttons, views... slash commands..

slim ibex
#

No not without using an external lib

dry kelp
#

yeah but u can still do the same shit

slim ibex
#

Not really

dry kelp
#

i will wait till nextcord will bring some new features that actually can provide smth for the bot

velvet tinsel
#

!pypi disnake

unkempt canyonBOT
dry kelp
#

rn i will keep using d.py v2

velvet tinsel
#

use disnake it's better

slim ibex
#

bro said nextcord has to prove something

dry kelp
slim ibex
#

all these wrappers are already better than dpy

#

oh my fault

#

I’m blind

dry kelp
#

all g

#

alr back to my question

#

can u send me an pagination example made in discord.py v2?

#

or even nextcord cuz i know the code is similiar

#

similar

#

so i can convert it

rocky trench
slim ibex
#

Welcome back to another discord.py video.

Read description for links!

----------------------------------------­­---------------------------------------­-­--

Need Help?
Require help with your code? Why not head on over to our dedicated support discord where you can receive only the best support: https://menudocs.link/discord

Our Partner:
Than...

▶ Play video
slate swan
slim ibex
#

that will show an example

dry kelp
#

thanks a lot

slim ibex
#

mhmm

dry kelp
#

awesome

rocky trench
#

or also log person who deleted the message

slim ibex
#

!d discord.Message.delete

#

wait

slim ibex
#

wrong one

rocky trench
#

Like this in audit log

slim ibex
#

!d discord.on_message_delete

slate swan
#

You'd need to check the audit logs in that case.

#

You can't see who deleted the message without looking at the audit logs.

rocky trench
#

I see...

slate swan
slim ibex
#

k

rocky trench
#

So how can I make a bot check logs?

dry kelp
slim ibex
#

you have to install it

dry kelp
#

what's the pip name

slim ibex
#

oh wait

dry kelp
slim ibex
#

pip install buttons

dry kelp
#

thanks a lot

slim ibex
#

mhmm

dry kelp
#

THERE'S NO FUCKING WAY

#

IM THAT DUMB

rocky trench
#

@slate swan any news?

dry kelp
#

i had to watch the video like 2 more seconds

#

😂

#

cuz he even said that pip name bruh

slate swan
slate swan
slim ibex
#

how did you create the bot

slate swan
#

!d discord.Guild.audit_logs

unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guild’s audit logs.

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

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print(f'{entry.user} did {entry.action} to {entry.target}')
```...
slate swan
#
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle

class Command(commands.Cog):
    def __init__(self, Client):
        self.bot = Client 
        
    @commands.command()
    async def Menu(self, ctx):
        print("ok")
        await ctx.send(f'test', components=[Select(placeholder="Test", options=[
            SelectOption(
                label="Test",
                value="test",
                description="r",
                emoji="😂"
            )
        ])])

    @commands.Cog.listener()
    async def on_select_option(Interaction):
        print(Interaction.values[0])

def setup(Client):
    Client.add_cog(Command(Client))``` I tried this but it didnt work and theres no errors
slim ibex
#

how do you create the bot

slate swan
#

Wdym

slim ibex
#

client in this context means nothing

#

it doesn't connect to the bot

slate swan
#

Oh

#

Wth it wasnt working before when I removed it

slate swan
slim ibex
#

what is the code where you instantiate the bot like bot = commands.Bot() etc

slate swan
#

Conventions?

#

Variables not with capital letters and same for functions.

slim ibex
#

^

slate swan
#

So not

async def Menu(...)

but

async def menu(...)
#

Kk ill make sure to avoid that

#

Coding conventions that you should definitely follow.

#

But any idea why it wont work?

slim ibex
#

i told you

#

show me the code where you instantiate the bot

#

client in the way you used it is a random argument that does nothing

slate swan
#

The self.bot

slim ibex
#

show me the code where you instantiate the bot

slate swan
#

kk

#

import Data, os, sys, discord, asyncio
from discord.ext import commands
from colorama import Fore, Back, Style
from discord.ext.commands import CommandNotFound, MissingPermissions
from os import system

sys.dont_write_bytecode = True
os.system("mode con cols=120 lines=30")
system("title "+ "River Client")

Intents = discord.Intents.default()

Bot = commands.Bot(
    command_prefix = Data.Info.Prefix,
    intents = Intents,
    case_insensitive = True,
    description = "River Bot"
)

ReSizing = True
Indent = "                              "

Bot.remove_command("help")

class DirClasses:
    Admin = "Commands/Admin"

def LoadCommands(Dir, DirName):
    for Function in os.listdir(f"./{Dir}"):
        try:
            if Function.endswith(".py"):
                FileName = Function[:-3]
                try:
                    Bot.load_extension(f"Commands.{DirName}.{FileName}")
                except Exception as Error:
                    Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")
                
                Name = Function.replace(f".py", "")
        except Exception as Error:
            Name = Function.replace(f".py", "")
            Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Name}.py{Fore.WHITE}]")
            Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")

@Bot.event
async def on_ready():
    Data.Function.Print(f"Ascend Satus > [{Fore.BLUE}Success{Fore.WHITE}]")
    Data.Function.Print(f"Client User  > [{Fore.BLUE}{Bot.user.name}#{Bot.user.discriminator}{Fore.WHITE}]")
    Data.Function.Print(f"Client ID    > [{Fore.BLUE}{Bot.user.id}{Fore.WHITE}]")

    LoadCommands(DirClasses.Admin, "Admin")

    Data.Function.Print(f"Loaded       > [{Fore.BLUE}Commands{Fore.WHITE}]")
        
@Bot.event
async def on_command_error(ctx, Error):
    if isinstance(Error, CommandNotFound):
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}Command{Fore.WHITE}]")
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")
    elif isinstance(Error, MissingPermissions):
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}Command{Fore.WHITE} (Permissions)]")
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")
        
        await ctx.message.channel.send("You do not have Permissions to run this command.", delete_after = 15)

Bot.run(Data.Info.Token)```
slim ibex
#

bot = commands.Bot

#

replace all Bot with lowercase bot

slate swan
#

kk

#

You definitely need to rename everything here..

rocky trench
#

Ipay, I made some things

#
@bot.event
async def on_message_delete(message):
    guild = message.guild
    async for entry in guild.audit_logs(limit=1):
        print(f'{entry.user} did {entry.action} to {entry.target}')
        if entry.user.id is bot.user.id:
            return
        else:
            if message.content == None:
                return
            else:
                embed = discord.Embed(title="Message deleted from {}".format(message.author.name+'#'+message.author.discriminator),
                                    description="", color=0x3498db)
                embed.add_field(name='**Deleted message:**', value=message.content,
                                inline=True)
                logs = bot.get_channel(934554464042487848)
                await logs.send(embed=embed)```
slate swan
#

Done

#

You should never use uppercase on variables or functions, only classes.

rocky trench
#

But it still logs the !rules it deletes

slim ibex
#

now

#

in the cog

slate swan
#

import Data, os, sys, discord, asyncio
from discord.ext import commands
from colorama import Fore, Back, Style
from discord.ext.commands import CommandNotFound, MissingPermissions
from os import system

sys.dont_write_bytecode = True
os.system("mode con cols=120 lines=30")
system("title "+ "River Client")

Intents = discord.Intents.default()

bot = commands.Bot(
    command_prefix = Data.Info.Prefix,
    intents = Intents,
    case_insensitive = True,
    description = "River bot"
)

bot.remove_command("help")

class DirClasses:
    Admin = "Commands/Admin"

def loadCommands(Dir, DirName):
    for Function in os.listdir(f"./{Dir}"):
        try:
            if Function.endswith(".py"):
                FileName = Function[:-3]
                try:
                    bot.load_extension(f"Commands.{DirName}.{FileName}")
                except Exception as Error:
                    Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")
                
                Name = Function.replace(f".py", "")
        except Exception as Error:
            Name = Function.replace(f".py", "")
            Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Name}.py{Fore.WHITE}]")
            Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")

@bot.event
async def on_ready():
    Data.Function.Print(f"Ascend Satus > [{Fore.BLUE}Success{Fore.WHITE}]")
    Data.Function.Print(f"Client User  > [{Fore.BLUE}{bot.user.name}#{bot.user.discriminator}{Fore.WHITE}]")
    Data.Function.Print(f"Client ID    > [{Fore.BLUE}{bot.user.id}{Fore.WHITE}]")

    loadCommands(DirClasses.Admin, "Admin")

    Data.Function.Print(f"Loaded       > [{Fore.BLUE}Commands{Fore.WHITE}]")
        
@bot.event
async def on_command_error(ctx, Error):
    if isinstance(Error, CommandNotFound):
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}Command{Fore.WHITE}]")
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")
    elif isinstance(Error, MissingPermissions):
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}Command{Fore.WHITE} (Permissions)]")
        Data.Function.ErrorPrint(f"Failed       > [{Fore.BLUE}{Error}{Fore.WHITE}]")
        
        await ctx.message.channel.send("You do not have Permissions to run this command.", delete_after = 15)

bot.run(Data.Info.Token)```
slim ibex
#

do

#
def __init__(self, bot):
  self.bot = bot
slate swan
slim ibex
#
def setup(bot):
  bot.add_cog(CogName(bot))
slate swan
#

kk

slate swan
#

done

#
if entry.user.bot:
    # Bot did an action
rocky trench
#

ooh

#

ty

slate swan
rocky trench
#

but I feel like this doesnt work

slate swan
rocky trench
#

bc in audit log, it says I deleted a msg from the bot

#

@slate swan

slate swan
#

What is the audit log?

slate swan
#

Oh you deleted a message

rocky trench
#

await ctx.message.delete()

#

is what the bot does

#

but it says in audit log that I did it

slate swan
#

lol that's not possible.

#

Are you sure it's that message?

#

Because it's not really possible.

rocky trench
slate swan
#

check again, the time probably doesn't line up

#

@slate swan Do you know how to check for select option event?

#

Library?

#

Been trying

#

That

#

What library are you using.

#

Oh

rocky trench
#

alright

#
@bot.command()
async def delete(ctx):
    await ctx.message.delete()```
#

made this, so bot should delete it right?

slate swan
slate swan
#

Now make it delete and compare the time now and in audit log.

stoic galleon
#

wait nvm

rocky trench
slate swan
#

Oh 😅

rocky trench
#

yk the no message.content

#
@bot.event
async def on_message_delete(message):
    guild = message.guild
    async for entry in guild.audit_logs(limit=1):
        print(f'{entry.user} did {entry.action} to {entry.target}')
        if entry.user.bot:
            return
        else:
            if message.content == None:
                return
            else:
                embed = discord.Embed(title=f"Message deleted from {message.author} by {entry.user}",
                                    description="", color=0x3498db)
                embed.add_field(name='**Deleted message:**', value=message.content,
                                inline=True)
                logs = bot.get_channel(934554464042487848)
                await logs.send(embed=embed)```
#

Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\bert\Downloads\discord bots\bertie's discord bots.py", line 53, in on_message_delete
await logs.send(embed=embed)
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1422, in send
data = await state.http.send_message(
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 335, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields.0.value: This field is required

#

@slate swan sorry for ping, just wanna make sure u here :)

slate swan
#

Replace == with is

rocky trench
#

ok

slate swan
#

I tried the github you sent

#

Didnt work

rocky trench
#

@slate swan It still logs messages the bot deletes

stoic galleon
#

how do i geri n discord py v2?

slate swan
slate swan
slate swan
#

I checked it and tried to implement how it worked into my code

stoic galleon
slate swan
#

Installing the development version
Or something similar

slate swan
#

But I had trouble because the way it did the menu is different from me

rocky trench
dry kelp
#

@slim ibex 😭

#

w buttons not reactions 😂

slate swan
dry kelp
#

i spent this entire time for reactions 😂

rocky trench
#

but it does add it to logs

#

if the bot deletes smthng it doesnt show up in audit log

#
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
Bertie#0001 did AuditLogAction.message_delete to Bertie's bot#5320
#

this is the print

slate swan
#

Well apparently it doesn't log in audit logs 😅

#

Never really worked with audit logs so I can't really help.

#

But seems like it doesn't even save on Discord's side.

#

Otherwise it would show up.

rocky trench
#

I found a fix on it

#

the log is like the opposite way

#

added

#
        if entry.target.bot:
            return```
slate swan
rocky trench
#

now it works fine

#

thanks for the help :)

#

I've been wasting a lot of ur time

slate swan
#

Oh okay, interesting though

rocky trench
#

might be usefull one day

slate swan
#

Docs says opposite but yeah

slate swan
rocky trench
#

alright, now on_member_update

#

how would I get the roles out of that

slate swan
#

after.roles and before.roles

#

Returns a list of roles objects

#

Won't be able to help further for now, I really need to work ^^ But I'm sure someone else will be here soon and take over :)

#

Have a great one KryptonBlanket

keen magnet
#

hello i wanna do something but i don't know the syntax i did a xp bot and if a player send a message which start with . it will remove him 5 xp but i don't know how can i do that

#

i know there is something like startwith() but i don't know it's working

#

i want to do something like
if startwith("."):
xp = stats["xp"] - 5

#

but obviously that not working

slate swan
#
await ctx.send(f'test', components=[Select(placeholder="Test", options=[
            SelectOption(
                label="Test",
                value="test",
                description="eee",
                emoji="😂"
            )
        ], custom_id = "trolled")])
        
        while True:
            try:
                Interaction = await self.bot.wait_for("select_opition", check = lambda inter: inter.custom_id == "trolled" and inter.user == ctx.author)
                Res = Interaction.values[0]

                print(Res)
            except Exception as Error:
                await ctx.send(Error)``` Does anyone know specifically why this code doesnt work?
slate swan
#

?

rocky trench
#

@slate swan py @bot.event async def on_member_update(before, after): guild = await bot.fetch_guild(934554396975575061) if len(before.roles) < len(after.roles): async for entry in guild.audit_logs(limit=1): print(f'{entry.user} did {entry.action} to {entry.target}') # The user has gained a new role, so lets find out which one newRole = next(role for role in after.roles if role not in before.roles) print(f'{entry.user} added the role {newRole} to {entry.target}') logs = bot.get_channel(934554464042487848) await logs.send(f'{entry.user} added the role \'{newRole}\' to {entry.target}') if len(before.roles) > len(after.roles): async for entry in guild.audit_logs(limit=1): print(f'{entry.user} did {entry.action} to {entry.target}') oldRole = next(role for role in before.roles if role not in after.roles) await logs.send(f'{entry.user} removed the role \'{oldRole}\' from {entry.target}')

#

got it working :D

final iron
slate swan
#

What

final iron
#

What

slate swan
#

@slate swan Do you know any discordpy forks for select menues without having to make a new command handler

keen magnet
#
    @commands.Cog.listener()
    async def on_message(ctx, *, message):
        stats = Levels.find_one({"id":message.author.id}) 
        if (message.startwith(".")):
            xp = stats["xp"] - 5```
#

can someone help me pls

#

that not working i know it's because of the if (message.startwith(".")):

#

but i don't know how to fix it so it can works

slate swan
final iron
slate swan
#

and what is that if statement no need for the extra ()

keen magnet
slate swan
#

Anything wrong with this code?

Interaction = await self.bot.wait_for("select_opition", check = lambda inter: inter.custom_id == "trolled" and inter.user == ctx.author)
Res = Interaction.values[0]```
final iron
keen magnet
#

you said i could use check

#

but how

#

i never used this to do that so i don't know it's working

cedar stream
#

||docs||

final iron
#

Lemme see if I know what I'm doing

slate swan
final iron
#

!d discord.ext.commands.Bot.add_check

unkempt canyonBOT
#

add_check(func, *, call_once=False)```
Adds a global check to the bot.

This is the non-decorator interface to [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check "discord.ext.commands.Bot.check") and [`check_once()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.check_once "discord.ext.commands.Bot.check_once").
final iron
#

Oh shit

slate swan
#

its a global check

final iron
#

I actually remembered

slate swan
#

lollll

cedar stream
final iron
slate swan
slate swan
final iron
keen magnet
#

i want something that will check if someone type .

final iron
#

If they have a . at the start of a message?

keen magnet
#

at the start of the message

slate swan
keen magnet
#

yes

keen magnet
#

i know i need to use the *

cedar stream
keen magnet
#

i did already

slate swan
cedar stream
slate swan
cedar stream
keen magnet
slate swan
#

No

cedar stream
slate swan
keen magnet
#

i wanna learn with bots because it's easier for me but yeah im doing basics too at school

slate swan
#
import random, Data, discord
from discord.ext import commands
from discord_components import DiscordComponents, Select, SelectOption, Button,ButtonStyle

class Command(commands.Cog):
    def __init__(self, Client):
        self.bot = Client 

    @commands.command()
    async def Menu(self, ctx):
        await ctx.send(f'test', components=[Select(placeholder="Test", options=[
            SelectOption(
                label="Test",
                value="test",
                description="eee",
                emoji="😂"
            )
        ], custom_id = "trolled")])
        
        while True:
            try:
                Interaction = await self.bot.wait_for("select_opition", check = lambda inter: inter.custom_id == "trolled" and inter.user == ctx.author)
                Res = Interaction.values[0]

                await Interaction.send(Res)
            except Exception as Error:
                await ctx.send(Error)
def setup(Client):
    Client.add_cog(Command(Client))```
cedar stream
slate swan
#

Whats pep8

slate swan
unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

slate swan
#

indeed

cedar stream
slate swan
#

Ohh that

#

the imports and kwargs are killing me

cedar stream
slate swan
#

Im gonna fix the capital stuff after I figure respond thing

#

bro those naming conventions are horrible

#

Client capital did you subclassed the bot class?

#

cause classes should and only be capital not functions or class instances

cedar stream
#

Why are class instances named using pascal case

slate swan
#

and dont name functions capital only classes smh PEP8

keen magnet
slate swan
#

Got damn I get it but my main focus right now is the respond issue

slate swan
keen magnet
#
    @commands.Cog.listener()
    async def on_message(message) -> None:
        stats = Levels.find_one({"id":message.author.id}) 
        if message.startswith("."):
            xp = stats["xp"] - 5```


my error is : ```TypeError: levelsys.on_message() takes 1 positional argument but 2 were given```
cedar stream
slate swan
cedar stream
slate swan
cedar stream
slate swan
#

Docs or examples?

flat shoal
#

Hi there, sry for chat interruption.

I was asked to make an "intro-timer" feature on a discord server, so that a member can see the other rooms after "N" time

So I was wondering if any bot already does this function, because I checked the documentation and saw that it is possible to get the "joined_at" that shows the time a member enters a guild.

Does anyone know which bot does this?

cedar stream
slate swan
keen magnet
flat shoal
#

Maybe a role that its removed after X time

final iron
flat shoal
#

or, a role that is given after that time

slate swan
cedar stream
flat shoal
slate swan
slate swan
cedar stream
# flat shoal what you mean by that

In on join store a timestamp when the role should be removed, then have a task that periodically checks for every new member if the current time is greater then the timestamp u stored

#

If current time is greater remove the role

sick birch
slate swan
flat shoal
#

I mean, im intersting in doing a bot with the function later on the year, but right now Im wondering if there is some that does it, so I could use it. @cedar stream

flat shoal
#

I see, thanks for the help

cedar stream
#

Good luck

cedar stream
sick birch
#

The nerve!

cedar stream
#

Fr

#

How could they

slate swan
pliant gulch
#

Imagine in 6 more months, forks being forked

#

👁️ 👁️

cedar stream
#

Lmfao

cedar stream
#

Imagine having the audacity to clone dpy code

#

Ight @pliant gulch

pliant gulch
#

what

cedar stream
#

😂

#

I’ m jk

slate swan
#

andy is funny ngl

pliant gulch
#

Actually you can't say my wrapper is a dpy clone anymore!

#

Cause I archived it and started working on a new one

slate swan
#

one day forks will be forked and those forks will be forked🧍‍♂️

cedar stream
#

It aint?

pliant gulch
cedar stream
#

Thats cool

pliant gulch
#

Okimi I gave up doing the listener rewrite cause I got to lazy

cedar stream
#

So no more lefi?

pliant gulch
#

Yes it's Rin now

pliant gulch
#

I cba

#

I'll write classes tonight then add application commands

final iron
#

Any ideas how I can implement dropdown menus in to my bot?

slate swan
#

we need the rewrite

cedar stream
#

Why did u archive it

final iron
#

I want to learn them before I create a help command

pliant gulch
#

Cause lefi was not very well typed and I didn't like how close it was to discord.py

#

So now we have Rin

slate swan
cedar stream
slate swan
final iron
cedar stream
cedar stream
slate swan
#

andy dont click

final iron
#

Not a help command

cedar stream
cedar stream
slate swan
#

😭

cedar stream
#

Lmao

slate swan
#

dekriel

velvet tinsel
#

what

slate swan
#

you monster 😭

velvet tinsel
#

look here

#

does it look like i give a shit

slate swan
#

🧑‍🦯

velvet tinsel
#

exactly

slate swan
unkempt canyonBOT
slate swan
velvet tinsel
slate swan
velvet tinsel
#

haha

slate swan
velvet tinsel
slate swan
#

i did

velvet tinsel
#

ok

cedar stream
#

Lmao

slate swan
velvet tinsel
#

look here mf

cedar stream
#

!ot

slate swan
#

hehe

velvet tinsel
#

!ot-names @cedar stream

unkempt canyonBOT
slate swan
calm steeple
#

discord.js or discord.py? you guys might be a little biased though haha

velvet tinsel
#

get your commands right

cedar stream
slate swan
#

🤸

cedar stream
#

Have u ever tried js

calm steeple
#

lol

slate swan
#

discord.rb > anything

#

🧑‍🦯

velvet tinsel
calm steeple
#

I like javascript better than python but only have experience with discord.py

slate swan
cedar stream
cedar stream
slate swan
#

you guys lmaooo

velvet tinsel
velvet tinsel
cedar stream
pliant gulch
# cedar stream Nicee, dpy has a nice api tho

Yea, but rin's current implementation is quite the refresher, E.g ```py
async def main() -> None:
token: str = os.getenv("DISCORD_TOKEN") # type: ignore
client = rin.GatewayClient(token, intents=rin.Intents.default())

@client.once(rin.Event.READY)
async def on_ready(user: rin.User) -> None:
    print(f"LOGGED IN AS: [{user.id}]")

await client.start()

asyncio.run(main())

slate swan
#

in discord rb you need to use a bare endpoint to add a reaction lmaooo

cedar stream
slate swan
pliant gulch
#

The internal structure itself and the codebase is extremely clean as well now!

#

Way better then the predecessor

velvet tinsel
pliant gulch
#

Which is mostly my main reason for the rewrite

slate swan
sacred sigil
#

how would I use Guild.invites?

#

does it show per person or the entire guild?

velvet tinsel
#

also @slate swan how's your twitter thing coming along

cedar stream
slate swan
pliant gulch
#

👁️ 👁️

velvet tinsel
slate swan
#

maybe i should make the async bridge of it

slate swan
#

ive just gotten stuck on a error i have with sphinx so i cant make docs to learn rip

pliant gulch
cedar stream
velvet tinsel
slate swan
#

😭

velvet tinsel
#

cat superior

slate swan
#

you trying to get muted or something😭

velvet tinsel
#

if I get muted it'd be like 3 days

#

or 4

final iron
#

I'm bored out of my tree

slate swan
#

LMAO

final iron
#

Anyone got any commands I can steal

velvet tinsel
slate swan
final iron
cedar stream
cedar stream
#

Rip walter

velvet tinsel
velvet tinsel
slate swan
# final iron For what commands though

make a wallpaper getter which sends an image with a button which you can change to it with buttons and it will edit the embed with a new image when one of the buttons is press so forward and back

slate swan
sacred sigil
#

@cedar stream does it show per person or per guild

velvet tinsel
#
@bot.event
async def on_message(message):
  if message.author.id == 802098197244674068:
    await message.delete()
    await ban(message.author, reason="dawg")
cedar stream
velvet tinsel
sacred sigil
#

0 social life i can tell

velvet tinsel
#

step 2: mf you're dead

sacred sigil
#

now back to my question, how would I check the amount of invites per person

cedar stream
#

What do u think

cedar stream
unkempt canyonBOT
#

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

Returns a list of all active instant invites from the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to get this information.
velvet tinsel
#

it gives you everything you need to know

cedar stream
#

!d discord.Invite

unkempt canyonBOT
#

class discord.Invite```
Represents a Discord [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") or [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") invite.

Depending on the way this object was created, some of the attributes can have a value of `None`.

x == y Checks if two invites are equal.

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

hash(x) Returns the invite hash.

str(x) Returns the invite URL...
velvet tinsel
sick birch
#

👋

velvet tinsel
#

I just won a match in ranked

#

ez

sick birch
#

progamer moment

slate swan
#

robin we should play

velvet tinsel
#

we should find a time where we all play

sick birch
#

that would be nice

slate swan
#

i get like 28 kills every match

velvet tinsel
#

since I have robin and okimii

velvet tinsel
sick birch
#

i get 5

slate swan
velvet tinsel
#

I get 30 kills per match and thats my lowest

velvet tinsel
cedar stream
velvet tinsel
#

I become amazing near the end of the game

velvet tinsel
#

@slate swan @sick birch should we make a gc

slate swan
sick birch
velvet tinsel
sick birch
velvet tinsel
slate swan
#

i cant

sick birch
#

we can coordinate these somewhere else

slate swan
#

i got school :((

velvet tinsel
#

I'll make a gc, is that ok with you?

sick birch
#

let's keep it on topic 😂

#

yeah sure

velvet tinsel
slate swan
sacred sigil
#

I get this error:

gif_channel = discord.utils.get(message.guild.channels, id=928014494142197820)
AttributeError: 'NoneType' object has no attribute 'channels'

For this:

@bot.event
async def on_message(message):
    gif_channel = discord.utils.get(message.guild.channels, id=928014494142197820)
    icon_channel = discord.utils.get(message.guild.channels, id=928014556926738433)
    for attachment in message.attachments:
        if attachment.filename.split(".")[1] == "gif":
            gif_embed = Embed(color=0x0f0f0f)
            gif_embed.set_image(url=attachment.url)
            await gif_channel.send(embed=gif_embed)
        elif attachment.filename.split(".")[1] in ["jpg", "jpeg", "png"]:
            icon_embed = Embed(color=0x0f0f0f)
            icon_embed.set_image(url=attachment.url)
            await icon_channel.send(embed=icon_embed)
    await bot.process_commands(message)
visual yarrow
slate swan
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
velvet tinsel
cedar stream
slate swan
velvet tinsel
velvet tinsel
#

im showing appreciation

slate swan
#

good child

sacred sigil
velvet tinsel
cedar stream
sacred sigil
#
    gif_channel = discord.utils.get(message.channel, id=928014494142197820)
    icon_channel = discord.utils.get(message.channel, id=928014556926738433)
cedar stream
#

velvet tinsel
#

🤦‍♂️

#

I'm gonna

cedar stream
#

@velvet tinsel ill leave this one to u

#

Gn

slate swan
#

🚪🏃 💨

velvet tinsel
#

it's midnight here you cant do that

sacred sigil
#

yk you don't have to be this vague, you could've said, "instead of using discord.utils.get() use message.channel()"

#

crazy how you're "support" lool

cedar stream
#

It’ s an attribute

#

Not a function

#

It’ s an instance of discord.GuildChannel

velvet tinsel
sacred sigil
#
    gif_channel = message.channel(id=928014494142197820)
    icon_channel = message.channel(id=928014556926738433)
velvet tinsel
#

we're not the helpers

#

we just pop in time to time

sacred sigil
#

if you're going to help someone, at least tell them what's wrong so they could learn from their mistakes

final iron
#

I would have to agree with ^

#

You guys are currently being pretty rude

velvet tinsel
#

it's midnight

always rude at midnight then I'm nice in the morning

final iron
#

If you know you're going to be rude then go to sleep

velvet tinsel
#

ok

#

fuck I should sleep

slate swan
#

yes

velvet tinsel
#

00:00

#

lovely

slate swan
#

lollll

final iron
#

So should I have a checkmark button, a next button and a x button?

#

I'm not going to have a backwards button because I'm just going to be requesting an api

visual yarrow
#

Unsplash has an API.

#

Might be a good place to get the wallpapers.

final iron
#

I already found one but I'll check it out

pliant gulch
#

You can also query r/wallpapers on reddit as well

#

They got some good wallpapers over there

visual yarrow
#

Maybe have a drop-down to select the kind of wallpaper (desktop, phone, etc.)? 🤔

raw latch
#

How can I make the bot listen a dropdown from a message for a long time? After some minutes I'm getting This Interaction failed when trying to select from dropdown and the bot have to resend that message(with dropdown) so I can use it. Any idea?

slate swan
final iron
#

Also same thing for desktop

visual yarrow
final iron
#

True

visual yarrow
final iron
#

This api allows me to choose the image size

#

So I'll do 1920 by 1080 for desktop

#

But mobile will be a bit harder to figure out what to do

raw latch
visual yarrow
frank tartan
#

lets say I have a list called myList. It has an unknown amount of discord users in it. Example: @frank tartan
How can I search the roles of every user on the list?
I hope that makes sense

raw latch
final iron
frank tartan
final iron
#

Why not append the member object?

frank tartan
raw latch
visual yarrow
#

Then what would you like to do with the roles?

#

Member objects have a roles attribute, which is just a list of the roles the member has.

raw latch
frank tartan
frank tartan
visual yarrow
visual yarrow
frank tartan
visual yarrow
#

A set is like a list, but the values contained within are unique and not in any particular order.

frank tartan
visual yarrow
#

Although the values have to be hashable (which discord.Member objects appear to be).

#

Yeah similar.

#

Think of like a dictionary but with only the keys, no values.

visual yarrow
#

But say you have a set of values xs = {1, 2, 3, 4}, and another set of values ys = {3, 4, 5}, and you want to remove all values from xs that happen to also be in ys, you can do: ```py
xs -= ys

#

And lots of other nifty things.

#

The result in this case will be that xs == {1, 2}

slate swan
visual yarrow
slate swan
#

Oh yeah

#

Me dumb dumb, ty

#

Best of Luck, LX lmao

visual yarrow
#

Erm, sorry @raw latch which API wrapper are you using?

final iron
#

Didn't danny shit on pycord?

visual yarrow
#

E.g. any logging output?

slate swan
raw latch
raw latch
slate swan
boreal ravine
final iron
#

Can I have a link to that?

boreal ravine
slate swan
#

Hello, may I ask how do I get the roles of the user who executed a command?

heavy folio
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
boreal ravine
#

!d discord.ext.commands.Context.author

unkempt canyonBOT
final iron
#

What in the sus

graceful gulch
#

anyone know how i can implement an after function for discord.ffmpegopus

dry kelp
#

embed.set_thumbnail(url=ctx.guild.icon.url)

final iron
#

!d discord.Intents.guilds

unkempt canyonBOT
final iron
#

!d discord.Guild.icon

unkempt canyonBOT
#

property icon: Optional[discord.asset.Asset]```
Returns the guild’s icon asset, if available.
dry kelp
#

oh

#

ty

#
        if ctx.guild.icon.url == None:
            pass
        else:
            embed.set_thumbnail(url=ctx.guild.icon.url)
#

fixed

final iron
#

I guess

graceful gulch
#
Traceback (most recent call last):
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "D:\Coding\Projects\MyMusicBot\bot\cogs\Music.py", line 137, in play
    await ctx.send(f"Added {players[0].title if len(players) == 1 else 'songs'} to queue")
  File "D:\Coding\Projects\MyMusicBot\bot\cogs\Music.py", line 95, in __check_queue
    p = discord.FFmpegOpusAudio(player.stream_url, **FFMPEG_OPTIONS)
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\player.py", line 324, in __init__
    super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\player.py", line 138, in __init__
    self._process = self._spawn_process(args, **kwargs)
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\player.py", line 144, in _spawn_process
    process = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, **subprocess_kwargs)
  File "D:\Coding\Python\lib\subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "D:\Coding\Python\lib\subprocess.py", line 1375, in _execute_child
    args = list2cmdline(args)
  File "D:\Coding\Python\lib\subprocess.py", line 561, in list2cmdline
    for arg in map(os.fsdecode, seq):

anyone got any idea as to why it raises?

#

it raises when ffmpeg is finished playing a song

#

never happened before

slim ibex
#

what is the error

slate swan
#

Ping?

graceful gulch
# slim ibex what is the error
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "D:\Coding\Projects\MyMusicBot\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not member_descriptor
slim ibex
#

whats the code

slim ibex
#

^

final iron
slate swan
#
global channel
channel=client.get_channel(934629001559932938)

@client.event
async def on_ready():
    print(f'Connected to {client.user}')
    print(channel)```
print(channel) returns 'None'
graceful gulch
final iron
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
slate swan
#

yea the problem is that I made it catch the channel before the bot is even ready

#

thats the problem

oblique adder
#

how do I get ctx:context object from interaction : nextcord.Interaction ?

final iron
#

!d discord.ext.commands.Bot.get_context

unkempt canyonBOT
#

await get_context(message, *, cls=<class 'discord.ext.commands.context.Context'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Returns the invocation context from the message.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
limpid thicket
#

option_type for slash_commands, specifically option 6 is a discord.User object right? Yet I can't pass in anyone who isn't in the server. E.g., Dyno has a /ban command and I can't use it on any other but a member in the guild, any way to be able to do this?

oblique adder
final iron
oblique adder
#

then how ?

final iron
#

Actually I'm not sure

#

Since its a slash command there is no message attribute

oblique adder
#

actually there is message attribute

#

but i dont think it work

#

cuz it will be the bot message

#

its just button

polar ice
#

Any idea how i can acheive something like this? everything i try keeps seperating all the lines

cloud dawn
#

You can't get_context from slash commands no.

#

Best is to just tie whatever you doing to bot.

oblique adder
#
Account: jMarchinton PlayerID: 17284 Coins: 1,028,366
polar ice
#

@oblique adder 😮 I can do it in the chat, but not sure how to format it into a string into pycharm

oblique adder
#

just do the same thing u write in chat and write there

polar ice
#

Okay that didnt work

oblique adder
#
Account: jMarchinton PlayerID: 17284 Coins: 1,028,366
polar ice
#

so many colors 😄

slate swan
#

the discord.py have a event to check when a user joined???

oblique adder
polar ice
#

How do you get it all on one line?

final iron
unkempt canyonBOT
#

An aware datetime object that specifies the date and time in UTC that the member joined the guild. If the member left and rejoined the guild, this will be the latest date. In certain cases, this can be None.

oblique adder
polar ice
#
Account: jMarchinton PlayerOD: 123434 Counts 3423432
oblique adder
polar ice
#

Awesome, how did you get it in yellow? 😄

oblique adder
#

use ml instead of prolog

polar ice
#

How many different ones are there?

slate swan
# oblique adder on_member_join

why my code dont worksss??????

import discord, os

class Client(discord.Client):
  async def on_ready(self):
    print('true')

  async def on_message(self, message):
    print(message.content)

  async def on_member_join(self, member):
    print('test =/')

bot = Client();
bot.run(os.environ['token'])
graceful gulch
#

guys quick question

slate swan
#

wym

oblique adder
graceful gulch
#

what fork would you all recommend in terms of efficiency and the least amount of code i would have to fix

polar ice
unkempt canyonBOT
oblique adder
fallow bridge
#

guys can i have a question?

graceful gulch
#

thanks both of you! Ill check both of them out

oblique adder
unkempt canyonBOT
#

Hey @fallow bridge! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

oblique adder
#

dont write your token in the code @fallow bridge

fallow bridge
#

ok im sry i dont know about that

oblique adder
#

also regenerate your token , someone might grab

fallow bridge
#

Traceback (most recent call last):
File "main.py", line 10, in <module>
cogs[i].setup(client)
File "/home/runner/Bot-For-Dc-1/music.py", line 47, in setup
client.add.cog(music(client))
AttributeError: 'Bot' object has no attribute 'add'

cloud dawn
#

You don't need listeners/ decorators inside there.

#

Could you delete this?

fallow bridge
final iron
#

!yt-dl

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)
fallow bridge
cloud dawn
oblique adder
# fallow bridge ok wait
  1. YT_DL is against TOS so we can't help
  2. format your code properly if short or use a pasting service.
polar ice
#

@oblique adder Using the ml method you just showed, is it possible to change a color of a individual word

for example local - grey or green or blue

but the rest of the sentence in the ml format all in one line? If that makes sense 😄

oblique adder
#

example

cerulean scaffold
#

shouldnt the on_reaction_remove event work? it doesnt trigger at all when someone removes a reaction on my bot

#

as in i literally have it linked to solely a print statement and it outright refuses

cerulean scaffold
#

@client.event
async def on_reaction_remove():
print("ran")

is literally it

cerulean scaffold
#

yep, it works for adding reactions

pliant gulch
#

on_reaction_remove does not have no parameters

#

!d discord.on_reaction_remove

unkempt canyonBOT
#

discord.on_reaction_remove(reaction, user)```
Called when a message has a reaction removed from it. Similar to on\_message\_edit, if the message is not found in the internal message cache, then this event will not be called.

Note

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

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

Note

Consider using [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") if you need this and do not want to enable the members intent.
pliant gulch
#

As you can see from the docs it takes reaction and user

cerulean scaffold
#

tried it with those params. Nothing happened

pliant gulch
#

How old is the message you are removing a reaction from

cerulean scaffold
#

brand new.

pliant gulch
#

If it isn't cached it won't be dispatched

cerulean scaffold
#

@pliant gulch i can add reactions to it and get a response, but im never getting anything through on the removal.

slate swan
#
#everything is correct above this
global channel
@client.event
async def on_ready():
    print(f'Connected to {client.user}')
    channel=client.get_channel(934629001559932938)
    update.start()

@tasks.loop(seconds=5)
async def update():
    if channel is None:
        return```

its says channel is not defined in the tasks.loop line
#

semeone can help me?? (the event on_member_join dont works)

import discord, os

class Client(discord.Client):
  async def on_ready(self):
    print('true')

  async def on_message(self, message):
    print(message.content)

  async def on_member_join(self, member):
    print('test =/')

bot = Client();
bot.run(os.environ['token'])
cerulean scaffold
#

^

#

ah right

slate swan
slate swan
#

just woke up from 2 naps whatsup guyssss

cloud dawn
slate swan
cloud dawn
slate swan
cerulean scaffold
#

i still dont have a clue why the on reaction remove isnt working this actually is confusing me haha

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

try this```py
import discord, os
intents=discord.Intents.default()
intents.members=True
client=discord.Client(intents=intents)

@client.event
async def on_member_join(member):
print('test=/')

client.run(os.environ['token'])```

slate swan
#

that still wont work without intents

slate swan
#

yea intent

#

member intents

#

also , who uses Client in 2022 , just use commands.Bot

#

it would do everything Client can

slate swan
#

ima go for breakfast

slate swan
#

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

slate swan
#

so basically you can py bot.my_channel = bot.get_channel(... and use it anywhere again!

#

globals are bad

#

okimii is smart

cloud dawn
#

be like okimii

#

wait no

slate swan
#

🧠

slate swan
scarlet pond
#

uh

slate swan
#

pip install it?

slate swan
# scarlet pond

if u are using replit, go in packages and install, else, use pip install

scarlet pond
slate swan
#

replit having a stroke

scarlet pond
#

yeah def

slate swan
scarlet pond
#

I forgot but I'm pretty sure replit has a .replit feature

#

but I forgot the syntax for importing through that

slate swan
scarlet pond
#

hm

slate swan
#

just use the bot framework

#

and pep8 is screaming

#

and you probably need to turn on members intents so the bot caches the users

slate swan
#

open

final iron
#

pep8

slate swan
#

its screaming

#

allot

quick gust
#

take a look at open

slate swan
#

infernum is so smort

#

dont you have to add the mode your viewing the file

#

?

#

not sure myself

#

yes

#

and are you using json as a db?

#

good

#

lovely

final iron
slate swan
#

json is easy lol

slate swan
final iron
#

What's the appeal with json anyway

quick gust
slate swan
final iron
#

Imo SQL is easier and a lot more readable

slate swan
#

yes

#

json is for formatting data

quick gust
#

me who doesn't even know how to read data stored in my db

slate swan
#

i.e a response from an api is formatted in json