#discord-bots

1 messages · Page 74 of 1

cerulean shale
#

Thx for asking btw

gentle eagle
#

thats good to hear

gentle eagle
primal token
#

val never asks me how i am😔

cerulean shale
#

🫡

#

Sed lyf

gentle eagle
cerulean shale
#

Is my pfp visible btw?

gentle eagle
#

yes its a little qt

primal token
#

cat

cerulean shale
#

It ain't visible on my screen 💀

#

That's why I asked

gentle eagle
#

sad :((

atomic glacier
#

Hi, I am having an issue where when i get message.content it is " ". This is not a self bot. Please help.

wicked atlas
#

Kinda odd that you say it's not a self bot. It's usually not a self bot when people ask those kinds of questions, so you saying that makes me think it's a self bot.

strong remnant
gentle eagle
#

thats a bit odd, why would he state hes not using a self bot because of a message's content being empty thats probably the furthest thing someone would think about when trouble shooting an issue like that, either way how can a message content have just a space when a user cant send a space char only?

atomic glacier
#

i figured it out tho

#

its cause its a setting in the fucking dev portal

wicked atlas
#

message content intent moment

gentle eagle
#

i thought discord didnt dispatch message events if you didnt have the intent? i guess it does with missing fields

#

-_-

wicked atlas
#

well, it's message content intent

#

you still get the event, just not the content of it

atomic glacier
#

ill show you the bot

gentle eagle
#

yeah youre right kek

atomic glacier
#

look

#

not a selfbot

gentle eagle
#

walter white?😍

atomic glacier
#

yes

gentle eagle
#

sexy

atomic glacier
#

but uh if u look it up everyone says its cause its a selfbot

wicked atlas
#

yeah a few days ago they started enforcing it on verified bots

atomic glacier
#

thats why I said it in the post

wicked atlas
#

so like all verified bots are stuck using slash commands now

primal token
gentle eagle
#

shhhhhhh 😡

hushed galleon
normal lava
#

Can anyone teach me how to make discord bots

slate swan
normal lava
#

Ohk

primal token
slate swan
#

Second of all, I will.

primal token
primal token
slate swan
primal token
slate swan
#

IT WAS 3 MONTHS AGO

#

I think

primal token
#

and the new release was like a month ago?

slate swan
#

it was?

#

Wait what was the new release

primal token
unkempt canyonBOT
primal token
#

2.0 on pypi

slate swan
#
import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')

intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run('token')

What is the difference between these two?

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')
primal token
#

What type of question is that and what point are you trying to prove?

slate swan
#

No point

#

I am actually curious. I do not know myself

#

I see many examples of these, mainly the discord.ext

primal token
#

Well i think the code explains it itself and nothing needs to be discussed as you can read/see its differences and similarities

slate swan
#

What is .ext

#

are those slash commands?

primal token
#

Its an extension for tasks and commands like prefixed commands and slash commands

slate swan
#

Okay so one is for text commands

#

the other is for slash? alright.

primal token
#

?

slate swan
#

I'm not trying to argue, I genuinely do not know

primal token
#

Im not really arguing but how did you conclude with that belief?

slate swan
#

Oh wait I misread it.

#

But what is different between @bot.command and @bot.event

#

wait bot.command is for slash @bot.event is for actual discord.py events

#

nvm im dumb

primal token
#

@Bot.command is for the command abstraction used with dpy for prefix commands while @Bot.event is for gateway events mainly but can register namespaces/abstractions of the library like setup_hook due to its way of registering events to itself

slate swan
#

Okay, thank you.

primal token
#

If you need more info the tutorial i gave should explain it fairly well or the documentation can as well

gentle eagle
hushed galleon
robust fulcrum
#

Guys how we can send a message to channel using discord api in python?

gentle eagle
hushed galleon
#

oh by the token used to login

#

user tokens are prefixed with Bearer while bot tokens are prefixed with Bot

gentle eagle
gentle eagle
#

sorry i dont really know how self bots bypass the gateway and API as ive never done it or researched about it

hushed galleon
#

is there any more context to this? theres not a lot to suggest from that besides verifying your database credentials
(also not discord bots related)

hushed galleon
gentle eagle
hushed galleon
#

bearer tokens let you do stuff on behalf of a user, like getting the guilds they're in

#

you can get a general idea of it from the scopes listed in the oauth2 page on the dev portal

gentle eagle
#

im not very advanced with discords auth system etc, as you can see🥲

hushed galleon
#

i dont really understand the oauth2 stuff since ive just dealt with bot stuff for discord applications

gentle eagle
#

same :^))

mild token
mild token
#

Oh last time i remember this channel was called discord.py

#

And we have that docs command linked to that

sick birch
sick birch
mild token
gentle eagle
sick birch
#

Hm.. not sure how well an oauth2 wrapper would work. I think there are a few but none of them seem very well implemented or designed. Not really their fault, it's just the way the oauth2 system is designed makes it difficult to, of course, design a wrapper for it

gentle eagle
#

ive done one but ive never really focused on auth

sick birch
gentle eagle
#

doesnt discord bots use Oauth2? sorry im not really knowledgeable with the system at all

mild token
#

Oauth2 is for user account info ,mainly used for login purpose

sick birch
#

Not necessarily, you make a bot, get a token, and use that for all of your needs. From a holistic point of view, it's pretty simple

mild token
#

I have used oauth2 in nextjs once, they implemented very clean way

sick birch
#

As mentioned, though, once you start dealing with user accounts, and having to do something on behalf of the user, things start getting more serious, and as expected, complexity scales appropriately

gentle eagle
#

ive never implemented it but i probably will if i ever finish my chat app which i was working on and after a week i stopped lol

sick birch
gentle eagle
#

ill probably make a chat app with sockets in another lang over python

mild token
#

Literally fallen in love with it lol

mild token
sick birch
#

Yep. It's just incredibly convenient to work with

mild token
#

😅

gentle eagle
#

im wasnt thinking of js at all😭

mild token
#

Oops 😬

gentle eagle
#

i was thinking using something like rust or cpp

sick birch
#

For a backend?

gentle eagle
#

yes

sick birch
#

Sure. But depending on the scale of your chat app, Python will more than likely do the job

gentle eagle
#

for front-end, my terminal is good enough ;^))

gentle eagle
#

anyways night night guys :33

silk fulcrum
#

nop

slate swan
#

yes

silk fulcrum
#

I think it's possible if user has bot as an Authorised App, but not sure'

slate swan
#

!d discord.Integration.user

unkempt canyonBOT
silk fulcrum
#

w--

#

!d discord.on_integration_create

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.
silk fulcrum
#

burh:(

slate swan
#

💀 I saw your pfp from a good distance and couldn't see the cat's eyes either, that actually looked so inappropriate lmao

#

dw you're not the only one

#
async def suggest(ctx, *, suggestion):
  await ctx.channel.purge(Limit=1)
  channel = nextcord.utils.get(ctx.guild.text_channels, name="║💡║suggestions")
  suggest = nextcord.Embed(title="New Suggestion!", description=f"{ctx.author.name} has suggested **{suggestion}**.")
  sugg = await channel.send(embed=suggest)
  await sugg.add_reaction("✔️")
  await sugg.add_reaction("❌")```
#

guys why doesn't it work? it keeps saying nextcord.ext.commands.errors.CommandNotFound: Command "suggest" is not found

slate swan
hollow agate
#

Are you certain you saved the file?

slate swan
#

yeah

hollow agate
#

Could you send me all of your code (without any important stuff, like token) in

#

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

hollow agate
#

It still doesn't seem like its @bot.command()

#
@bot.command()
async def suggest(ctx, *, suggestion):
  await ctx.channel.purge(Limit=1)
  channel = nextcord.utils.get(ctx.guild.text_channels, name="║💡║suggestions")
  suggest = nextcord.Embed(title="New Suggestion!", description=f"{ctx.author.name} has suggested **{suggestion}**.")
  sugg = await channel.send(embed=suggest)
  await sugg.add_reaction("✔️")
  await sugg.add_reaction("❌")```
#

should be it

slate swan
#

alr I changed to that

hollow agate
#

Save the file and restart the bot and see if it works

slate swan
#

lets see if it works

#

error

hollow agate
#

What's the error?

slate swan
#

Traceback (most recent call last):
  File "/home/runner/Discord-Bot/venv/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 1382, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/Discord-Bot/venv/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 948, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/Discord-Bot/venv/lib/python3.8/site-packages/nextcord/ext/commands/core.py", line 174, in wrapped
    raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: purge() got an unexpected keyword argument 'Limit'```
hollow agate
#

Are you trying to delete just the command message?

slate swan
#

yes

#

so that it just sent suggestion

hollow agate
#

Use ctx.message.delete()

#

Don't use purge

#

It should be await ctx.message.delete() in full instead of await ctx.channel.purge()

slate swan
#

alr

#

I was kinda watching tuto from youtube

hollow agate
#

If you ever want to use purge, it's limit, not Limit.

slate swan
#

lets see now

silk fulcrum
#

don't watch them

hollow agate
#

Learn python from not guides xd

silk fulcrum
#

they're all outdated or bad

hollow agate
#

Also, discord.py isn't very friendly for beginners, but I did learn from discord.py so I can't talk 😂

slate swan
#

WORKS

hollow agate
#

:)

slate swan
#

THANK YOU ALL!

slate swan
#

but it didn't delete my message

hollow agate
#

Send the code & error

slate swan
#

no error

hollow agate
#

Code?

slate swan
slate swan
# hollow agate Code?
async def suggest(ctx, *, suggestion):
  await ctx.message.delete()
  channel = nextcord.utils.get(ctx.guild.text_channels, name="║💡║suggestions")
  suggest = nextcord.Embed(title="New Suggestion!", description=f"{ctx.author.name} has suggested **{suggestion}**.")
  sugg = await channel.send(embed=suggest)
  await sugg.add_reaction("✔️")
  await sugg.add_reaction("❌")```
hollow agate
#

You saved the file and restart the bot, yes?

silk fulcrum
hollow agate
#

Ah, none that's why

silk fulcrum
#

it's a fork of dpy

hollow agate
#

@slate swan go to your Discord Developer Portal and enable everything you see named intents and put intents = discord.Intents.all() somewhere in your code

silk fulcrum
#

nextcord*

hollow agate
#

Oh, you do have it in there, just enable everything you see in Discord Developer Portal with intents

silk fulcrum
hollow agate
hollow agate
#

Maybe that'll work

silk fulcrum
#

wtf is intents = discord

#

where will he find that

slate swan
#

ugh its fine if msg.delete doesn't work

hollow agate
#

He already has it

slate swan
#

just how do I make this command only useable on one channel?

hollow agate
silk fulcrum
#

by the way @slate swan does your bot have manage_messages permission?

hollow agate
silk fulcrum
hollow agate
#

Pro Doggy's.

silk fulcrum
#

why the heck do you have both dpy and nextcord??? @slate swan

#

that breaks all the logics

hollow agate
#

xd

#

It's much easier and more supported

silk fulcrum
slate swan
#

THIS WAS THE PROBLEM BOTS PERMS WERE KINDA EDITED AND I FORGOT TO ADD THAT

silk fulcrum
#

no need to use so many capital letters

#

first of all consider using only one API wrapper, discord.py or nextcord

#

but preference

slate swan
slate swan
hollow agate
#

It's tutorial code that Pro Doggy has

slate swan
#

is that how py-cord has implemented their buttons

#

idts

#

that's a third party lib and not py-cord

hollow agate
#

Can you rephrase that?

#

It doesn't make a ton of sense 😅

slate swan
#

just do message.channel.send instead of message.send

#

and yes I agree with Someone

hollow agate
#

OH, I see what he meant, I'm just stupid, okay.

slate swan
#

smh, do message.channel.send and not message.send

#

thanks for cooperating

shrewd apex
slate swan
#

you asked again

swift pumice
#

merkste selber nh

#

diggah in der fehlermeldung steht doch was falsch ist

hollow agate
#

!rule 4

unkempt canyonBOT
#

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

swift pumice
#

!rule 4

unkempt canyonBOT
#

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

hollow agate
#

lol

#

With?

silk fulcrum
#

u r trying to use create_actionrow which is not defined

#

looking

ionic edge
#
    @commands.hybrid.command(
        name="avatar",
        description="Get the avatar of a user.",
    )
    @checks.not_blacklisted()
    async def avatar(self,context:Context , user: discord.Member = None) -> None:
        """
        Get the avatar of a user.
        
        :param context: The hybrid command context.
        :param user: The user to get the avatar from.
        """
        if user is None:
            user = context.author
        embed = discord.Embed(
            title=f"{user}'s avatar",
            color=discord.Color.blue(),
        )
        embed.set_image(url=user.avatar_url)
        await context.send(embed=embed)```
#

ExtensionFailed: Extension 'cogs.fun' raised an error: AttributeError: module 'discord.ext.commands.hybrid' has no attribute 'command'

silk fulcrum
#

no idea, I've never seen similar code in my life

#

and I don't use pycord

ionic edge
silk fulcrum
#

seems like it is discord_slash

#

not pycord

#

uhm

#

did you even think about the question you asked? how it sounds?

#

like I mean

#

You are using discord-slash

#

then you are like "oh yes?? Im using it?"

#

and then How to use pycord then?

#

like wtf

#

i dont even know how to explain that

#

like just use pycord instead of discord-slash maybe?

#

what is that

#

well if you want you can use discord.py's Views implementation and I recommend that, but discord.ui doesn't have all these methods like create_button and e.t.c

#

idk? walk in the park? go wash your face?

#

well this code is absolutely nuts

#

you should rewrite it

#

it's not even close to how you make buttons in dpy

#

yes you can

#

View()*

#

i think so

#

btw try it and see

#

ok

#

wait are u trying to use both pycord and discord.py?

#

hm pycord uses pretty much the same sys

#

it just takes *items in View()

#

no idea, there is while True which i dont understand for what is there btw

ionic edge
#
discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'purge' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
#
    @commands.hybrid_command(
        name="purge",
        description="Delete a number of messages.",
    )
    @commands.has_guild_permissions(manage_messages=True)
    @checks.not_blacklisted()
    @app_commands.describe(amount="The amount of messages that should be deleted.")
    async def purge(self, context: Context, amount: int) -> None:
        purged_messages = await context.channel.purge(limit=amount)
        await context.send(content="Deleted {} messages.".format(len(purged_messages)), delete_after=5 , ephemeral=True)```
silk fulcrum
ionic edge
#

messages are getting deleted but

#

no response

silk fulcrum
# ionic edge

if it takes longer than 3 seconds to delete the messages then you cannot respond to an interaction, to fix that use await context.defer() before deleting the messages, so you will have not 3 seconds but 15 minutes to respond

shrewd apex
#

get_member(1234)

#

no kwarg required

#

bruh

#

remove user_id=

#

just pass the id

paper sluice
#

create a cursor object, then execute queries with it

vale frigate
#

Oh Hello!

#

My code so long

#

ah

#

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

vale frigate
#

Oh ok!

#

and this the error ```py

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x0000021E4571BDC0>:
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Discord Bot\main.py", line 266, in fight
await message1.edit(embed=embed, view=myview)
UnboundLocalError: local variable 'myview' referenced before assignment

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: UnboundLocalError: local variable 'myview' referenced before assignment

#

i referenced myview

#

before i use it

#

but idk why it not work]

#

any idea why this not working ping me please

#

idk

#

But rip 😦

vale wing
#

Have you ever heard of refactoring

slate swan
vale wing
#

You have like 8 lines repeating 30 times

slate swan
#

wtf

vale wing
#

Just look at that

slate swan
#

I did

vale frigate
vale frigate
#

ah

slate swan
#

what do I say

vale wing
vale frigate
vale wing
#

For example

vale wing
#

Not ctrl+c ctrl+v a thing you need to execute in multiple places but put it into function

vale wing
#

That's unrelated

vale frigate
#

ok

#

so what i do

#

ctrl+v

#

ah it copy and paste

vale wing
outer parcel
#

how do i put this in my bot description

vale wing
outer parcel
#

do i just have to type in manually

vale frigate
vale wing
#

Read my sentence again

vale frigate
outer parcel
vale frigate
outer parcel
#

k ty

slate swan
vale frigate
#

never do Function

outer parcel
#

so i can try it so e idk

vale wing
vale frigate
#

any thing can make me learn what is Function

vale frigate
vale wing
vale frigate
#

ok

#

!python

#

ah#

vale wing
#

!resources

unkempt canyonBOT
#
Resources

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

outer parcel
vale frigate
slate swan
vale frigate
outer parcel
#

Function is like a separate piece of code that runs when it is called like if function is called myview you call it with myview()

vale wing
#

Ima go learn go

vale frigate
outer parcel
paper sluice
vale wing
#

Idc

slate swan
#

!d discord.User.send

unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

slate swan
#

jeez

paper sluice
#

almighty '

slate swan
#

!d discord.User.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
vale frigate
#

but really now i care about fix my problem than make my code clean

vale wing
#

The only thing I hate about go yet is its error handling

outer parcel
vale frigate
vale wing
#

This is more like forkcord

outer parcel
vale frigate
outer parcel
#

or ask stack overflow

vale frigate
#

just this small error

outer parcel
vale frigate
#

yes

vale frigate
#

so he not understand

outer parcel
vale frigate
#

so let me

outer parcel
#

how does buttons work

#

if that error appears

#

it means it cant run myview() because it is referenced before assignment

vale frigate
#

ok i put py buttom1.callback = buttom1_callback buttom2.callback = buttom2_callback buttom3.callback = buttom3_callback buttom4.callback = buttom4_callback buttom5.callback = buttom5_callback myview = View(timeout=180) myview.add_item(buttom1) myview.add_item(buttom2) myview.add_item(buttom3) myview.add_item(buttom4) myview.add_item(buttom5) myview2 = View(timeout=180) myview2.add_item(buttom12) myview2.add_item(buttom22) myview2.add_item(buttom32) myview2.add_item(buttom42) myview2.add_item(buttom52)up

outer parcel
#

O

vale frigate
#

let me test

outer parcel
#

you know its easier to put in class

#

much more clean

vale frigate
#

idk i sitll new

paper sluice
outer parcel
#

this tutorial explains nicely how to do nextcord.ui.View in class

vale frigate
vale frigate
paper sluice
outer parcel
#

its basically a code for a new object whenever you call it, it makes a new instance of itsself and can be changed

#

think of it like a blueprint for new objects

outer parcel
#

it should be within the command

vale frigate
#

what in the world ```py
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x000001FDE002B730>:
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Discord Bot\main.py", line 258, in fight
buttom1.callback = buttom1_callback
UnboundLocalError: local variable 'buttom1_callback' referenced before assignment

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: UnboundLocalError: local variable 'buttom1_callback' referenced before assignment```

outer parcel
#

put that block of code inside the command function

vale frigate
vale frigate
#

idk what is function really

#

but i know class

paper sluice
outer parcel
#

you have smt like this

#

right ?

vale frigate
#

ah this class?

outer parcel
#

no

vale frigate
#

ah

outer parcel
#

its async function for discord bots

vale frigate
#
class buttom(nextcord.ui.buttom)```
paper sluice
vale frigate
#
@bot.slash_command(name='fight', description="Fight With a Bot!")
async def fight(ctx, health: int, time: int):```
outer parcel
vale frigate
#

oh

#

how :0

outer parcel
#

:(

vale frigate
#

rip

outer parcel
#

just copy it

#

and paste it beneath it

#

then index it

vale frigate
#

i need understand frist what you trying to do

slate swan
#
        async with self.bot.db.cursor() as cursor:
            await cursor.execute(f"SELECT color_hex FROM EmbedColor WHERE guild_id = {self.bot.guild.id}")
            result = await cursor.fetchone()

how would i get the current guild id

slate swan
outer parcel
slate swan
vale frigate
#

ah server name py {interaction.guild} or py {ctx.guild}

outer parcel
slate swan
outer parcel
vale frigate
#

and i pertty sure server id py {ctx.guild.id}

outer parcel
#

im confused are you lookinng for a specifi guild

slate swan
outer parcel
vale frigate
#

ah

slate swan
#

ty anyways

outer parcel
#

What are you trying to make it do

vale frigate
#

ok now any one can help me

outer parcel
slate swan
outer parcel
#

you will prob need it in every command

slate swan
#

i could add it to every command but then id be lazy

vale frigate
outer parcel
#

make it into a function

vale frigate
#

Ok me will wait 10 mins

slate swan
#

lemme try

outer parcel
#

make a async function that gets color from data

#

then you can just calll on it every time in code

slate swan
outer parcel
outer parcel
#

@vale frigate you have smt like this right

#

where your buttons are above it

#

you want to take buttons and index it inside the command

vale frigate
#

a

outer parcel
#

also make sure you put button1 to 5 variables also in there

vale frigate
#

OH WHat a smart guy

outer parcel
#

:/ e not relly

vale frigate
#

lol

#

like this?

outer parcel
#

yes

vale frigate
#

it should work?

outer parcel
#

ye prob

#

unless there is error in code below

#

send error if there is error

vale frigate
#
The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: UnboundLocalError: local variable 'buttom1_callback' referenced before assignment```
#

@outer parcel

outer parcel
vale frigate
#

true

outer parcel
#

can i see how you put it ?

#

like where did you put it please send screenshot

outer parcel
#

could u paste it into pastebin? or smt

vale frigate
#

Sure!

outer parcel
#

ty

vale frigate
#

💀

outer parcel
#

what?

#

just type paste bin in google

vale frigate
#

i know this was kind a wrido

outer parcel
#

should be first thing

vale frigate
#

xD

outer parcel
vale frigate
#

i know

outer parcel
#

its just a virus checkup there are no threats

vale frigate
#

i was jkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

outer parcel
#

o lol :/

vale frigate
vale frigate
outer parcel
#

aight ty

vale frigate
outer parcel
#

you have not defined myview yet

slate swan
#

@outer parcel could you help me with the fucntion btw cos now im kinda stuck

async def embed_color(self, interaction: nextcord.Interaction):
    async with self.bot.db.cursor() as cursor:
        await cursor.execute(f"SELECT color_hex FROM EmbedColor WHERE guild_id = {interaction.user.guild.id}")
        result = await cursor.fetchone()
        color_hex = f"{result[0]}"
        readableHex = int(hex(int(color_hex.replace("#", ""), 16)), 0)

function ^

color=await embed_color(self, interaction)

its receiving a NoneType

vale frigate
outer parcel
outer parcel
#

like this

paper sluice
slate swan
outer parcel
#
await cursor.execute(f"SELECT color_hex FROM EmbedColor WHERE guild_id = ?", (interaction.user.guild.id,))
      result = await cursor.fetchone()
#

wait can you select from aiosqlite like that

#

idk im used to doing a bracket variable at the end

vale frigate
paper sluice
slate swan
outer parcel
#

ye but myview is not declared yet

#

your only defining view

#

not myview

vale frigate
outer parcel
#

ok

vale frigate
outer parcel
#

you put this buttom1.callback = buttom1_callback
buttom2.callback = buttom2_callback
buttom3.callback = buttom3_callback
buttom4.callback = buttom4_callback
buttom5.callback = buttom5_callback
myview = View(timeout=180)
myview.add_item(buttom1)
myview.add_item(buttom2)
myview.add_item(buttom3)
myview.add_item(buttom4)
myview.add_item(buttom5)
myview2 = View(timeout=180)
myview2.add_item(buttom12)
myview2.add_item(buttom22)
myview2.add_item(buttom32)
myview2.add_item(buttom42)
myview2.add_item(buttom52) at bottom of code

vale frigate
#

a

#

Hmmm

#

bottom of the command? not code

slate swan
paper sluice
outer parcel
#

put it below this

outer parcel
#

buttom1.callback = buttom1_callback
buttom2.callback = buttom2_callback
buttom3.callback = buttom3_callback
buttom4.callback = buttom4_callback
buttom5.callback = buttom5_callback
myview = View(timeout=180)
myview.add_item(buttom1)
myview.add_item(buttom2)
myview.add_item(buttom3)
myview.add_item(buttom4)
myview.add_item(buttom5)
myview2 = View(timeout=180)
myview2.add_item(buttom12)
myview2.add_item(buttom22)
myview2.add_item(buttom32)
myview2.add_item(buttom42)
myview2.add_item(buttom52)

vale frigate
paper sluice
#

!e

def foo():
  print(a)
  a = 1
foo()
unkempt canyonBOT
#

@paper sluice :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 |   File "<string>", line 2, in foo
004 | UnboundLocalError: cannot access local variable 'a' where it is not associated with a value
paper sluice
outer parcel
outer parcel
#

he is making it inbuilt within the code

vale frigate
#

xD

outer parcel
vale frigate
vale frigate
#

i keeping tell him read up

outer parcel
#

copy what i replied

vale frigate
outer parcel
vale frigate
#

oh ok

outer parcel
#

paste it below this

vale frigate
#
    player2 = random.choice(namesoffight)
    buttom1 = Button(label="Push 🤛", style=ButtonStyle.red)
    buttom2 = Button(label="Kick 🦶", style=ButtonStyle.red)
    buttom3 = Button(label="Fire 🔥", style=ButtonStyle.red)
    buttom4 = Button(label="Shot 🔫", style=ButtonStyle.red)
    buttom5 = Button(label="Eat 🥩", style=ButtonStyle.green)
    buttom12 = Button(label="Push 🤛", style=ButtonStyle.red, disabled=True)
    buttom22 = Button(label="Kick 🦶", style=ButtonStyle.red, disabled=True)
    buttom32 = Button(label="Fire 🔥", style=ButtonStyle.red, disabled=True)
    buttom42 = Button(label="Shot 🔫", style=ButtonStyle.red, disabled=True)
    buttom52 = Button(label="Eat 🥩", style=ButtonStyle.green, disabled=True)
    buttom1.callback = buttom1_callback
    buttom2.callback = buttom2_callback
    buttom3.callback = buttom3_callback
    buttom4.callback = buttom4_callback
    buttom5.callback = buttom5_callback
    myview = View(timeout=180)
    myview.add_item(buttom1)
    myview.add_item(buttom2)
    myview.add_item(buttom3)
    myview.add_item(buttom4)
    myview.add_item(buttom5)
    myview2 = View(timeout=180)
    myview2.add_item(buttom12)
    myview2.add_item(buttom22)
    myview2.add_item(buttom32)
    myview2.add_item(buttom42)
    myview2.add_item(buttom52)```
outer parcel
#

ye see if works

vale frigate
#

Ok Sir!

paper sluice
outer parcel
#

class is way easier

outer parcel
vale frigate
#

i understand how fix all this

outer parcel
#

does it work?

vale frigate
outer parcel
#

what?

vale frigate
#

Frist of all py buttom1.callback = buttom1_callback buttom2.callback = buttom2_callback buttom3.callback = buttom3_callback buttom4.callback = buttom4_callback buttom5.callback = buttom5_callback myview = View(timeout=180) myview.add_item(buttom1) myview.add_item(buttom2) myview.add_item(buttom3) myview.add_item(buttom4) myview.add_item(buttom5) myview2 = View(timeout=180) myview2.add_item(buttom12) myview2.add_item(buttom22) myview2.add_item(buttom32) myview2.add_item(buttom42) myview2.add_item(buttom52) working

#

butttt py buttom1_callback is furtion

outer parcel
#

ye

vale frigate
#
    async def buttom1_callback(interaction):```
#

SO

vale frigate
#
async def buttom1_callback(interaction):
  print("hi")
 buttom1.callback = buttom1_callback
 buttom2.callback = buttom2_callback
 buttom3.callback = buttom3_callback
 buttom4.callback = buttom4_callback
 buttom5.callback = buttom5_callback
 myview = View(timeout=180)
 myview.add_item(buttom1)
 myview.add_item(buttom2)
 myview.add_item(buttom3)
 myview.add_item(buttom4)
 myview.add_item(buttom5)
 myview2 = View(timeout=180)
 myview2.add_item(buttom12)
 myview2.add_item(buttom22)
 myview2.add_item(buttom32)
 myview2.add_item(buttom42)
 myview2.add_item(buttom52)```
#

like this#

outer parcel
#

make sure button1.callback is not isde of the callback

#

ye but all callbacks above this

#

but index properly

#

otherwise it wont work

vale frigate
#

He not understand buttom1_callback

#

bc it not even set

#

we set it so down

outer parcel
#

so altogether like this

vale frigate
#

like this what we trying to do rn py Print(view) view = "It will not work"

vale frigate
outer parcel
#

async def callback has to be aboce button.callbacks

vale frigate
#

still me not understand

outer parcel
#

oof

vale frigate
#

wait OHHH

#

wait me dumb ;/

outer parcel
#

:o

vale frigate
#

Lol

outer parcel
#

put the async function iside of the command

#

but above the this area

#

so it is definied before it is called

vale frigate
#

example bc my brian kinda boom in 3

#

2

outer parcel
#

o

vale frigate
#

1

#

brian dead

outer parcel
#

I have to go soon

vale frigate
vale frigate
outer parcel
#

should look like this

vale frigate
#

I UNDERSTAND you try put funtion in command

outer parcel
vale frigate
#

oh let me try

#

it's aready in command

unkempt canyonBOT
#

Hey @vale frigate!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

vale frigate
#

ah

outer parcel
#

huh where is the callbacks function

#

i ahve to go but put the button callback functions

#

above this

vale frigate
#

ah

#

!!!

#

oh

vale wing
#

I am gonna get a heart attack from this

vale frigate
# outer parcel

so just py async def buttom1_callback(interaction): above thos

vale frigate
vale wing
#

Have you ever heard of for loops

#

And lists

vale frigate
#

i know

#

i know all that

vale wing
#

And why is it named buttom

vale frigate
#

but just don't make me change all my code let's just fix this problem

vale wing
#

You'd better rewrite the whole code and your issues would automatically disappear

vale wing
vale frigate
vale wing
#

You can fix it by rewriting

vale frigate
#

ah it will along timeee

#

um ok let's rewirte

#

@vale wing Now what we gonna do frist

vale wing
#

At least you won't suffer from aids code

#

Wait until I get on PC I will help with that

vale frigate
#

ok me afk ping me when you at pc

#

Thank you for help anyways!

#

i really still new ;/ and don't know alot of things

#

ping me if you ready

#

ah

#

@vale wing

#

😦

#

anyone

#

um D:

#

D:::

#

sorry for ping again @vale wing

#

D:::::::::

vale frigate
#

0 understand 😭

#

RIp

#

any one help

#

i stay here or 1 hour

#

no help so idk you

#

does i have make this in /

#

frist time know that

#

ah

#

um

#

1 sec

#

yes this

#

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

vale frigate
cerulean shale
#

Try keeping the argument arg at the end, i mean after the choices

#

try

silk fulcrum
#

you take arguments in the function definition, not in command decorator 🗿

silk fulcrum
#

wrongpy @bot.command(name="haha", argument: ...) async def haha(ctx):

vale frigate
# unkempt canyon

error ```py
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x00000241ED803730>:
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Discord Bot\main.py", line 237, in fight
buttom1.callback = buttom1_callback
UnboundLocalError: local variable 'buttom1_callback' referenced before assignment

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: UnboundLocalError: local variable 'buttom1_callback' referenced before assignment```

silk fulcrum
#

right py @bot.command(name="haha") async def haha(ctx, argument: ...)

vale frigate
silk fulcrum
#

well for you function

#

not variable

silk fulcrum
vale frigate
silk fulcrum
#

that is -eyes

vale frigate
#

yes idk why it say

#

need define the fuction

#

and i aready did

vale frigate
silk fulcrum
paper sluice
#

import it 💀

silk fulcrum
#

SlashContext does not exist

vale frigate
#

help this guy he good guy

paper sluice
#

you should refer to docs for that

vale frigate
vale frigate
silk fulcrum
#

900+ lines

vale frigate
#

me who will edit

#

but just So i need put the defin before fution

silk fulcrum
#

me who dint inderstand you english

paper sluice
vale frigate
slate swan
#

How do I measure the latency between a message being sent, from the time it triggers?

paper sluice
# vale frigate how

thats for you to decide, but you can subclass View and add buttons with callbacks directly.

vale wing
#

@vale frigate k I am back

paper sluice
#

congrats on surviving goland

vale wing
#

About this @vale frigate

  1. There's special bool type for true/false values, use it instead of strings
is_fighting = True
is_fighting = False```
2. Don't use `time.sleep` in async context, instead use `await asyncio.sleep(...)`
3. Instead of `await ctx.channel.purge(limit=1)` you can just `await ctx.message.delete()`
4. `health` and `time` will never be equal to **type** `str` and as it is typehinted it will never be **instance** of str either
5. For checking if the value is in required range you can use `if a in range(min_inclusive, max_exclusive)` instead of or, that's ok too tho
#

Unnecessary typecast and unnecessary brackets

#

As for those hell-like callbacks..

#

Instead of doing this (pseudocode)

if a > 5:
  a += 10
  b += 20
  c += 30
if a < 5:
  a -= 10
  b += 20
  c += 30

Do this

if a > 5:
  a += 10
if a < 5:
  a -= 10

b += 20
c += 30```
This is one of refactoring methods you really should utilize
#

Also I just put some of your callbacks into diff checker, seems like the difference is only damage. Instead of defining the damage in every fricking callback make a button subclass with damage attribute and just overwrite the callback inside of subclass and instantiate objects of that subclass

hearty cliff
#

hi I am programming a discord bot in python and was wondering how you call functions in something with discord api that still allows reading and writing to a file I've looked online but couldn't find what I was looking for

#

any help would be greatly appreciated

vale wing
#

Use aiofiles or bring it out to a thread/executor

hearty cliff
#

performing the operation of the code thats been written as a sub root and then excuting it accordingly with discords api

#

am I making sense

#

let me know if you need more info

vocal snow
#

You have some python code and you want to execute it with the discord api?

hearty cliff
#

yes

vocal snow
#

Ok but that makes no sense

hearty cliff
#

ok

vocal snow
#

How would you execute code with the discord api

#

And what do you mean by that exactly

hearty cliff
#

I've written a program using sub-roots the code is there I just need to change the inputs ect but because there if statements to match with the code I think

#

unless I just write something like run subroteins()

vocal snow
#

Just speak in layman language

hearty cliff
#

ok

vocal snow
#

You want to send code in discord, read it with the discord bot, execute it and send the output to discord?

hearty cliff
#

yes

vocal snow
#

If it's for personal use, you can use jishaku

#

Otherwise snekbox/piston

hearty cliff
#

how would I go about using that?

vocal snow
#

For jishaku, install with pip and load the extension (bot.load_extension("jishaku"))

#

Then you can use {prefix}jsk py {code}

#

For piston, you can use aiohttp/httpx

hearty cliff
#

ok thank you

#

I will give that a try

pastel finch
#

my python bot not turning on and showing this. i made it on repl. it was working fine for the past months

pastel finch
#

meaning ?

rugged shadow
#

you're sending too many requests at once

#

but it could just be replit

pastel finch
#

meaning i should remove some commands ?

rugged shadow
#

do kill 1 in the terminal

pastel finch
#

what do you mean by that ? whats terminal ? i am a noob sry

pastel finch
knotty agate
#

no problem here, just so happy that i somehow guessed the line to disconnect from a vc first try 🙂

i made a guess that voice_client was a part of the guild and i was right 🙂

rugged shadow
#

there should be like a "terminal" or "console" tab

rugged shadow
knotty agate
hushed galleon
knotty agate
#

await message.author.guild.voice_client.disconnect()

i didnt even know guild was an attribute of author so i had to guess the last 3 🤣

pastel finch
rugged shadow
#

there, "shell"

hushed galleon
#

you cant do much about the discord ban besides finding another way to host your bot (see pins in #965291480992321536)

rugged shadow
#

and in the shell type "kill 1"

pastel finch
primal token
#

You can avoid the ban by changing your public IP as cloudflare is the one that sets the ban to that IP and blocks incoming traffic

pastel finch
primal token
#

thats just poetry installing all dependencies from poetry.lock into an environment

rugged shadow
hushed galleon
#

iunno about their demographics

pastel finch
#

it worked thankyou

hushed galleon
#

good ol workarounds

rugged shadow
primal token
#

That would be imposible to block any packages that interact with the Gateway and REST API of discord, the only possible thing to do is not to let any IP and its traffic reach that server/discord

pastel finch
knotty agate
#

so ive been trying to get my bot to play audio in vcs, following a tutorial. but ive gotten the biggest error message i have ever seen in my 10 months of python and i dont know how to interpret this

#

its 241 characters above the limit

#

the code

FFMPEG_OPTIONS = {'before_options' : '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options' : '-vn'}
YDL_OPTIONS = {'format' : 'bestaudio'}
vc = message.author.guild.voice_client
if vc is None:
    await message.reply("i am not in a vc")
    return
else:
    with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(content_words[1], download=False)
        url = info['formats'][0]['url']
        source = await discord.FFmpegOpusAudio.from_probe(url, **FFMPEG_OPTIONS)
        vc.play(source)
#

the error message isnt consistent either, sometimes i just get
2022-09-04 15:36:08 INFO discord.player ffmpeg process 16672 successfully terminated with return code of 1.

slate swan
#

How do i get the person who used the command using @bot.command() async def func(ctx):

slate swan
#

thanks

#

what is the function to delete a message again?

#

is it await message.delete()

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)
slate swan
slate swan
dull knot
#

What does this mean?

Writing web request
Writing request stream... (Number of bytes written: 8764807)

Tried following a tutorial on YT to host Dc bots and I installed by typing iwr https://fly.io/install.ps1 -useb | iex in the powershell

I'm kinda new to programming in general so forgive my ignorance lemon_angrysad

vocal snow
slate swan
dull knot
vocal snow
#

You should ask that on the fly.io forums

slate swan
#

or is it that bee one

vocal snow
#

I've never heard of it before

slate swan
#

ok

vocal snow
#

Looks ok at first glance though

slate swan
#

So far my code works!

slate swan
#

what is the function called?

#

await message.add_reaction('reaction here')?

vocal snow
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
slate swan
#

wait whaaaatt

#

you can do that command?

slate swan
#

I have a bot that is suppose to forward discord messages to twitter but doesn’t respond. All the intents are enabled th

vocal snow
slate swan
#

what is the difference

vocal snow
#

Latter is triggered even if the message isn't cached

slate swan
#

ok

#
@bot.event(WHAT AM I MISSING HERE?)
async def on_reaction_add(*args, **kwargs) -> None:
    print('Added')
#

What am I missing in bot.event(here)

#

it's coro= but idk what to put after the =

knotty agate
#

you dont need anything

#

just @bot.event()

slate swan
#

it says im missing a positional argument

paper sluice
#

you don't call event

knotty agate
#

oh yeah

slate swan
#
ypeError: event() missing 1 required positional argument: 'coro'
knotty agate
#

you dont call it

slate swan
#

ah okay.

knotty agate
#

just @bot.event

slate swan
#

thanks

#

What does it give me

#

What does the on_reaction_add function give me as args

#

printing *args, **kwargs result in an error

vocal snow
#

What's the error

slate swan
#
@bot.listen()
async def on_message(message):
    with open("curse_words.txt", "r") as cursed:
        gg = cursed.readlines()
        print(cursed.readlines())
    for line in gg:
        if line in message.content:
          await message.delete()
          await message.channel.send("ayy dont curse")
``` message not deleting and no error
silent portal
slate swan
slate swan
fickle hamlet
#

The printing issue is caused by the second readlines() call

#

g = cursed.readlines() changes the stream position to the end

silent portal
fickle hamlet
#

So calling cursed.readlines() again will return []

silent portal
slate swan
gusty shard
#

how can i make my bot print some stuff when somebody uses any of commands?

slate swan
gusty shard
#

well printing it was just an example

#

i will try to make it give some coins randomly when user uses the bot

slate swan
silent portal
swift pumice
#

make a try: and expect:

slate swan
# silent portal This should print out the whole txt file

its printing the file in this way
fword
fword, and the command is working but raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message error keeps getting printed again and again also the "ayy dont curse" sentence gets sent and delete multiple times

slate swan
slate swan
#

Hey!

How do i make a timeout command?

#

it does lol

maiden fable
unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
maiden fable
#

this has a timed_out_until kwarg

slate swan
#

what would i put after the =

maiden fable
#

datetime object

slate swan
maiden fable
#

isnt readlines the same as read().split("\n")?

slate swan
#

hi guys is it possible to give a slash command argument a description

maiden fable
#

Yea

slate swan
#

how

maiden fable
#

What module

slate swan
maiden fable
#

Have u checked out the slash command example in the examples folder in the repo?

slate swan
slate swan
#

but is there a way to do it to each argument?

slate swan
#

Was wondering if anyone can help, I keep getting the following error on my discord bot:

AttributeError: 'int' object has no attribute 'id'

But I am struggling to get my head around this and where I am going wrong, so I was wondering if anyone had any good learning material that focus on this area of python, cheers!

unkempt canyonBOT
#

@primal token :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AttributeError: type object 'int' has no attribute 'id'
primal token
#

Youre trying to use the id attribute on an int

slate swan
#

Not really sure what I am suppose to use there then , back to learning basics then as this just isn't processing in my brain lol cheers.

primal token
slate swan
#

!p discord.Interaction.user

unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

slate swan
unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

#
Command Help

!pep <pep_number>
Can also use: get_pep, p

Fetches information about a PEP and sends it to the channel.

pliant gulch
# slate swan Not really sure what I am suppose to use there then , back to learning basics th...

There are a few common ways this error can happen. lets assume one of them. py channel = 343944376055103488 print(channel.id) Here, people who are new to python will assume straight away that channel is now a discord text channel when using discord.py. This is not the case and infact it is still an int.

What should be done here is that, first of all know how to convert an int into a discord.TextChanel py channel = Guild.get_channel(343944376055103488) print(channel.id) Now this piece of code works because we've converted int -> discord.TextChannel

slate swan
#

how do i get the person who interacted with something

silent portal
hushed galleon
#

it might mean their for-loop attempted deleting the message more than once

#

but id first double check the code to make sure the content was read correctly

#

its very easy to screw that up

slate swan
#

When using on_reaction_add how do I check what message they reacted to?

hushed galleon
hushed galleon
unkempt canyonBOT
slate swan
slate swan
slate swan
#

interaction.user.mention

#

just needed that

hushed galleon
#

oh i thought you meant getting the Interaction itself

pliant gulch
#

You could do await add_roles(discord.Object(id=role)) to make it a snowflake

slate swan
#

Crikey, I can't believe it was that simple and I have been at this for weeks. Goes to show that what your learning isn't always the right thing though, I'll have to go through the docs again, but thank you ❤️

pliant gulch
#

No problem

slate swan
#

@hushed galleon how do I

#

wait

pliant gulch
slate swan
#
  File "main.py", line 40, in <module>
    bot.run("token")
  File "/home/runner/ScamCheck-1/venv/lib/python3.8/site-packages/discord/client.py", line 828, in run
    asyncio.run(runner())
  File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete```
#

??

#

I will do, I'll definitely have another read through docs to tyr get a better understand.

sick birch
#

Is that all? Seems like there must be more

slate swan
#

@hushed galleon is this how i get the right info? ```py
message, emoji = reaction.message, reaction.emoji

slate swan
#

I am trying to find what emoji they used and what message they reacted to

sick birch
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.

slate swan
#

ok

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

sick birch
slate swan
#

ok

#

... @slate swan 'charmap' codec can't encode character '\U0001f633' in position 0: character maps to <undefined>

slate swan
#
message, emoji = reaction.message, str(reaction.emoji)
    print(message, emoji)
pliant gulch
#

Kek, knew it was gonna be a repl.it error as soon as I saw the nix directories in the traceback

slate swan
slate swan
#

go ahead

#

I am trying to recreate a feature that’s in the NekoBot. Basically you type n!punch @rich otter and it will post a picture of anime person punching another person. Same with hug, kiss, etc. does anyone know of a way I can use an existing database images on the internet to pull from to get the same type of specific gifs at random, instead of me having to collect all of the images and recreating my own db?

unkempt canyonBOT
slate swan
#

that's only for anime pictures, dont hate me :kek:

#

What function is used to remove a reaction from a message for a specific player.

#

?

#

like only their reaction is removed.

unkempt canyonBOT
#

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

Remove the reaction by the provided [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") from the message.

If the reaction is not your own (i.e. `user` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.

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

thanks

primal token
#

but iirc its docs werent working or something?

slate swan
#

pleasure is mine

#

How do I edit a message?

#

!d discord.Message.edit

unkempt canyonBOT
#

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

Edits the message.

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

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

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
slate swan
#

anyone know why i get this error when attempting to run my bot?
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]

pliant gulch
#

Could be a DNS issue, wait a few minutes and try again it might resolve itself. Or if your on MacOS it could be that you need to install some certifications (iirc)

slate swan
# sick birch Are you on mac?

yes, ive found on stackoverflow:

For Mac Users, If they are facing the same problem, You can do the following :-

Go to MacintoshHD -> Applications -> Python3.x Folder.
Double click on the "Install Certificates.command".

#

not sure what to do next

slate swan
#

after a week of trying, my bot is finally running

sick birch
#

Yeah I had the same issue a few days back when I was setting up my new MBP for Python stuff lol

pliant gulch
#

I'd use my Mac labtop more if yabai WM wasn't so slow on that model

sick birch
#

Lol. I've got the M2 chip so in terms of specs, it's pretty good. I also use it for school so might as well just do all my coding stuff on it and game on my Windows desktop haha

#

And occasionally use the arch dual boot when I'm too lazy to change to the mac

pliant gulch
slate swan
pliant gulch
#

😔

pliant gulch
#

All my labtops are strictly work related

#

My desktop is my gamer

#

Gotta use that RTX 2060 or it's kind of a waste

sick birch
#

yeah lol. gaming laptops tend to force you to plug them in all the time, which kind of defeats the point

#

My old one couldn't power the components with just the battery so everything I did was framecapped or the performance was horrid

pliant gulch
#

The labtop was decent had it not been for the battery health

#

The person I got it off from didn't keep it plugged in so it just died

#

I could replace but I'm quite lazy

primal token
#

Gaming laptops are like me, They get hot and explode

pliant gulch
#

It's i7 with a few cores

#

GPU is some intel graphics card which kinda sucks

#

But it has more cores and a better CPU than my desktop which is just i5

primal token
#

Females dont explode

sick birch
#

Getting hot and exploding is my favourite pasttime hobby

slate swan
#

Okay guys, I need help.

#

Lets say I have 5 tuples and the range is 0 - 48

primal token
#

second grade roasts😼

slate swan
#

How do I pick a tuple that is not any of those 5 tuples

sick birch
#

I'm not following, how does a tuple have a range? It's not one number?