#discord-bots

1 messages · Page 112 of 1

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.

honest shoal
#

I may not respond later coz it's midnight here

#

will go to sleep anytime soon

#

the value is not an integer in string that's what I can say from error

#

arg

#

whatever you're trying to convert into integer is not an integer like thing

feral frost
#

anyone got an easy database ?

#

thing

slate swan
#
import discord
import random
from discord.ext import commands
from discord_slash import SlashCommand



bot = commands.Bot(command_prefix="!", description = "test")
slash = SlashCommand(bot, sync_commands = True)```
#

Import "discord_slash" could not be resolved

#

how to fix ?

honest shoal
#

remove that 3rd party lib.

#

why not copy paste

#

images are hard to read

slate swan
sharp nest
#

MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured. This may cause limited functionality for prefix commands. If you want prefix commands, pass an intents object with message_content set to True. If you don't need any prefix functionality, consider using InteractionBot. Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.
bot = commands.Bot(command_prefix="!")

import disnake
from disnake.ext import commands
from disnake import TextInputStyle

# Subclassing the modal.
class MyModal(disnake.ui.Modal):
    def init(self):
        # The details of the modal, and its components
        components = [
            disnake.ui.TextInput(
                label="Name",
                placeholder="Foo Tag",
                custom_id="name",
                style=TextInputStyle.short,
                max_length=50,
            ),
            disnake.ui.TextInput(
                label="Description",
                placeholder="Lorem ipsum dolor sit amet.",
                custom_id="description",
                style=TextInputStyle.paragraph,
            ),
        ]
        super().init(
            title="Create Tag",
            custom_id="create_tag",
            components=components,
        )

    # The callback received when the user input is completed.
    async def callback(self, inter: disnake.ModalInteraction):
        embed = disnake.Embed(title="Tag Creation")
        for key, value in inter.text_values.items():
            embed.add_field(
                name=key.capitalize(),
                value=value[:1024],
                inline=False,
            )
        await inter.response.send_message(embed=embed)


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


@bot.slash_command()
async def tags(inter: disnake.AppCmdInter):
    """Sends a Modal to create a tag."""
    await inter.response.send_modal(modal=MyModal())
slate swan
#

and what would be the code then to have slash commands?

sharp nest
#

can help?

slate swan
slate swan
#

thanks

honest shoal
#

ok send the image here

sharp nest
#

?

honest shoal
# sharp nest can help?
intents = disnake.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)```
sick birch
# sharp nest MessageContentPrefixWarning: Message Content intent is not enabled and a prefix ...

MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured. This may cause limited functionality for prefix commands. If you want prefix commands, pass an intents object with message_content set to True. If you don't need any prefix functionality, consider using InteractionBot. Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.

#

The errors are a lot more descriptive and helpful than you may think

honest shoal
#

hold on

slate swan
#

and how can I add something like this where the user has to enter something?

#

@honest shoal

#

where are the functions?

honest shoal
#

@slate swan I guess the error is not in that command

#

it's somewhere later probably

#

are you using pycord?

slate swan
#

hmmmmmmmmmmmmm

#

weird

#

I'm really bad at bot discord so I didn't really understand

primal token
#

!e

print(int("1.3"))
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 | ValueError: invalid literal for int() with base 10: '1.3'
primal token
#

You're passing an incorrect type

honest shoal
#

did u type test in switc parameter

#

switch*

primal token
#

can you show your autopublish command

cloud dawn
#

This code could be so much shorter.

primal token
#

4 nested functions, have you not considered readability with your codebase?

cloud dawn
#

Well I'm seeing some very repetitive code 👀

primal token
#

You really should consider readability and speed with your codebase to get better over "making it work"

#

How did you invoked the slash command?

slate swan
#
import requests
import json

def search(query):
    url = f'https://stockx.com/api/browse?_search{query}'

    headers = {
      'accept': 'application/json',
        'accept-encoding': 'utf-8',
        'accept-language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
        'app-platform': 'Iron',
        'referer': 'https://stockx.com/',
        'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-origin',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.62 Safari/537.36',
        'x-requested-with': 'XMLHttpRequest'
    }

    html = requests.get(url=url, headers=headers)
    output = json.loads(html.text)

    return output['Products'][0]```
#
from cgitb import text
import discord
from discord.ext import commands
from discord import app_commands
from stockx import search

class SlashClient(discord.Client):
    def __init__(self) -> None:
        super().__init__(intents=discord.Intents.default())
        self.tree = discord.app_commands.CommandTree(self)
    
    async def setup_hook(self) -> None:
        self.tree.copy_global_to(guild=discord.Object(id=994970483973967953))
        await self.tree.sync()

client = SlashClient()

@client.tree.command(name="stockx", description="scraping stockx")
@app_commands.describe(product="product")
async def stockx(interaction: discord.Interaction, product: str) -> None:
    query = product
    item = search(query)

    embed = discord.Embed(
        title=item['title'],
        url = 'https://stockx.com/' + item['urlKey']
    )
    embed.set_thumbnail(
        url = item['media']['imageUrl']
    )
    embed.add_field(
        name = 'colourway',
        balue = item['colorway']
    )
    embed.add_field(
        name = 'sku',
        value = item['styleId']
    )
    embed.add_field(
        name = 'last sale',
        value = item['market']['lastSale']
    )
    await interaction.response.send_message(embed=embed)



client.run("token")```
#

ha yes sorry I forget every time

primal token
#

How do you use the slashcommand?

#

with the according arguments?

primal token
#

you need to mention the channel

#

It seems to be a conversion error with your announcementchannel parameter, it seems like you passed a string

#

No, I'm pretty sure its an error with the conversion of the value given to the announcementchannel argument, as dpy converts the value given to the argument to a base 10 int and passes it to a dataclass

#

Yeah sorry, but the issue still applies

north escarp
#

how do I make the team see the error handler that is in another file ?

primal token
#

It's not something wrong with your code, have you tried supplying another value like another id of a textchannel?

#

Yeah, I'm correct, you're passing a string into announcementchannel!

#

Add the typehint again and pass a valid textchannel

north escarp
#
    @commands.Cog.listener()
    async def on_commands_error(self, error):
        if isinstance(error, commands.MissingPermissions):
            embed = discord.Embed(description = 'Вы не являетесь администратором', colour=0xF1C40F)
            await self.ctx.send(embed=embed)
        if isinstance(error, commands.MissingRequiredArgument):
            embed = discord.Embed(description = 'Вы не указали аргумент', colour=0xF1C40F)
            await self.ctx.send(embed=embed)```

why is this command handler not working ?
primal token
#

The converter of dpy and its forks convert the value passed to the argument and type given in this case its TextChannel, by parsing the value, in this case it would parse a mention or it would just use the snowflake passed

primal token
#

and youre missing an argument which would be the error

north escarp
# primal token it's `on_command_error`*

I fixed it and it still doesn't work

    @commands.Cog.listener()
    async def on_command_error(self, error):
        if isinstance(error, commands.MissingPermissions):
            embed = discord.Embed(description = 'Вы не являетесь администратором', colour=0xF1C40F)
            await self.ctx.send(embed=embed)```

the team has only admin rights, and the bot does not issue that message
north escarp
#
    @commands.Cog.listener()
    async def on_command_error(self, error):
        if isinstance(error, commands.MissingPermissions):
            embed = discord.Embed(description = 'Вы не являетесь администратором', colour=0xF1C40F)
            await self.ctx.send(embed=embed)
        if isinstance(error, commands.MissingRequiredArgument):
            embed = discord.Embed(description = 'Вы не указали аргумент', colour=0xF1C40F)
            await self.ctx.send(embed=embed)```

why is this command handler not working ?
slate swan
#

look at the docs

#

your missing an argument

north escarp
slate swan
#

i mean if u would look at them u would understand what is wrong

#

on_command_error(self, something_else_goes_here, error).

#

or just spoonfeed

faint mural
#

sorry

north escarp
#

@slate swan I have tried many times to understand this documentation and it has not brought any results except aggression on the person who wrote it.

slate swan
#

but its a simple fix if you literally just compares urs to the docs?

#

you obviously aren't looking

#

there is a difference in asking for help and then just asking ppl to fix your problems and spoofeed u code.

north escarp
north escarp
# slate swan .

on_command_error(ctx, error)
The first thing I see is this

slate swan
#

yes

primal token
north escarp
# slate swan yes

and I don 't see where it says there about
on_command_error(self, something_else_goes_here, error)

north escarp
north escarp
primal token
primal token
north escarp
slate swan
primal token
north escarp
slate swan
#

ur trolling

#

I have my bot in 2 servers. On the one server, i press on a button and on the other, the bot adds to me a role. The problem is that the bot adds to me the role but at the same time i get error "Missing Permissions". Why's that?

north escarp
slate swan
#

is the bot missing any perms from that channel?

primal token
slate swan
#
Traceback (most recent call last):
  File "C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\view.py", line 423, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\bebro\Documents\Bots\Element Roleplay\cogs\activity_system.py", line 106, in onduty
    await interaction.user.add_roles(onduty)
  File "C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 1014, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "C:\Users\bebro\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 709, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
#

well according to traceback

#

its missing perms to add the role

north escarp
#

@slate swan@primal tokenPython documentation is not created for beginners, but for those who already understand.

sick birch
#

The documentation in itself is really not that hard. It tells you all the methods, which class they belong to, what arguments they take, what they return, and the types of everything

#

Discord.py is also typed quite well so your IDE will usually "self document"

faint mural
#

Hellow,

i am a bit confused about spotify.start|end|duration.
The bar is always filled ;-; ```py
passed = passed.total_seconds()
draw.rectangle((400, 150, 1000, 180), fill=(255, 255, 255), outline=(255, 255, 255))

# 1.0 195.191 195.191 2022-10-22 20:45:46.962000+00:00 2022-10-22 20:42:31.771000+00:00
percentage = passed / (end - start).total_seconds()
print(percentage, passed, (end - start).total_seconds(), end, start)
draw.rectangle((400, 150, 400 + (600 * percentage), 180), fill=color, outline=color)
faint mural
#

gotcha

primal token
north escarp
primal token
north escarp
primal token
#

This isnt an issue with python, it depends on the documentation and there format

sick birch
#

to be fair

#

discord.py documentation is generally known to not be up to par as some of the others

north escarp
slate swan
#

.......

slate swan
#

not in your case lmao

sick birch
#

Though of course discord.py users are biased and will deny it 😛

slate swan
#

plot twist. im a disnake user. this guy just wants code spoon fed to him

north escarp
faint mural
north escarp
north escarp
faint mural
#

It is from the class discord.Spotify

north escarp
#

got it

slate swan
#

or does it just start completely filled?

faint mural
#

starts at: draw.rectangle((400, 150, 1000, 180), fill=(255, 255, 255), outline=(255, 255, 255))
updates at: draw.rectangle((400, 150, 400 + (600 * percentage), 180), fill=color, outline=color)

#

Whitebg, green duration (old image before refactoring LorbWsadOwO )

slate swan
#

i would assume ur math is off somewhere if it is always filled? or the data you are getting is incorrect

faint mural
#
        buffer = await ctx.wrap(
            create_spotify_canvas,
            spotify.title,
            spotify.artist,
            spotify.album,
            spotify.color,
            spotify.start,
            spotify.end,
            spotify.duration,
            artist_image,
            album_image
        )
        image = discord.File(await buffer, filename="spotify.png")


# func
@executor_function
def create_spotify_canvas(
        title: str,
        artist: str,
        album: str,
        color: int,
        start: datetime.datetime,
        end: datetime.datetime,
        passed: datetime.timedelta,
        image: BinaryIO,
        cover: BinaryIO
) -> BinaryIO:
slate swan
#

u using passed to fill it?

north escarp
faint mural
#

Testing and documentation, anyways I use passed = passed.total_seconds() / (end - start).total_seconds() to get the percentage

zealous jay
#

Is this a problem?

[2022-10-22 17:23:46] [INFO    ] discord.gateway: Shard ID None has successfully RESUMED session 24c91643519fceb4b874f3223bbd1710.
#

I get that on the console every once in a while

zealous jay
#

its normal?

glad cradle
#

yes

zealous jay
#

oh ok

#

thanks

slate swan
#

What would be wrong with this? i do the command and i just turns of the bot

#

how can I print all channels?

slate swan
slate swan
slate swan
slate swan
#

how would I return it different

#

1, 2 or
1
2

#

u would need to iterate through them

#

idk how to do that and ive tried alr and got it wrong

slate swan
#

ion know

simple kettle
#

For some reason all my commands dont work and they return no error

faint mural
simple kettle
#

nope

faint mural
#

So what else did you change, before they stopped working?

simple kettle
#

it never worked

#

making a support bot for my main bot

#

and even a simple command will not respond

#
@bot.command()
async def ping(ctx):
    await ctx.channel.send("pong")
#

nothing happens

faint mural
#

Do you have the message content intent enabled?

slate swan
simple kettle
#

for some reason when i try to do intents.message_content = True it says message_content does not exist

slate swan
simple kettle
faint mural
#

Consider updating then

simple kettle
#

i guess i could but this makes no sense, my official bot is not on 2.0 but it works just fine

#

let me try to change the token and see what happens

faint mural
#

again, check your intents

#
  1. Developer portal
  2. message_content = True
simple kettle
#

i fixed it, on the developer portal i turned on all intents i changed no code

#

i needed this one

#

idk why

faint mural
#

I can still recommend you updating your bot

frank pollen
#

hey anyone knows how to update the print? like not printing with new line, it print at same line it will just update old print

bright wedge
# frank pollen

try something like that!,

import sys
import time
steps = 10
print("Total steps: "+str(steps),end=' ')
time.sleep(1)
for i in range(steps):
    sys.stdout.flush()
    print("\rStep "+str(i+1)+"/"+str(steps),end=' ')
    time.sleep(1)
print("")#to change the current line

NOTE: its old code
lucid kite
#

is this actual discord bot code? doesnt seem to be in the right channel

south coyote
#

where can i get a dictionary of intents?

lucid kite
#

or just the meaning of them

wary crystal
#

!e ```py
def example() -> None:
print("foo", end="")
print("bar", end="")

example()

unkempt canyonBOT
#

@wary crystal :white_check_mark: Your 3.11 eval job has completed with return code 0.

foobar
south coyote
#

a good list

wary crystal
unkempt canyonBOT
#

class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").

New in version 1.5.
wary crystal
#

Go to this link, and it'll have all the intents listed under it

#

It'll also explain what the specific intent is for

south coyote
#

no i mean like a dictionary of responses

#

premade

wicked atlas
#

Isn't that one right there?

south coyote
#

yeah just found it

#

are there others?

hushed galleon
#

definitely not what we were thinking when you asked for intents...

south coyote
#

lol

wicked atlas
# south coyote are there others?

Not sure. Asking about this kind of intents in this chat is a little misleading though, because we all thought you were asking about discord intents

south coyote
#

my bad im learning

slate swan
mighty pilot
#

i have a button menu that pops up for people to select a role at a certain level, do you guys think itd look better for the button to be greyed out after selecting it or to just delete the menu after selection

slate swan
mighty pilot
#

each menu only gets used once. follow up question then, when a button is selected i send an ephemeral message, will that still work

slate swan
#

yes

mighty pilot
#

sweet

slate swan
#

you can actually delete ephemeral messages now as well

mighty pilot
#

idek when that would be useful lmao

hushed galleon
#

you could argue that removing the view is a more motion jerky approach since it significantly changes the size of the message

mighty pilot
#

yea thats true. i guess ill see how it looks before committing to it becuase it is 3 buttons on different rows

timid pawn
#

Hello guys, i need an help with a discord_bot i'm working on

#

This is my code:

email_checker = [
  '.com', '.net', '.ru', '.co', '.bru', '.dme', '.me', '.nik', '.email'
]

if message.channel.name == "bot-test" and message.content == '/verify':
      sender = message.author
      msg = f'Hi {sender},  Please provide your email for verification'
      
      overwrites = {
        message.guild.default_role: discord.PermissionOverwrite(read_messages=False),
        sender: discord.PermissionOverwrite(read_messages=True, send_messages=True),
        self.user: discord.PermissionOverwrite(read_messages=True, send_messages=True)
      }

      ticket_channel = await message.guild.create_text_channel(f'{sender} verification', overwrites=overwrites)
      await ticket_channel.send(msg)

      def check(message):
        for email_suffix in email_checker:
          if message.content.endswith(email_suffix) and message.channel==ticket_channel:
            return message.content == "Starting your verification"

So i created a ticket channel to interact with a user, i need to be able to listen for messages after have created the ticket from the user, in the check function, i need to be able to be able to loop the email checker so i can listen for the specific type of message to be returned. And i don't think that is possible or a right implementation, i am open to your suggested implementation

south coyote
#

how do i make my bot only respond to every 5th message

#

or sleep between responses

#

i have it set to respond to every message but that is too much

timid pawn
south coyote
#

can you show me what that looks like in a line of code

timid pawn
#

you just have to input asyncio.sleep(seconds) at where you want the sleep or pause to be

south coyote
#
if message.content.startswith(""):
        response = chatbot.request(message.content[10:])
        await message.channel.send(response)```
#

that's what i have right now

violet kraken
#

hi guys, in discord.py v2 when i say view=Buttons() to display the buttons in the Buttons class, is there a way to exclude a button? so to not display that?

south coyote
#

thanks!

#

NameError: name 'asyncio' is not defined

south coyote
#

okay so i have to import asyncio

#

it's not waiting though

timid pawn
#

you need to input the amount of seconds the wait should be

south coyote
#

yeah i did that

#
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith(""):
        response = chatbot.request(message.content[10:])     
        await message.channel.send(response)
        await asyncio.sleep(600)
#

is there something that will make it sleep with each response?

upbeat gust
#

Why isn't this a seperate view

violet kraken
#

becouse sometime i'll need all of the buttons and sometime just a few

#

it depends on the current event

#

can i include 2 views?

upbeat gust
upbeat gust
#

You could however use a button subclass

#
view = View()
view.add_item(buttonOne())

.send(view=view)```
violet kraken
#

i'm so confused about what im seeing

#

what is that adding 2 views togheter?

timid pawn
upbeat gust
#

It's an empty view, that you add buttons to

#

Instead of having a view that already has buttons

violet kraken
#

that would be useless

upbeat gust
violet kraken
# upbeat gust ..how so?

as i understood its like if i have a variable cald apple with the value of 5 and then i create another one called apple_2 = apple and use apple 2 instead of apple

#

whats the point

upbeat gust
#

what-

violet kraken
#

still same resoult

timid pawn
# upbeat gust is this using wait_for?

i need to make the wait for event message.content be able to check if any of the email_checker values ends the message.content and the run a function when i get the message.content

violet kraken
#

i'm cloning the view

#

same buttons atached

upbeat gust
#

how is this related to what I said

violet kraken
#

i don't know tbh, this is what i understood

upbeat gust
#

I'm understanding that you have multiple buttons, and you want to choose which of these to show up

violet kraken
#

exactly

#

like this bot

#

once i press hit one button disappears

#

becouse its not supposed to be there anymore

upbeat gust
#

so you'd create an empty view

#

then check conditions and add each button accordingly

violet kraken
#

how do i add each button

#

witouth adding them all

upbeat gust
#

buttonOne here is an instance of ui.Button

violet kraken
#

ohhh i throught it was the whole class

#

since i called my buttons

upbeat gust
#

it is a whole class

#

You're referring to a view

violet kraken
#

then how do i specify wich buttons from that class to attach to the new view

#

if i attach them all there is no point

upbeat gust
violet kraken
#

its pretty long, i can make a pastebin if you want

upbeat gust
#

Here's an eg of what you'd do

#
class CounterButton(discord.ui.Button):
  def __init__(self, label='0', **kwargs):
    super().__init__(label=label, **kwargs)
    self.counter = 0

  async def callback(self, interaction: discord.Interaction):
    self.counter += 1
    self.label = self.counter
    await interaction.response.edit_message(view=self.view)

view = discord.ui.View()
view.add_item(CounterButton(style=discord.ButtonStyle.primary))
view.add_item(CounterButton(style=discord.ButtonStyle.success))
view.add_item(CounterButton(style=discord.ButtonStyle.danger))

await ctx.send('Click counter button below', view=view)
south coyote
#

how do i get my bot to wait ten minute between responses?

upbeat gust
south coyote
#

no its not working

south coyote
#
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith(""):
        response = chatbot.request(message.content[10:])     
        await message.channel.send(response)
        await asyncio.sleep(600)
upbeat gust
#

Read your own code

south coyote
#

i know its out of order but why does everybody else get help but not me

upbeat gust
#

because this is a really really simple issue you should be able to solve yourself

violet kraken
#

he definetly does not know this is why he's not telling you

south coyote
#

if i could solve it myself i wouldnt be here

upbeat gust
#

Tell me what each line does

south coyote
#
if message:
        response = chatbot.request(message.content)
        await asyncio.sleep(600)     
    
    await message.channel.send(response)
    
#

like that

timid pawn
upbeat gust
upbeat gust
#

are you using client.wait_for

timid pawn
south coyote
#

i want it to send and then sleep though

upbeat gust
south coyote
#

because i don't want it to respond to every message that comes along only one every ten minutes

upbeat gust
#

oh

#

That is not what you asked lol

#

But ok let's see

south coyote
#

i think this works right?

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message:
        response = chatbot.request(message.content)
        await message.channel.send(response)
    
    await asyncio.sleep(600)
upbeat gust
#

A really easy but bad way is to use time.sleep instead of asyncio.sleep

#

This blocks the whole bot from running

#

If you want to do this the proper way

#

You could store the time that the bot last responded, then on each new message, check if that was ten minutes ago

timid pawn
upbeat gust
#

if you return False, the bot will keep waiting and checking messages

timid pawn
upbeat gust
timid pawn
timid pawn
#
email_checker = [
  '.com', '.net', '.ru', '.co', '.bru', '.dme', '.me', '.nik', '.email'
]

if message.channel.name == "bot-test" and message.content == '/verify':
      sender = message.author
      msg = f'Hi {sender},  Please provide your email for verification'
      
      overwrites = {
        message.guild.default_role: discord.PermissionOverwrite(read_messages=False),
        sender: discord.PermissionOverwrite(read_messages=True, send_messages=True),
        self.user: discord.PermissionOverwrite(read_messages=True, send_messages=True)
      }

      ticket_channel = await message.guild.create_text_channel(f'{sender} verification', overwrites=overwrites)
      await ticket_channel.send(msg)

      def check(message):
        for email_suffix in email_checker:
          if message.content.endswith(email_suffix) and message.channel==ticket_channel:
            return message.content == "Starting your verification"
upbeat gust
#

This isn't your whole code

timid pawn
#

the check would be what i would pass into the wait_for

upbeat gust
#

it's missing relevant parts lik4 the wait_for

timid pawn
upbeat gust
timid pawn
#

but that's where the event listening begins

upbeat gust
#

what

keen iris
#

are u having a bad day? 💀 @upbeat gust

upbeat gust
timid pawn
#

i basically want to be able to listen back for the response sent into the ticket channel created

upbeat gust
#

I don't think you understand

timid pawn
#

yeah, only gone through scenerios in which they are used online and the code i posted was just me trying to see is anything gets returned when initiating the wait_for and calling the check but maybe i don't fully understand it

upbeat gust
#

wait_for Waits for a specific event, when it receives this event it calls the check

The check can either return
True: this is good, I accept this, stop waiting
False: I don't want this, keep waiting

#

you'd return True if the message is an email

timid pawn
#

okay, but the scenerio i need to implement it for, i need the check to be able to have access to the values inside the email_checker so i still need to make a check inside the check function and that is confusing

#

because there's nothing i can compare the message in the wait_for to be True to or False to if i can't use the email_checker as a conditional in the check function.

upbeat gust
timid pawn
#

the response i'm waiting for from the user the bot created the ticket_channel for is an email address and the suffix that should end the message.content(response) is in the email_checker

upbeat gust
#
      def check(message):
        for email_suffix in email_checker:
          if message.content.endswith(email_suffix) and message.channel==ticket_channel:
            return True
    
        return False```
#

Sorry for bad formatting I'm on mobile

timid pawn
#

then how would i instantiate the wait_for

upbeat gust
#

emailmsg = await client.wait_for('message', check=check)

upbeat gust
#

also this isn't a good email checker, use regex

mighty pilot
#

ok i cant figure it out on my own. how do i delete the view after interactions with a button? i assume it would use the clear_items() function but i dont understand how it works i guess

timid pawn
upbeat gust
timid pawn
#

if the message.content ends with the suffixs and the channel == "the ticket channel"

#

hmm...i get it know, thanks for the help @upbeat gust

upbeat gust
#

nvm you can just use

mighty pilot
#

i have a view class with 3 buttons in it

upbeat gust
mighty pilot
#

when a button is pushed, i want it to do all the checks as it does right now, assign roles, delete roles, send an ephemeral message, and delete the view

upbeat gust
#

You can use await self.message.edit(view=None)

upbeat gust
timid pawn
#

@upbeat gust worked great

mighty pilot
#

self has no attribute message

#

self returns my view

timid pawn
upbeat gust
mighty pilot
#

no

#

on_message triggers a message to be sent with the view

upbeat gust
#

I'm not sure what's going on then sorry

mighty pilot
#

i also tried to specify self.message inside the __init__ as the original message but then it tries to edit the message the user sent instead of the message attached to the view Noorowmg

faint mural
#

Why are you not using interaction

upbeat gust
faint mural
#

response.edit_message,
edit_original_response,
...

upbeat gust
faint mural
#

When you send a message with a view, that is whats get edited with original_message, second point is that the other options were just hints how you can use the button callback.

  1. Option is to take self.message and you can edit it with await self.message.edit(**self.send_kwargs)
south coyote
#

what is this?

/home/deusopus/.local/lib/python3.10/site-packages/neuralintents/main.py:97: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  training = np.array(training)
/home/deusopus/.local/lib/python3.10/site-packages/keras/optimizers/optimizer_v2/gradient_descent.py:111: UserWarning: The `lr` argument is deprecated, use `learning_rate` instead.
  super().__init__(name, **kwargs)
royal wind
#

I got a problem. So apparently, it tries to load the cog file, but for some reason, it's not properly loading it... It does not invoke on_ready() function. I did have the setup method in level.py. Is there some mistake I am somehow oblivious to?

south coyote
#

anybody know?

hushed galleon
hushed galleon
hushed galleon
royal wind
#

awaited eh

#

await bot.load_extension('filename.py')

#

?

hushed galleon
#

you will have to move your for-loop to a setup_hook() or main() function as the link describes in order for await to work

royal wind
#

Alright, I'll check that in a moment once I'm done playing

slate swan
#

Can someone help me?

#

Things have happened to my discord bot :p

#
from discord.ext import commands


class Help(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.command(name="help")
    @commands.cooldown(1, 2, commands.BucketType.user)
    async def help_command(self, ctx):
        embed = discord.Embed(
            color=0x5865F2,
            type=("rich"),
            title=('Eclpses help center!'),
            description=('These are all the commands you can do and what perms you need to do them!')
            add_field(name='!help', value='Defualt')
            add_field(name='!joke', value='Defualt')
            add_field(name='!purge', value='Manage Messages')
        )
        await ctx.send(embed=embed)


async def setup(bot: commands.Bot):
    await bot.add_cog(Help(bot))```
#

I do not understand what is wrong

slate swan
#

you should close after description

#

then embed.add_field

#

mk lemme try dat

#

embed param doesn't have an add_field to it. that's method you use after establishing the embed.

#

np.

#

misspelled meh name e_sobbingpuddle

sick birch
royal wind
#

I didn't expect they actually changed it

sick birch
#

setuphook is kind of important from 2.0 and up :p

royal wind
sick birch
#

It's not recommended to do much in on ready

royal wind
#

Ok, I think I fixed it. So how do I run the bot? It used to be bot.run(token), but now I can't do MyBot.run(token)

#

The docs don't specify how to run if I use setup_hook

sick birch
#

running should be the same

#

also you don't need to load the same extension twice

royal wind
#

No, that's the docs

#

It's giving us two ways to do it

sick birch
#
class MyBot(commands.Bot):
  ...

bot = MyBot(...)
bot.run(...)

should work just fine

royal wind
#

Anything going inside MyBot()?

sick birch
#

that's up to you

#

there are a few different approaches

royal wind
#

It still doesn't load it for some reason

sick birch
#

Option 1

class MyBot(commands.Bot):
  def __init__(self) -> None:
    # define intents and everything else here
    super().__init__(command_prefix="!", intents=intents, ...)
bot = MyBot() # no arguments necessary
bot.run()

Option 2

class MyBot(commands.Bot):
  def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
bot = MyBot(command_prefix="!", intents=intents, ...) # notice how all your arguments are here now?
bot.run()
royal wind
#

Ah

sick birch
#

Maybe the splitting logic is faulty

royal wind
#

Ok, so either those __init__ is passed and using the normal parent's __init__ or the custom __init__ where we do the intents there before calling the parent's __init__

sick birch
#

If you haven't learned about *args, **kwargs yet, it's basically saying: "take everything inside of the parenthesis () and pass it straight to super().__init__() without messing with it"

royal wind
royal wind
#

It's loaded... so fingers crossed. I will check

sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

{'name': 'John Doe', 'age': 42, 'occupation': 'Software Engineer'}
royal wind
sick birch
#

yup, kwarg order doesn't matter

royal wind
#

So I can pass, to the same function, age=42, name="john doe", etc

sick birch
#

that's correct

royal wind
#

Aye! Thank you. Now on to fixing a ValueError inside my level.py. Thanks for the help

sick birch
#

Feel free to ask if you need help with that

royal wind
#

I might, but I want to spend a bit of time trying to debug first.

#

Thank you!

sick birch
#

No worries

royal wind
#

It says ValueError from this line

#

Does it mean I need to convert it to str() first?

#

I don't assume it has to, otherwise, we'd have the problem that I talked with someone here where SQL would just essentially be blind and be subject to sql injection attack..

#

Ah, never mind. I think it can afford to be picky and only take string while at the same time not be subject to that attack

#

OK, I need help Robin!

slate swan
#

I have a question for a cog cmd

#

how would i make it if someone uses the command "!help" it deletes their message?

#

then sends text which I know

#

I searched it on google and yt but they are for slash cmds in the main file ```py
import discord
from discord.ext import commands

class Help(commands.Cog):
def init(self, bot: commands.Bot):
self.bot = bot

@commands.command(name="help")
@commands.cooldown(1, 2, commands.BucketType.user)
async def help_command(self, ctx):
    embed = discord.Embed(
        color=0x5865F2,
        type=("rich"),
        title=('Code Assist\'s help center!'),
        description=('These are all the commands you can do and what perms you need to do them! If you need more support go [here](http://www.code-assist.ca)')
        )
    embed.add_field(name='!help', value='Defualt')
    embed.add_field(name='!joke', value='Defualt')
    embed.add_field(name='!purge', value='Manage Messages')
    

    await ctx.send(embed=embed)

async def setup(bot: commands.Bot):
await bot.add_cog(Help(bot))```

vale wing
slate swan
#

a ok

vale wing
#

Also pretty sure there's no need for type kwarg in Embed constructor in this case

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
vale wing
#

Type is rich by default

slate swan
#

o

#

what other types are there? I only know rich..

vale wing
slate swan
#

so would the cmd be this?

    @commands.command(name="help")
    @commands.cooldown(1, 2, commands.BucketType.user)
    async def help_command(self, ctx):
        await ctx.message.delete()
        embed = discord.Embed(
            color=0x5865F2,
            title=('Code Assist\'s help center!'),
            description=('These are all the commands you can do and what perms you need to do them! If you need more support go [here](http://www.code-assist.ca)')
            )
        embed.add_field(name='!help', value='Defualt')
        embed.add_field(name='!joke', value='Defualt')
        embed.add_field(name='!purge', value='Manage Messages')
        

        await ctx.send(embed=embed)
vale wing
#

Why are you using those unnecessary braces

slate swan
#

Just makes it easier on my eyes

vale wing
#

"Defualt" is not the correct spelling, "Default" is

slate swan
#

I keep messing up on that 😫

vale wing
slate swan
#

mk

#

ty for the help

#

wait

#

do u know how to make slash cmds in cogs?

#

I tried it but it only works in main.py

vale wing
#

I think so tho I don't have experience with dpy

slate swan
#

o

vale wing
#

!d discord.app_commands.command

unkempt canyonBOT
#

@discord.app_commands.command(*, name=..., description=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command from a regular function.
vale wing
#

With this deco

slate swan
#

oki

slate swan
wheat walrus
#
Traceback (most recent call last):
  File "main.py", line 9, in <module>
    bot = commands.Bot(command_prefix='!')
TypeError: __init__() missing 1 required keyword-only argument: 'intents'```

what its worng ?
paper sluice
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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
slate swan
wheat walrus
#

ok

#

ty sir

slate swan
#

who?

wheat walrus
slate swan
#

ima girl lul

#

that's hair

wheat walrus
#

-,-

royal wind
#

Did they recently change the embed color system as well?

slate swan
#
     embed = discord.Embed(
            color=0x97FEEF
     )
#

try that

royal wind
#

Yeah, I'll do that once pycharm stop freezing on me

slate swan
#

k, lul

#

tell meh if it works?

royal wind
#

It works, but on to another problem...

#

I swear this used to work

slate swan
#

hmmm

vale wing
#

"0x97FEEF" is a string, you need hex representation of int, basically done without quotes 0x97FEEF

#

!e print(0x97FEEF)

unkempt canyonBOT
#

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

9961199
paper sluice
royal wind
upbeat gust
#

You need Asset.url

upbeat gust
slate swan
#

nope :p

upbeat gust
royal wind
slate swan
#

googled stuff but I dont wanna use tree :/

upbeat gust
#

Soo what's going on

slate swan
#

kinda gave up sunglas

upbeat gust
#

uh ok then do you want to fix it or not

slate swan
#

I do

dull knot
#

Been awhile last I visited here. Got a question.

What's the object/method or whatever it's called to add stickers to a guild?
I'll try making a sticker-add cmd

upbeat gust
unkempt canyonBOT
#

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

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

You must have [`manage_emojis_and_stickers`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_emojis_and_stickers "discord.Permissions.manage_emojis_and_stickers") to do this.

New in version 2.0.
dull knot
#

Alright. Ima try this later. Thanks!

#

The same goes for emojis, right?

Guild.create_emoji?

upbeat gust
upbeat gust
dull knot
#

I don't think the Stickers option's been added in CPs yet

#

Plus, I found it to be more efficient (Especially with emojis)

upbeat gust
solar garnet
#

one of announcementchannel or ctx.guild appear to be a string..

#

perhaps, print out what announcementchannel and ctx.guild are before the line that causes the error

#

I don't know what that means :)

#

Ah, does this autopublish messages in that channel

south coyote
#

im looking for an open source discord tipbot that is compatible with tokens built on avalanche blockchain. can anyone direct me?

solar garnet
#

what are you doing to enable it? is it code that run sin your code or is it a setting on the channel?

#

so, I assume somewhere in your code you are tracking whether or not autopublish should be on or off. and the bot checks that to see if it should publish a message?

#

if the bot is still publishing, you probably need to print out what that state is before the bot publishes

#

it's either reading that state wrong, or the state is not being written (turned off)

empty frigate
#

lets say I am getting a string from somewhere called action and its value is "blur"
The actual command is img.blur(20)
but since im getting value from action I need to do
img.action(20)
but I get error
action is not a function
so how do I solve that
how do I put blur instead of "blur" if you know what i mean

upbeat gust
empty frigate
#

nvm I got my answer

north escarp
#
    @commands.Cog.listener()
    async def on_command_error(self, error):
        if isinstance(error, commands.MissingPermissions):
            embed = discord.Embed(description = 'Вы не являетесь администратором', colour=0xF1C40F)
            await self.ctx.send(embed=embed)
        if isinstance(error, commands.MissingRequiredArgument):
            embed = discord.Embed(description = 'Вы не указали аргумент', colour=0xF1C40F)
            await self.ctx.send(embed=embed)```

why is this command handler not working ?
#
Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\...\Desktop\проекты на Python\disocrd bot python\cogs\event.py", line 26, in on_command_error
    if isinstance(error, something_else_goes_here, commands.MissingPermissions):
TypeError: isinstance expected 2 arguments, got 3```
upbeat gust
#

your code doesn't match the error

outer flint
#

anything you see wrong with this? thinko

import disnake
from disnake.ext import commands


class ADM(commands.Cog):
    """Botmakers functions"""

    def __init__(self, bot):
        self.bot = bot

    @adm.command()
    async def servers(self, ctx, payload):
        """Returns a list of the servers the bot is in"""
        guild_lst = payload.guilds
        for guild in guild_lst:
            await ctx.send(guild)

I have the whole commands.group after the def __init__ thinko

outer flint
#

when I write +adm servers the bot doesn't reply thinko

upbeat gust
outer flint
outer flint
# upbeat gust Idk disnake but in dpy its `@commands.command()`

nah the command creation is correct [as in ti should be @adm.command()], I think the "payload" is wrong there thinko

class ADM(commands.Cog):
    """Botmakers functions"""

    def __init__(self, bot):
        self.bot = bot

    @commands.group(case_insensitive=True, invoke_without_command=True)
    async def adm(self, ctx):
        """Greets the maker... or condemns the pretender"""
        if ctx.invoked_subcommand is None:
            author_roles = ctx.author.roles
            if any(
                role.name in {"Botmakers", "Admin", "Moderators", "Staff", "Lead Devs"}
                for role in author_roles
            ):
                await ctx.send("Hello, my blessed masters!")

    @adm.command(pass_context=True)
    async def clean(self, ctx, *, amount: str):
        """Cleans the command message and the specified number of messages before it"""
        author_roles = ctx.author.roles
        if any(
            role.name in {"Botmakers", "Admin", "Moderators", "Staff", "Lead Devs"}
            for role in author_roles
        ):
            await ctx.channel.purge(limit=int(amount) + 1)

    @adm.command()
    async def servers(self, ctx, payload):
        """Returns a list of the servers the bot is in"""
        guild_lst = payload.guilds
        for guild in guild_lst:
            await ctx.send(guild)
shrewd apex
#

the payload is not automatically created

shrewd apex
#

u have to input the payload if u are putting it in as a command arg

upbeat gust
#

it's @commands.command(), as I said

outer flint
#

I have like 10-15 bots cogs in that way and they all work thinko

upbeat gust
#

oh wait shit its a group

outer flint
#

yeah thinko

upbeat gust
#

Yeah didn't see that before

outer flint
#

here, maybe it's clearer thinko

upbeat gust
outer flint
#

let me see... cause I used to have it, but then we disabled it when we went from discord to disnake thinko

upbeat gust
#

you definitely should be getting an error

upbeat gust
outer flint
#

I think I found another way thinko

#

moved to the bot.command() in this way it can directly use the bot.guilds thinko
although I think there's a better way to write it thinko

@bot.command()
@commands.has_role("Botmakers")
async def servers(ctx):
    guild_lst = bot.guilds
    for guild in guild_lst:
        await ctx.send(guild)
glad cradle
upbeat gust
glad cradle
brazen raft
#

Also you should put the names together in one string and send that so you don't get rate limited

outer flint
#

the bot can get rate-limited? I never had that happen thinko
but yeah usually we group all of the stuff into one message thinko

brazen raft
upbeat gust
#

You only get an error if you really fuck up

outer flint
brazen raft
#

The library automatically limits message sends to five per five seconds

#

Ever tried spamming once yourself?

outer flint
#

tbh... no kek

upbeat gust
#

not even spamming just like sending 5-10 messages in a row

vale wing
#

I once decided to delete all slash commands one by one for absolutely no reason with raw requests and got ratelimited

pastel mist
#

How do I play an audio file in a voice channel without using FFMPEG?
What I am trying to do: I am trying to use Google TextToSpeech (gTTS) and make the bot say something in a voice channel without storing any audio files

brazen raft
#

You can write it to an io.BytesIO object with

from io import BytesIO
with BytesIO() as buffer:
    gTTS_instance.write_to_fp(buffer)
    # play it in a voice channel

Actually playing sounds in voice channels is beyond me

#

You might want to seek to the beginning of the buffer with buffer.seek(0) so it also reads the buffer from the beginning

cold needle
#

hey im currently trying to send my csv file via my discord bot in a channel

#

with but in discord the file just shows

#

... (NaN KB left)

#

someone know what the issue could be?

pastel mist
#

How do I make the bot leave vc after it finishes playing an audio file?

slate swan
#
async def open(ctx):
    guild = ctx.guild
    member = ctx.author
    staff = discord.utils.get(ctx.guild.roles, name="🧥・𝙾𝚠𝚗𝚎𝚛")
    ticket = discord.Embed(title="McBott", description=f"► ``TICKETS``: __Oppened__ :boom: \n \nThanks for contacting support, {member.mention} here at **McBott**. Our amazing staff members will be with you shortly and hope to slove your issuses. If you have any information leave it below.")
    ticket.set_footer(text="☆ Developer Matija#5983 ☆")
    if ctx.channel.name == f'ticket-{ctx.author}':
        return ctx.send("You already have ticket")
    else:
        channel = await guild.create_text_channel(name=f"ticket-{member.name}")
        await channel.set_permissions(ctx.guild.default_role, read_messages=False)
        await channel.set_permissions(member, read_messages=True)
        await channel.set_permissions(staff, read_messages=True)
        await channel.send(embed=ticket)
        await ctx.channel.send("Ticket successfully made")```
why this didnt work i can make multiple channels
bright wedge
slate swan
#

i can create channels

bright wedge
#

What we trying to do?

slate swan
#

i need to block it

#

ex i can spam $open command and it will be create channels

bright wedge
#

check the category channels

#

and then check if channel exist

slate swan
bright wedge
#
define ticket category
for channel in category.text_channels:
    if channel.name == etc....
bright wedge
#

you wanna check all channels

#

Not the ctx.channel

slate swan
#

@bright wedge and dont work

bright wedge
slate swan
#
async def open(ctx):
    guild = ctx.guild
    member = ctx.author
    staff = discord.utils.get(ctx.guild.roles, name="🧥・𝙾𝚠𝚗𝚎𝚛")
    ticket = discord.Embed(title="McBott", description=f"► ``TICKETS``: __Oppened__ :boom: \n \nThanks for contacting support, {member.mention} here at **McBott**. Our amazing staff members will be with you shortly and hope to slove your issuses. If you have any information leave it below.")
    ticket.set_footer(text="☆ Developer Matija#5983 ☆")
    for channel in ctx.message.guild.text_channels:
        if channel.name == "ticket-matija":
            return
        channel = await guild.create_text_channel(name=f"ticket-{member.name}")
        await channel.set_permissions(ctx.guild.default_role, read_messages=False)
        await channel.set_permissions(member, read_messages=True)
        await channel.set_permissions(staff, read_messages=True)
        await channel.send(embed=ticket)
        await ctx.channel.send("Ticket successfully made")
        return```
bright wedge
#

Question

#

You wanna open all this tickets in specific category?

slate swan
balmy bobcat
#

hi, do you know a good discord bot hosting website? I'd like to host my bot and a mariaDB database for it (if possible, not too expensive)

faint mural
#

hetzner

brazen raft
worldly ridge
#

hey does anyone know how to make a discord bot tool that let's you control a bot and it asks you a channel ID, you type it in, and then a message ID, you type it in, and then the bot reacts to the message. (the message already has a reaction)

bright wedge
#

name use your string for check

slate swan
bright wedge
#

Brother

bright wedge
#

I send you how must be

#

You must check the guild channels,not the context channel

shrewd apex
#

use channel id who uses name

bright wedge
#

Is wrong if statement

shrewd apex
#

map channel ids to user ids

slate swan
bright wedge
#

...

#

Can't make you understand sorry

worldly ridge
#

for tokens, how can I control 2 accounts instead of 1

worldly ridge
bright wedge
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

stone field
#

can someone help me make this work? im trying to make it so that only my accounts id can use the command nobody else

async def shutdown(ctx, message):
    if discord.Member.id == "696202168390385734":
        await ctx.send("Shutting down in 5 seconds...")
        time.sleep(5)
        exit()
    else:
        await ctx.send("You are not authorized to run this commmand!")```
vale wing
#

fetch(0) maybe fetch[0]?

bright wedge
#

and do not change the id to string

bright wedge
#

Then you don't have nothing on tuple

stone field
slate swan
#

you can't convert that data to a dictionary

vale wing
#

Are you sure Image.text is a method

gloomy meadow
#
import discord
from discord.ext import commands
from utils import Control
import utils


class Bot:
    TOKEN = utils.PASSWORD

    def __init__(self):
        intents = discord.Intents.default()

        self.bot = commands.Bot(commands_prefix='!', intents=intents)

    def run(self):
        self.bot.run(Bot.TOKEN)

    


def launch():
    bot = Bot()
    bot.run()


if __name__ == '__main__':
    launch()

I seriously can't figure out why I'm getting this error

TypeError: BotBase.__init__() missing 1 required positional argument: 'command_prefix'```
paper sluice
#

its command_prefix not commands_prefix

gloomy meadow
#

I'm blind oh my god

#

thank you

vocal snow
#

Print role and you'll see why

slate swan
#

can anyone help me im really stuck

@client.command()
async def spy(ctx, channel: int):
  await ctx.message.delete()
  user = ctx.author
  client.spy = channel
  await user.send(f"**Channel:** <#{channel}>")
#

so I have this and it works

#

but I dont want the client.spy variable to reset when I restart the bot

#

I was thinking to open a file and set the client.spy to that but idk how and the docs are confusing

vocal snow
#

Have you done any sort of file i/o before?

slate swan
slate swan
#

ill try

#

i dont really learn good reading by myself

vocal snow
#

You can also look up "file i/o with python" and you'll get a lot of resources

slate swan
#

I dont belive its this easy 💀

vocal snow
slate swan
#
with open("spy",'r',encoding = 'utf-8') as f:
  read_data = f.read()
  client.spy = read_data
vocal snow
#

That's a good start

#

But you need client.spy to be a TextChannel, not a str

slate swan
#

its a channel id

vocal snow
#

Yes... So do you think that would work for utils.get?

vocal snow
#

It wouldn't, exactly

#

You need to pass a valid role name to utils.get

#

And anyways, you shouldn't be using role names for this

vale wing
#

Well I just scrolled through their docs, there's no such method at all

#

!d PIL.Image.Image

unkempt canyonBOT
#

class PIL.Image.Image```
This class represents an image object. To create [`Image`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image "PIL.Image.Image") objects, use the appropriate factory functions. There’s hardly ever any reason to call the Image constructor directly.

• [`open()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.open "PIL.Image.open")

• [`new()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.new "PIL.Image.new")

• [`frombytes()`](https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.frombytes "PIL.Image.frombytes")
vale wing
#

ImageDraw does have it tho

vocal snow
#

(set(after.roles)-set(before.roles)) gives you a set of Role objects

#

You don't need utils.get at all

#

If you want a string of the role names just use .name

slate swan
vocal snow
vale wing
#

!d PIL.ImageDraw.ImageDraw.text

unkempt canyonBOT
#

ImageDraw.text(xy, text, fill=None, font=None, anchor=None, spacing=4, align='left', direction=None, features=None, language=None, stroke_width=0, stroke_fill=None, embedded_color=False)```
Draws the string at the given position.
faint mural
#

!d PIL.ImageDraw.Draw

unkempt canyonBOT
#

PIL.ImageDraw.Draw(im, mode=None)```
Creates an object that can be used to draw in the given image.

Note that the image will be modified in place.
slate swan
#

@vocal snow

#

when i do $spy id

#

it will work but when I restart the bot it doesnt

#

and the client.spy is the channel id

worldly ridge
# vale wing What

basically in my visual code, I'm tryna make it so that I can control 2 bots in one script

vale wing
#

Why

#

Better run 2 processes

slate swan
#

yea why

vale wing
#

2 bots in one script is not really a good idea

hushed galleon
#

i dont see anything wrong with doing that for small bots

magic orbit
#

hello. I'm trying to make a level bot, but it doesn't work. It supposed to add the userID in users.json, and then update the experience, and level, but it doesn't work.

What happens is that when I send a message, it adds my ID (so far it's ok), but then instead of rewriting the experience, it adds the ID again. After that nothing happens
(I'll send the code in a min)

#
import discord
import json
import os
from discord.ext import commands

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

client = commands.Bot(command_prefix='|', intents=intents)

@client.event
async def on_ready():
    print('Bot online')

@client.event
async def on_member_join(member):
    with open('users.json', 'r') as f:
        users = json.load(f)

    await update_data(users, member)

    with open('users.json', 'w') as f:
        json.dump(users, f)

    
@client.event
async def on_message(message):
    with open('users.json', 'r') as f:
        users = json.load(f)

    await update_data(users, message.author)
    await add_experience(users, message.author, 7)
    await level_up(users, message.author, message.channel)

    with open('users.json', 'w') as f:
        json.dump(users, f)

async def update_data(users, user):
    if not user.id in users:
        users[user.id] = {}
        users[user.id]['experience'] = 0
        users[user.id]['level'] = 1

async def add_experience(users, user, exp):
    users[user.id]['experience'] += exp

async def level_up(users, user, channel):
    experience = users[user.id]['experience']
    lvl_start = users[user.id]['level']
    lvl_end = int(experience ** (1/4))

    if lvl_start < lvl_end:
        await client.send_message(channel, '{} has levelled up to level {}'.format(user.mention, lvl_end))
        users[user.id]['level'] = lvl_end

client.run('token')```
hushed galleon
magic orbit
#

yep

hushed galleon
#

again, what does that file look like afterwards? do you also get any error message in the terminal?

slate swan
#

@hushed galleon can you help me with something that should work but doesnt?

hushed galleon
#

you can just ask the question, if i know i can answer

slate swan
#
  with open("spy.txt",'r') as f:
    best = f.read()
    client.spy = best
    print(client.spy + " spy")
    print(best + " best")
@client.command()
async def spy(ctx, channel: int):
  await ctx.message.delete()
  user = ctx.author
  client.spy = channel
  with open("spy.txt",'w') as f:
    f.write(f"{channel}")
  await user.send(f"**Channel:** <#{channel}>")
#

so all this works fine except when I reload the bot

#

if I do $spy id then it will start logging the chats

#

but if I restart the bot it doesnt?

hushed galleon
slate swan
#

and now it wont work if i do $spy

hushed galleon
slate swan
#

on_ready

#
  if message.channel.id == client.spy:
    if message.author != client.user:
      sp = client.get_channel(1033452318936551464)
      em = discord.Embed(title='SENT', description=f"**Author:** {message.author}\n**Message:** {msg}\n**Guild:** {message.guild}\n**Channel:** <#{message.channel.id}>\n**Category:** {message.channel.category}\n[Jump](https://discord.com/channels/{message.guild.id}/{message.channel.id}/{message.id})",color=0xFB03F0,timestamp=datetime.datetime.utcnow())
      await sp.send(embed=em)
#

this is how im logging messages

#

with on_message

hushed galleon
#

it seems like there's a type mismatch you have with client.spy

#

f.read() returns a string, not an integer

slate swan
#

would make sense

hushed galleon
#

you'll need to convert it back to an integer before you can compare the channel id

slate swan
#

how would i do that? I read the docs and didnt see anything

#

int(best)?

hushed galleon
#

yeah

slate swan
#

wait wait

#

can I do

#

best = f.read()
best = int(best)

#

would that work?

hushed galleon
#

sure

slate swan
#

alr ill test thank you!

ripe blaze
#

I was wondering why bot.get_user(ID) works fine in the main file but for some reason doesnt work at all when used inside a cog

hushed galleon
#

perhaps you're mixing up multiple bot instances

#

bot by itself typically isnt a variable a cog would have access to (assuming the cog is defined in a separate file and loaded through dpy's extension mechanism)

slate swan
#

thank you so much!!!

hushed galleon
#

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

slate swan
#
      if message.channel.id != client.spy:
#

I added this and it broke it

hushed galleon
#

were you meaning to check if the channel id is not equal to your spy attribute?

slate swan
#

wait I dont even need to add it 🤦

hushed galleon
slate swan
#
        async def reaction(otherinteraction: discord.Interaction):
            cstmid = str(otherinteraction.data['custom_id'])
            if buttonlist[cstmid]["price"] == 0:
                buttonlist[cstmid]["button"] = wrong
            else:
                buttonlist[cstmid]["button"] = Button(label=str(buttonlist[cstmid]["price"]), style=discord.ButtonStyle.green)

            newview = View(timeout=None)
            for i in range(0, 25):
                btn = buttonlist[str(i)]["button"]
                btn.callback = reaction
                newview.add_item(btn)

            await interaction.edit_original_response(content="Bet: 250", view=newview)
            await otherinteraction.response.defer()





        # setting vars
        buttonlist = {}
        setvalues = []
        view = View(timeout=None)
        wrong = Button(label="", emoji="⬛", custom_id="wrong", style=discord.ButtonStyle.danger)


        # generate buttons
        for i in range(0, 25):
            button = Button(label="", emoji="⬛", custom_id=str(i), style=discord.ButtonStyle.grey)
            buttonlist[str(i)] = {"button": button, "price": 0}


        # setting values
        for i in range(0, 5):
            x = str(random.randint(0, 25))
            while x in setvalues:
                x = str(random.randint(0, 25))
            setvalues.append(x)
            buttonlist[x]["price"] = random.randint(25, 300)


        # creating view
        for button in buttonlist:
            sample = buttonlist[button]["button"]
            sample.callback = reaction
            view.add_item(sample)


        await interaction.response.send_message("Bet: 250", view=view, ephemeral=True)```
im trying to make a little game and its working fine except that after clicking 2-3 buttons the interaction will stop working, does anyone know why?
ripe blaze
hushed galleon
#

so you do have multiple bot instances

#

the cog file shouldnt define its own commands.Bot at the top

ripe blaze
#

how do I reference the one in the main file?

#

or is there another way to do it?

hushed galleon
#

the setup function is what provides the bot instance that loaded the extension, and you've already assigned it to self

#

so self.bot is how you'd access that instance in your command

ripe blaze
#

oh

#

thanks!

silent portal
#

Hey, can my Bot Token get stolen when it's directly in the main.py file? Should I use an extra .txt file for that?

winged coral
#

Define stolen

#

If it's not going anywhere other than your PC then there's no difference

#

If you're gonna put it on github or someplace like that, it would help

#

Because you can gitignore the extra file and leave the main

silent portal
#

no it will just be on my private server

#

and ofc I won't share my token with any1

#

but idk i was just wondering

slate swan
#
import discord
from discord.ext import commands

intents=discord.Intents.all()

token = 'my bots token is here'
prefix = '.'
bot = commands.Bot(command_prefix=prefix, intents=intents)

bot.remove_command('help')

@bot.event
async def on_ready():
    print("BOT IS READY")


bot.run(token)```

**Does anyone know how to fix this error**
#
2022-10-23 12:33:41 INFO     discord.client logging in using static token
Traceback (most recent call last):
  File "c:\Users\mic\Desktop\Snoopy\Snoopy.py", line 18, in <module>
    bot.run(token)
  File "C:\Users\mic\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 828, in run
    asyncio.run(runner())
  File "C:\Users\mic\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\mic\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\mic\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 817, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\mic\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 746, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\mic\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 672, in connect
    raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
PS C:\Users\mic>```
cloud dawn
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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
cloud dawn
#

Yes

slate swan
#

How do I put it into my code?

cloud dawn
slate swan
#

where do i put it and what do i remove

#

alr

cloud dawn
#

Compare the example with yours.

slate swan
#

I just did and it gave me same error

#
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.```
cloud dawn
#

Code?

slate swan
#
from discord.ext import commands

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

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

token = 'my bots token here'
prefix = '.'
bot = commands.Bot(command_prefix=prefix, intents=intents)

bot.remove_command('help')

@bot.event
async def on_ready():
    print("BOT IS READY")


bot.run(token)```
cloud dawn
#

Have you gone to the develops portal?

slate swan
#

yea?

#

im in it rn

cloud dawn
#

Did you enable your intents?

slate swan
#

no

#

idk how

#

@cloud dawnFixed it ty

slate swan
cloud dawn
#

Oki

ionic edge
#
import datetime
timesec = datetime.datetime.now()
print(timesec)```
how to convert it to integer
2022-10-23 23:10:43.496526
faint mural
#

total_seconds()

white citrus
torn sail
#

is it possible to fetch a message without knowing the channel id?

glad cradle
zinc otter
#

You need the channel to fetch it

glad cradle
#

and

gloomy meadow
#

oh my god my text was deleted bruh

#

sec lemme write it again :/

glad cradle
#

ok

gloomy meadow
#

I made a discord bot and told my friends to spam commands in order to test it.
The commands are taking time to execute as they're performing certain tasks which cause it. This is intentional.
How can I do so that once a command is executed, until its execution is over, all the other commands will be ignored. With that being said, let's say I ran a command list, until the command's function finishes its execution no other command shall be noticed. So if someone writes another command before that previous command finishes its execution, it will simply be ignored and never executed.

#

how do I accomplish that?

sick birch
gloomy meadow
#

I figured that out yeah

#

I understand what I'm asking for is basically wrong

#

but does discord bot support synchronous programming?

sick birch
#

You could set some sort of state that indicates if the bot should ignore commands, and a global commands check that only processes commands if that state is false

gloomy meadow
#

yeah

#

I thought about that as well

sick birch
#

Is there a reason that wouldn't work?

gloomy meadow
#

so basically it works, but I would have actually loved if it'd print out a message that another command is in execution

sick birch
#

You should be able to do that in a global check no problemo

gloomy meadow
#

well I did, but the message is delayed

#

I mean, sure, it informs the user, but late

#

and don't mind the last 2 lines

#

they're simply there because I forgot to return

#

the point is that it waits for the previous command to finish, before informing of another command being executed

#

as it is asynchronous after all

glad cradle
#

what?

gloomy meadow
#

let me explain

glad cradle
#

An asynchronous function does not wait for the result of another function, those are synchronous functions

gloomy meadow
#

running first command -> execution in progress
running second command while first is still in progress -> nothing happens
first finishes -> outputs
now since first finishes, second is able to output that it can't run because another command is already in execution

gloomy meadow
#

ah nvm

#

I'll give up on that message and just have it ignore duplicates

slate swan
#

anybody have a code to make discord bot send a message every hour or so

sick birch
unkempt canyonBOT
#

class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.

The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
slate swan
sick birch
#

we don't do that here

slate swan
#

oh

#

ok

thorn oracle
#

Hey I'm trying to create a bot that displays the price of Bitcoin as its username. So far I found an API, and now I'm trying to figure out what my next steps are. Could someone help me figure this out?

slate swan
#

rename the bot with the price

stone field
#

hello, how do i add the thumbnail in my embed? i must be forgetting something embedVar = discord.Embed(title=f"Grabbed `{message}'s` NameMC profile.", description=f"{r.json()['uuid']}", thumbnail=f"https://mc-heads.net/body/{message}/right", color=0x00ff00)

#

nvm i figured it out

worthy beacon
#
import discord

from discord.ext import commands

#----
tokenfile = 'token.txt'
with open(tokenfile) as tf:
    line = tf.readline()
    TOKEN = line.rstrip()
#----

bot = commands.Bot(command_prefix='$')

@bot.command(name='99', help='Responds with a random quote from Brooklyn 99')
async def nine_nine(ctx, member : discord.Member):
    brooklyn_99_quotes = [
        'I\'m the human form of the 💯 emoji.',
        'Bingpot!',
        (
            'Cool. Cool cool cool cool cool cool cool, '
            'no doubt no doubt no doubt no doubt.'```
#

is this correct like that

thorn oracle
stone field
thorn oracle
stone field
thorn oracle
slate swan
#
@client.command()
async def channels(ctx):
  channel = list(ctx.guild.channels)
  c = str(channel)
  em = discord.Embed(title='ALL CHANNELS/CATEGORYS', description=f"channels\n{c}")
  await ctx.send(embed=em)
#

how do I return this more clean

#

why aint this working? i have 0 errors


@client.command(name="commands")
async def _commands(ctx):
    await ctx.send("commands: ")

#

why do ppl do it like that so weird

slate swan
#

client = commands.Bot (command_prefix = '/')

slate swan
#

do you have the intents

, intents=discord.Intents.all()
#

obv u dont need all

slate swan
#

try putting intents

slate swan
#

error?

#

none

#

want me 2 send u my code?

#

yea

shut rock
slate swan
#

if i knew what to do with it 😂

white citrus
#
            button = nextcord.ui.Button(label="Show all Roles", style=nextcord.ButtonStyle.blurple)

            e_view = nextcord.ui.View(timeout=None)
            e_view.from_message(interaction.message, timeout=None)
            
            async def button_callback(interaction):
                embed_roles = nextcord.Embed(title="Roles", description="\n".join(reversed([f'> {r.mention}' for r in filter(lambda role: not role.is_default(), member.roles)])))

                button.disabled = True
                button.style = nextcord.ButtonStyle.grey
                await interaction.edit_original_message(embeds=[userinfo, embed_roles], view=e_view(interaction.message, timeout=None))
            
            async def button_timeout(interaction):
                button.disabled = True
                button.style = nextcord.ButtonStyle.grey
                await interaction.edit_original_message(view=e_view)  
            
            button.callback = button_callback
            button.timeout = button_timeout
            
            view = nextcord.ui.View()
            view.add_item(button)
#
Traceback (most recent call last):
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 502, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\bot.py", line 209, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 863, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\cooldowns\cooldown.py", line 93, in inner
    result = await func(*args, **kwargs)
  File "c:\Discord\Maja Projekt\MajaSystem_Test\modules\information\cog.py", line 192, in userinfo
    e_view.from_message(interaction.message, timeout=None)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\view.py", line 260, in from_message
    for component in _walk_all_components(message.components):
AttributeError: 'NoneType' object has no attribute 'components'```
shut rock
#

@slate swan

guild = ' '.join(map(str, await bot.rest.fetch_guild_channels(guild_id)))
#

something, like this

#

wait

#

i'm thinking of a whole different library not discord.py

shut rock
slate swan
#

hi im making a dm command how would i make the bot say dmd user?

slate swan
#

but idk what i should put inside (user)

shut rock
#

do you want it to print out to the channel?

slate swan
#

yes

shut rock
#

oh

#

you want it to say the users name#1234

#

show code

slate swan
whole kite
#

it was working yesterday but all of a sudden its not working anymore

sick birch
#

If so, the command is ??roots

whole kite
#

right

#

thanks

#

how do i put an image into a discord embed

faint mural
#

local image or url?

whole kite
#

url

#

can u show me both?

faint mural
#

set_image(url=...)
set_thumbnail(url=...)

whole kite
#

o0k

faint mural
#

You can use local images

#

but that works a bit different

whole kite
#

thanks

south coyote
#
import discord
from discord.ext import commands
import random

bot = commands.Bot(command_prefix="random", intents=discord.Intents.all())


messages = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
keywords = ["random"]

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')

@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if message.content.startswith('random'):
         await message.channel.send(random.choice(messages))

how does this look so far

#

how do i get it to respond to the command prefix?

winged coral
#

You're using the commands.Bot extension so you don't need to manually parse and handle commands in the message event

#

The commands.command decorator handles that for you, and uses the prefix you pass the Bot constructor as the prefix for those commands

bright wedge
winged coral
#

The prefix can be anything you want

bright wedge
#

ofc

bright wedge
south coyote
#

random.randint(0, 9)

#
import discord
from discord.ext import commands
import random

bot = commands.Bot(command_prefix="", intents=discord.Intents.all())

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user}')

@bot.command()
async def random(ctx):
  await ctx.send(random.randint(1, 10))
#

that should work whenever anybody types random

#

right?

bright wedge
#

define the prefix

south coyote
#

i don't want a prefix

bright wedge
#

ok

south coyote
#

thanks though

bright wedge
#
@bot.event
async def on_message(message):
    if message.author == bot.user:
        return
    if message.content.startswith('random'):
         await message.channel.send(random.randint(1, 10))
#

this will work then

winged coral
#

^ You only want the prefix if you're using the commands extension

south coyote
#

what is the difference between bot.event and client.event

bright wedge
#

there is a difference between bot and client

south coyote
#

so its kinda pointless to use commands if you are not using a prefix then huh

bright wedge
#

if you dont wont commands

#

you can use client

south coyote
#

what if i want it to respond to this "please give me a random number"

#

if random is somewhere in the message then i want it to respond

#

how do i make it aware of the keyword somewhere within the message?

#

if message.contains?

#

take out the startswith?

#
if message.content('random'):
        await message.channel.send(random.randint(1, 10))
#

yeah?

#

no apparently that doesn't work

#

oh it's "includes"

#

hmmm not working either

faint mural
#

you can just use "something" in message.content:

light night
#
        await interaction.response.send_message(content="Oh no it was a fake", ephemeral=True)
        await asyncio.sleep(2)

        # message = await interaction.original_response()

        await interaction.edit_original_response(content="Prepare to get rickrolled...(it's a good song anyway)")
        await asyncio.sleep(2)

        await interaction.edit_original_response(content="https://i.imgur.com/NQinKJB.gif")

for me to even check if the orginal response is deleted I have to do this message check should I just fetch if it doesn't work then make I pass the arg into followup, I am not sure how to do this well lol
Having the user delete the response doesn't raise an error

south coyote
#

thanks lia

faint mural
light night
#

it doesn't, I can tell you that easily

faint mural
#

Is the message ephemeral?

light night
#

yes, when it's deleted it doesn't send me an errors, when deleted
This is because of the user btw

#

I am only using discord web, but I am logged into mobile but my phone is in sleep mode rn

slate swan
#

Can somebody make a script so when ever a person joins it dms them with a link

light night
#
pip show discord.py

Name: discord.py
Version: 2.1.0a4604+gcd04f6ca
Summary: A Python wrapper for the Discord API
Home-page: https://github.com/Rapptz/discord.py
Author: Rapptz
Author-email: 
License: MIT
faint mural
#

Hm I don't get an error either

light night
faint mural
#

Unsure what exactly you are trying to achieve

violet kraken
#

hey i'm trying to open a .json that is in a different directory, i don't know but i can't manage to make it work in the modal class, in the main class works fine how

light night
#

I want to pop it up, to rickroll them but if that's not good idea, feel free to say so

violet kraken
faint mural
#

Not in my interest to judge on that.
Did you try fetching the message before? (as you mentioned above?)

topaz helm
#

Do you have the kick/ban order to give me, please, but let it go smoothly???

lost yoke
#

Problem:
Import "colorama" could not be resolved from source

Imports:

from discord.ext import commands
import random
from discord import Permissions
from colorama import Fore, Style
import asyncio```

O que tem de errado?
#

whats wrong?

topaz helm
#

Do you have the kick/ban order to give me, please, but let it go smoothly???

#

Pls have?

austere vale
#

how can i check the type of exception that occurs? im trying to do:

except Exception:
      if Exception is errors.ExtensionAlreadyLoaded:
        pass
      else:
        print(f'Failed to load extension {extension}', file=sys.stderr)
        traceback.print_exc()
sick birch
austere vale
#

command error?

sick birch
austere vale
#

ohhh

#

thank you

#

did i type something wrong? it says it isnt defined

sick birch
austere vale
#

ohh ty

silent ridge
#

hey guys

#

anyone knows how to solve this?

hushed galleon
#

@silent ridge do you have a file named discord.py? or a discord folder?

#

apparently the .ext commands sub-package doesnt exist

silent ridge
hushed galleon
#

can you show the packages you have installed with pip list in the terminal?

south coyote
#

i just wanna take a second to thank all of you who take your time out of your day to help those of us in need

silent ridge
hushed galleon
#

discord and discord.py might be conflicting

silent ridge
#

okay let me uninstall discord

hushed galleon
#

id uninstall both of them and then pip install discord.py==1.7.3 to make sure d.py isnt broken

silent ridge
#

it did worked! I don't have the problem anymore

#

thanks, but now my code doesn't respond :/

#
import discord
import random
from discord.ext import commands


bot = commands.Bot(command_prefix='!')



@bot.command()
async def cr(ctx):
    embed = discord.Embed(title="CoolRate", description = f"You are {random.randrange(101)}% Cool", color = discord.Color.random())
    await ctx.send(embed = embed)




bot.run("TOKEN")```
#

I have this, and replaced for TOKEN I have inputted the token ofcourse