#discord-bots

1 messages ยท Page 393 of 1

teal delta
#

!tag

#

!on_message

slate swan
#

salut

sage crown
#

I think you're missing an async with

mint pecan
sage crown
odd folio
#

What is an instance variable?

mint pecan
sage crown
mint pecan
sage crown
#

Why bother? Just use a with

#

You have to remember to use a finally

mint pecan
sage crown
#

You can close it manually and still use the with

stark ingot
mint pecan
sage crown
mint pecan
woven plume
#

I'm being comissioned by someone to make a discord bot for them, but I have no frame of reference for how much to charge for. The bot is supposed to facilitate running a 'ranked match' in an external game (with things like character bans) and also taking the results of the match and using a ranking algorithm to rank the players.

queen wedge
#
@bot.tree.command(name="start_election", description="Start an election in a specific region.")
@app_commands.describe(region="1,2,3,4")
async def start_election(interaction: Interaction, region: int):
    region_map = {1: 'Aryavart', 2: 'Dravidian Rashtra', 3: 'Saurashtra', 4: 'Purvanchal'}
    
    if region not in region_map:
        await interaction.response.send_message(f"Invalid region: {region}. Please choose between 1, 2, 3, or 4.", ephemeral=True)
        return
    
    eci_role = discord.utils.get(interaction.user.roles, name="ECI")
    if not eci_role:
        await interaction.response.send_message("You do not have the required ECI role to start an election.", ephemeral=True)
        return   
    
    selected_region = region_map[region]
    candidates = await db.get_candidates_for_region(selected_region)
    
    if not candidates:
        await interaction.response.send_message(f"No candidates found for the {selected_region} region.", ephemeral=True)
        return

    options = [discord.SelectOption(label=candidate['candidate_name'], description=candidate['party_name'], value=candidate['party_name']) for candidate in candidates]
#
    class VotingDropdown(ui.Select):
        def __init__(self, candidates_options):
            super().__init__(placeholder="Choose your candidate", min_values=1, max_values=1, options=candidates_options)
        
        async def callback(self, interaction: Interaction):
            user_id = interaction.user.id
            party_name = self.values[0]
            username = interaction.user.name
            
            already_voted = await db.check_if_voted(user_id, region)
            if already_voted:
                await interaction.response.send_message("You have already voted!", ephemeral=True)
                return
            
            await db.add_vote(user_id, party_name, region)
            await interaction.response.send_message(f"You voted for {party_name}!", ephemeral=True)
            print(f"Vote added for {party_name} by {username} from {selected_region}")

    view = ui.View()
    view.add_item(VotingDropdown(options))
    
    await interaction.response.send_message(
        embed=Embed(
            title=f"Election Poll for {selected_region}",
            description="\n".join([f"{index + 1}. {candidate['candidate_name']} ({candidate['party_name']})" for index, candidate in enumerate(candidates)]),
            color=Color.green()
        ),
        view=view
    )
#

it says interaction failed if I restart the server

fast osprey
#

You should be making a View class, not a generic View object that you then staple items into. If you're using discord.py, look at the persistent.py example for options on how to get things to persist across restarts

fast osprey
#

There are examples in the example file I mentioned

wheat summit
#

Hello! I'm doing my first Discord bot with Python, but I saw a tutorial that said to go to the internal PC commands and run "pip install discord" but it doesn't work, any ways to fix this? And if it can't be fixed, what do I do to install that Discord thing?

elfin peak
#

how can I make a discord bot?

fast osprey
#

ยฟ

wheat summit
#

Why won't this work?

@bot.command()
    async def hello(ctx=None):
        await ctx.send("Hello there!")```
#

It says that "hello" isn't a command.

queen wedge
fast osprey
#

It's in the examples folder in the repo

wheat summit
stark ingot
stark ingot
wheat summit
#

Why does my bot keep saying that my command doesn't exist as an error?

fast osprey
#

Probably because you're not registering it properly

young dagger
wheat summit
#

Should the command be grey when I type it or?

fast osprey
#

Going to need to see the full code

wheat summit
#

Here it is. ```py
@bot.command()
async def sendembed(ctx:None):
embeded_msg = discord.Embed(title="Title of Embed", description="Description of embed", color= discord.Color.blue())
embeded_msg.set_thumbnail(url= ctx.author.avatar)
embeded_msg.add_field(name="Name of the author", value="Value of field", inline=False)
embeded_msg.set_image(url=ctx.guild.icon)
embeded_msg.set_footer(text="Footer Text", icon_url= ctx.author.avatar_url)

        await ctx.send(embed= embeded_msg)```
#

It says that the "sendembed" command doesn't exist.

fast osprey
#

"full" means "full"

#

as in all of it, not just this command

wheat summit
#

Alright.

fast osprey
#

(removing any tokens)

wheat summit
#
import discord
from discord.ext import commands

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

@bot.event
async def on_ready():

    print("Bot ready!")


    @bot.command()
    async def hello(ctx:None):
        await ctx.send(f"Hello there, {ctx.author.mention}.")

    @bot.command(aliases=["gm", "morning"])
    async def goodmorning(ctx):
        await ctx.send(f"Goodmorning, {ctx.author.mention}!")

        @bot.command()
        async def sendembed(ctx:None):
            embeded_msg = discord.Embed(title="Title of Embed", description="Description of embed", color= discord.Color.blue())
            embeded_msg.set_thumbnail(url= ctx.author.avatar)
            embeded_msg.add_field(name="Name of the author", value="Value of field", inline=False)
            embeded_msg.set_image(url=ctx.guild.icon)
            embeded_msg.set_footer(text="Footer Text", icon_url= ctx.author.avatar_url)

            await ctx.send(embed= embeded_msg)

with open("token.txt") as file:
    token = file.read()

bot.run(token)``` Here.
#

(Currently following a tutorial which doesn't get these types of errors).

fast osprey
#

You should not nest commands inside of each other, or inside of an event

#

these should all be indented to the top level

wheat summit
#

Alright!

mint pecan
sage crown
open cobalt
#

hey guys, I have a problem, so I fire a HTTP request to get the members of a guild, but instead receiving only my name, why?

timber dragon
#

Members intent.

teal delta
#

Use dotenv

wheat summit
teal delta
#

It secures secret keys

#

Make a new file called .env

wheat summit
#

Alright, thanks!

open cobalt
mint pecan
timber dragon
#

Yes you do

timber dragon
#

Oh wait http request

#

fetching a guild doesn't return its members

stark ingot
fast osprey
#

Environment variables drakeNo
Typed modern config formats like toml or yaml drakeYea

mint pecan
#

is making a shutdown command good?

timber dragon
timber dragon
south yacht
#

Hello I need help, when I try run setup command on bot it sends smth weird

stark ingot
#

what is a "setup command"

south yacht
stark ingot
#

Did you install this off of github or something? It is probably a bad idea to run files that you dont know what is in them or what they do that you find on the internet
Do you even have python installed?

wheat summit
#
GUILD_ID= discord.Object(1149794271935873126)

@bot.tree.command(name="hello", description= "Says hello back to the user that used the command.", guild= GUILD_ID)
async def sayHello(interaction: discord.Interaction):
                  await interaction.response.send_message(f"{interaction.user.mention} Hello there!")```
#

Why won't this work?

#

It says this: "builtin_function_or_method" object is not subscriptbale.

wheat summit
#

But the try: command was wrong, now it says "Synced 0 commands".

fast osprey
#

You should have a traceback

#

If you don't know what line that error happened on, youre shooting in the dark

wheat summit
fast osprey
#

The library gives it to you by default

#

Something in your code is eating it

wheat summit
#

Here if the full code:

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!",intents=discord.Intents.all())
@bot.command()
async def sendembed(ctx:None):
            embeded_msg = discord.Embed(title="Title of Embed", description="Description of embed", color= discord.Color.blue())
            embeded_msg.set_thumbnail(url= ctx.author.avatar)
            embeded_msg.add_field(name="Name of the author", value="Value of field", inline=False)
            embeded_msg.set_image(url=ctx.guild.icon)
            embeded_msg.set_footer(text="Footer Text", icon_url= ctx.author.avatar)

            await ctx.send(embed= embeded_msg)

@bot.command(aliases=["gm", "morning"])
async def goodmorning(ctx):
        await ctx.send(f"Goodmorning, {ctx.author.mention}!")

@bot.command()
async def hello(ctx:None):
        await ctx.send(f"Hello there, {ctx.author.mention}.")


GUILD_ID= discord.Object(1149794271935873126)

@bot.tree.command(name="hello", description= "Says hello back to the user that used the command.", guild= GUILD_ID)
async def sayHello(interaction: discord.Interaction):
                  await interaction.response.send_message(f"{interaction.user.mention} Hello there!")

@bot.event
async def on_message(message):

    if message.content == "You are rude":
        await message.delete()
        await message.channel.send("Please be kind to others.")

@bot.event
async def on_ready():

    print("Bot ready!")

    try:
           synced_commands= await bot.tree.sync()
           print(f"Synced {len(synced_commands)} commands")
    except Exception as e:
           print('An Error while syncing applications commands has occured:', {e})


with open("token.txt") as file:
    token = file.read()

bot.run(token)```
fast osprey
#

You're not going to have a good time implementing something this advanced not knowing what a library is

#

This is like walking into a brain surgery class and asking what a scalpel is

wheat summit
#

Soo, what is a library?

fast osprey
#

You have a try and except in your code. Do you know what these do or why you put them there?

wheat summit
wheat summit
wheat summit
fast osprey
#

That is not what try and except do, generally

wheat summit
fast osprey
#

Why is it in your code if you don't know what they do what

wheat summit
#

I'm trying to do my first slash command, but it won't sync into my guild.

fast osprey
#

This tutorial is teaching you bad practices and not even explaining why they're doing it lol

fast osprey
#

Wherever you're getting it from is talking out of their ass, because what they're doing is actively making your code less usable

teal delta
fast osprey
#

You should first understand what it does. You should never add/remove/change code just because someone tells you to, that's lesson 0

teal delta
fast osprey
#

Spoon feeding is really bad, especially when they spoon feed you shit code they don't even explain

wheat summit
fast osprey
teal delta
#

Put that in a command

fast osprey
wheat summit
wheat summit
teal delta
wheat summit
#

Alright!

fast osprey
#

json is a data exchange format. It Works โ„ข๏ธ but it's unnecessarily verbose and limited for configuration imo

teal delta
teal delta
fast osprey
fast osprey
wheat summit
teal delta
#

Or creating

fast osprey
#

configuration as in...things that configure how your application works

wheat summit
#

It says that I can only use await with the async function.

teal delta
wheat summit
#

Nvm.

teal delta
wheat summit
wheat summit
teal delta
wheat summit
#

Alright!

#

Nope didn't sync it.

teal delta
#

For me when I add app commands it doesn't pop up yet

#

But restarting Discord should work

wheat summit
#

Alright.

#

Still nothing.

teal delta
#

No errors in the console right?

wheat summit
#

Don't think so.

#

Nope.

teal delta
#

Show the code

wheat summit
#
import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="!",intents=discord.Intents.all())
@bot.command()
async def sendembed(ctx:None):
            embeded_msg = discord.Embed(title="Title of Embed", description="Description of embed", color= discord.Color.blue())
            embeded_msg.set_thumbnail(url= ctx.author.avatar)
            embeded_msg.add_field(name="Name of the author", value="Value of field", inline=False)
            embeded_msg.set_image(url=ctx.guild.icon)
            embeded_msg.set_footer(text="Footer Text", icon_url= ctx.author.avatar)

            await ctx.send(embed= embeded_msg)

@bot.command(aliases=["gm", "morning"])
async def goodmorning(ctx):
        await ctx.send(f"Goodmorning, {ctx.author.mention}!")

@bot.command()
async def hello(ctx:None):
        await ctx.send(f"Hello there, {ctx.author.mention}.")


GUILD_ID= discord.Object(1149794271935873126)

@bot.tree.command(name="hello", description= "Says hello back to the user that used the command.", guild= GUILD_ID)
async def sayHello(interaction: discord.Interaction):
                  await interaction.response.send_message(f"{interaction.user.mention} Hello there!")
                  await bot.tree.sync(GUILD_ID)

                  
@bot.event
async def on_message(message):

    if message.content == "You are rude":
        await message.delete()
        await message.channel.send("Please be kind to others.")

@bot.event
async def on_ready():

    print("Bot ready!")


with open("token.txt") as file:
    token = file.read()

bot.run(token)```
teal delta
#

You synced inside the command

#

Do it in a separate command

wheat summit
#

Alright.

#

When I do that it says that I can only use it with the async function..

fast osprey
#

Do you know what syncing is, why you need to do it, and when you should do it?

wheat summit
fast osprey
#

That's not really accurate at all

wheat summit
fast osprey
#

Did the tutorial even try to explain?

wheat summit
fast osprey
#

This tutorial somehow manages to get worse and worse. You really should stop reading it

wheat summit
fast osprey
#

Slash commands (app commands) specifically are stored in a structure called the CommandTree. Calling sync() on that command tree is effectively telling discord about the commands that it's storing, because discord needs to know about them and their metadata

teal delta
#

Then restart Discord

fast osprey
#

This only pertains to app commands, hence why it's called on the CommandTree that stores them

teal delta
fast osprey
#

CommandTree is a class made by the library that tracks app commands

wheat summit
#

Why does interaction become grey when I type it... It shouldn't..

stark ingot
wheat summit
#

What is the "def" function?

fast osprey
#

Some of these questions you're asking are very, very base level python. And if you try to learn them in the context of an advanced framework like a discord bot, you are going to get very very confused

#

as these libraries presuppose you have these fundamental skills and will not talk you through them

wheat summit
#

I can't do anything at this point... I don't want to continue using platforms like BotGhost.

#

Can you please tell me just how to fix my problems? I really want to make my slash command work..

#

As you are basically telling me no way on how to learn how to use Python, as you said that every single tutorial that I'm watching are just bad, so how should I learn it then?

fast osprey
wheat summit
#

Alright, thanks.

stark ingot
#

Learning python and learning how to make a discord bot in python are separate. You should learn some python first.

fast osprey
#

These concepts build off of each other but will take time, there's not an easy path to just running before you know how to walk. This community exists to help with those stages of learning but you'll need to put the effort in to self-learn

wheat summit
#

But I learn better with examples or by videos.

#

Or just a page that has a true explanation and examples.

fast osprey
#

Examples there are plenty once you've read the underlying concepts.

Videos are an inherently wrong medium for conveying this information, and will range from bad to outright misleading. I strongly suggest you get comfortable with reading articles and then experimenting yourself in code

wheat summit
stark ingot
#

!res has a bunch of tutorials for learning python. It is not official but I started with "Automate the boring things"

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.

wheat summit
#

Alright, thanks!

#

How to make like the "wait" function?

fast osprey
#

You'll need to describe the behavior you're trying to accomplish

south yacht
#

Hello I need help, when I try run setup command on bot it sends smth weird

fast osprey
#

"setup command" is something that some random person wrote, and if you want to use it (you shouldn't), you should ask them

south yacht
#

Batch script what is that

fast osprey
#

Windows Batch File

#

This is a script you downloaded from somewhere that some rando wrote, you are running it and it is trying to do things to your computer that you don't understand. That should be alarming to you.

lilac sparrow
#

Hello does someone know how to handel with user-installable apps? bc i want to make that my Discord Bot Command register also in the normal dms of a user and not in the bot dms i can use my command everywhere besides in this so if someone know it would be helpfull

fast osprey
#

Which library are you using?

lilac sparrow
fast osprey
lilac sparrow
#

idk im a starter i just watch a youtube video

#

and try something out what kinda worked

fast osprey
#

yeah youtube videos will lie through their teeth at you

#

and give you things that are horrible practice or just not work

#

Anyways, at some point you will have picked a discord library to work with, and the answer to your question may vary based on that

south yacht
fast osprey
#

You are trying to run some bot that a specific person built. You should contact them. Your question is with what they made, not with python.

Though I would not trust this at all given what I'm seeing, and you would do really well to be more skeptical about things you get from online

teal delta
#

I agree, sounds like a Trojan worm ransomware to me

mint pecan
#

im getting discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook when using interaction.followup.send

mint pecan
merry cliff
#

oh ok

#

followup is used when the intertaction has already been respionded to

#

so if you are sending just a message, either do interaction.response.send_message("my message") or await interaction.response.defer(thinking=True) first

merry cliff
#

the defer is used when your program will take longer than ~!3 seconds to give an output

merry cliff
#

havent used it ion a whjile tho'

timber dragon
#

thinking is always True for slash interactions

#

It's for components where it defaults to False, and you can actually set it

wheat summit
#

Is there a way to make like the options of the slash commands in the prefix command?

#

Like the option that you need to choose the members.

#

And how to make the bot always stay online even if I close Visual Studio?

slate swan
#

!intents

dense falcon
#

Is there any way I can reset the cooldown of a command without the reset being executed within that command?

fast osprey
mint pecan
#

How do i fix Unclosed connector error?

fast osprey
#

What's the full error and traceback?

mint pecan
#
2024-11-02 06:39:37 ERROR    asyncio Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000001585A847590>, 15332.187)]']
connector: <aiohttp.connector.TCPConnector object at 0x0000015859419F40>
fast osprey
#

Traceback?

mint pecan
fast osprey
#

Sounds like something to fix or you have no idea where this problem is

pale zenith
#

Maybe because it is <:name:id> not <:name:id:> unless you mistyped?

#

<python286529073445076992:>

#

no that would just break it. Maybe you have the wrong ID?

fast osprey
#

robux

real currency

okay skid

craggy anvil
#

nvm i fixed it somehow

stark ingot
#

Is it animated? I thing animated emojis need to be <a:name:id>

craggy anvil
#

nah it wasnt

stark ingot
craggy anvil
#

i never said it lol

fast osprey
#

They have a long history of skid currency exchange

craggy anvil
#

me?

fast osprey
#

Look up their message history

craggy anvil
#

nun exchanging i did in my past

fast osprey
#

And yet you deleted your message anyways Thonk

craggy anvil
#

what message did i delete?

#

these past 5

#

it's js bc there was no specific error with it i js changed name of emoji and it worked after it i dont see the problem in deleting those 5

fast osprey
#

When you have a long history of writing shit trying to get people to send you money, then you post code here with the word robux next to currency values, it doesn't take Sherlock Holmes to put two and two together

craggy anvil
#

and these 2 are totally different projects

#

you are not putting any shit together mate

#

blud aint sherlock holmes ๐Ÿ™

fast osprey
#

Really

craggy anvil
#

litteraly an automated middleman bot

#

where did i try to get people to send "ME" money there?

#

and what that has to do with robux now lol

fast osprey
#

Why don't you show the full code and describe what this is doing then if you've got nothing to hide?

craggy anvil
#

because i sold that src? why would i leak it here to prove you wrong?

#

you rlly think i've been doing one project since july

#

that's when i asked abt that

fast osprey
#

No I think you're a prolific skid

craggy anvil
#

think what you want ๐Ÿ™‚

fast osprey
#

Then show code

craggy anvil
#

i got no reason to care abt that ๐Ÿคฃ

craggy anvil
fast osprey
#

To prove you're not a skid

craggy anvil
#

i told you to keep thinking i am skid

#

i dont care xd

#

would u show your bands if i called you poor?

#

to prove that you're not pooron

#

didnt u have some roles in this server? looks like you got demoted

fast osprey
#

You show code with currency next to robux, you delete that code, you refuse to provide more code or context of why you're displaying currency next to robux. It's not a good look, and someone who wasn't breaking rules would have nothing to hide

craggy anvil
#

show that again please

pale zenith
#

You just deleted it lol

slate swan
#

gigabrain

#

Shows something
Deletes it
Gets pointed they've shown something
Asks to show and prove where they sent it

brainmon

craggy anvil
#

i didnt mention real currency in there

#

and the message that he sent id of was sent in july

#

so you are connecting those two projects?

#

gg big brains ๐Ÿ˜‚

craggy anvil
#

it got no thing to do with real currency

fast osprey
#

The connection is you skid together shit asking people to send money to your bot

#

LOL

#

"Nothing to do with real currency"

Posts code with "$24.99"

Immediately deleted

craggy anvil
fast osprey
#

You can't make this shit up

craggy anvil
#

it still doesn't have anything to do with the code u mentioned that i've asked about in july

fast osprey
#

You literally just posted code with currency prices and deleted it a second later

#

Why are you deflecting

craggy anvil
#

you are actually ed ๐Ÿคฃ

#

still got nothing to do with the code you mentioned before

fast osprey
#

You can try to gaslight me into thinking you didnt post skid code you immediately deleted, but you did. Hopefully there are logs

craggy anvil
#

how skid when made by me ๐Ÿคฃ

#

logs for what

#

blud thinks staff gonna look trough logs to prove him wrong xd

wispy falcon
#

why does my ping command not work

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

  @commands.Cog.listener()
   async def on_ready(self):
       print(f"{__name__} is online")

   @commands.command()
   async def ping(self, ctx):
       embed = discord.Embed(
           title = "Pong!",
           description = f"Latency in MS",
           color = discord.Color.light_gray()
       )
       embed.add_field(name="Bot Latency", value=f"{round(self.bot.latency * 1000)}ms")
       embed.set_footer(name=f"Requested by {ctx.author.name}", icon_url=ctx.author.avatar)
       await ctx.send(embed=embed)

async def setup(bot):
   await bot.add_cog(Test(bot))```

added this in the main file

```async def Load():
   print("Attempting to load cogs...")
   for filename in os.listdir("./cogs"):
       if filename.endswith(".py"):
           try:
               print(f"Loading {filename}...")
               await bot.load_extension(f"cogs.{filename[:-3]}")
               print(f"{filename} loaded successfully.")
           except Exception as e:
               print(f"Failed to load {filename}: {e}")


async def main():
   async with bot:
       await Load()  # Ensure cogs are loaded here
       await bot.start(TOKEN)  variable for security
   
asyncio.run(main())```
#

oops

craggy anvil
#

now imma continue doing my thing and u can continue wasting time aruging with yourself bc u got nothing else to do in your life ๐Ÿ™‚

wispy falcon
fast osprey
#

Are you sure that extension is loading?

stark ingot
wispy falcon
fast osprey
#

The code they posted and deleted then literally had "$24.99" on it

fast osprey
slate swan
#

probably doesn't load if that's your indentation

wispy falcon
#

and it prints loaded succesfully

wispy falcon
fast osprey
#

So you're getting the success print for that specific extension? Are other extensions loading commands properly?

fast osprey
#

Are you loading these commands into the same bot object you're running? Seeing the full main file minus token would be helpful

slate swan
#

how can i fix thhis

slate swan
#

fixed it

wispy falcon
fast osprey
#

Show your code now, you didnt have other commands before

slate swan
#

anyone able to join a vc and help me

#

post screenshots containing the errors, no point in joining a vc

finite salmon
#

Python is for macos/Unix, py is for windows

slate swan
finite salmon
#

There goes your bot token

slate swan
#

delete the screenshot and reset your token now

finite salmon
slate swan
#

you just need to install audioop-lts the same way you did for discord.py

finite salmon
#

Also you're using python 3.13, I doubt dpy supports 3.13 yet

slate swan
#

Python 3.13 doesn't have it in the stdlib anymore

#

And you shouldn't use 3.13 either way - downgrade to 3.12

finite salmon
#

Yeah

#

Use 3.12

slate swan
#

shall i move to 3.12?

finite salmon
#

Yes

slate swan
#

any of these

finite salmon
#

Download the 3.12 installer from python.org and don't forget to add python to path

finite salmon
#

Don't use the Microsoft version

slate swan
finite salmon
#

I can't help on vc

slate swan
#

download the installer and run it

finite salmon
#

Uninstall the Microsoft version before you install 3.12

slate swan
#

32 or 64?

#

depends your device, probably 64 if it's not old

#

shall i uninstall this too

#

yes

finite salmon
slate swan
finite salmon
#

Sorry for the ping

finite salmon
#

do py -m venv venv

#

In the terminal

#

And then a popup should come asking if you want to select that venv, click yes

slate swan
#

no popup

finite salmon
#

In vsc

slate swan
#

in vsc

finite salmon
#

Not in your cmd

slate swan
#

done

finite salmon
#

Yeah click yes

#

And kill the terminal and create a new one

#

And then pip install

slate swan
finite salmon
#

Vsc

slate swan
#

"terminal" in vsc = cmd

#

i forgot how to kill it not used vsc in ages

#

just exit ๐Ÿคท

finite salmon
#

Hover over the Python tab and a dustbin icon should popup

#

And with the PowerShell also

#

And press ctrl + `

slate swan
#

done

finite salmon
#

To open a new terminal

#

And pip install

open cobalt
#

hey guys, hope yall doing well. I receive several events from the discord websocket, how would you guys make the event listener with all the events?

slate swan
finite salmon
fast osprey
finite salmon
slate swan
finite salmon
#

Run your code

fast osprey
#

On windows you shouldn't be running raw pip commands

#

It's ambiguous which pip installation that uses

finite salmon
#

Doesn't matter once you activate a venv

slate swan
open cobalt
finite salmon
slate swan
#

alr cheers

finite salmon
#

๐Ÿ‘๐Ÿฟ

fast osprey
open cobalt
fast osprey
#

It's unclear what you're trying to do and why you can't use the things already given to you, is this more of an educational exercise?

#

you can look through library source but those are internals that aren't going to be documented as they're not intended for consumer use

open cobalt
#

ok, I will look through a library that wraps the discord api pretty well

fast osprey
#

The structure and types of events sent through the socket are also documented by discord itself for people writing this

fast osprey
finite salmon
#

Lmao yea

#

Once I started using venv I couldn't go back to using my global environment

slate swan
fast osprey
#

You need to indent your code

slate swan
fast osprey
#

Do you know what indenting is, and how it's important in python?

tardy lagoon
#

should I use app_commands.command or Bot.tree.command for making slash commands?

fast osprey
# slate swan not really

This is pretty fundamental like first week python stuff. You will struggle to learn those basics while also trying to do so in the context of an advanced subject like this

#

indenting (tabs and spaces at the beginning of a line) have a fundamental purpose in python to signify when code is "nested" inside of a statement above it.

def something():
abcdef()

is invalid, compared to

def something():
  abcdef()
fast osprey
fast osprey
#

Which part is confusing?

tardy lagoon
fast osprey
#

Yes, I was responding with that in mind

tardy lagoon
#

so what is context, and the command tree?

fast osprey
#
@app_commands.command()
async def cmd(...):
  ...

This just makes a command sitting there. Same as creating any variable like x = 5. This alone doesn't do anything

#

A command being in the CommandTree is what actually gets it sent to discord when you sync that command tree

tardy lagoon
fast osprey
#
@bot.tree.command()
async def cmd1(...):
  ...

@app_commands.command()
async def cmd2(...):
  ...
bot.tree.add_command(cmd2)

are equivalent

tardy lagoon
#

oh, ok, thanks

fast osprey
#

If you declare an app_command with method 2 inside of a Cog and then load that Cog into the bot, that will automatically register that command in the commandtree as well. This is the majority use-case for @app_commands.command but not necessarily the only one

tardy lagoon
fast osprey
#

Yes, loading the cog itself effectively does that for all app commands contained in the cog

wheat summit
wheat summit
slate swan
#

you ask if something is possible and get "no" as answer

#

can someone help me make an announcment command

stark ingot
# wheat summit What do you mean no?

Prefix commands cannot have options like slash commands because well... at that point just use slash commands
If you mean to create a prefix and slash command at the same time py-cord has ext.bridge not sure if other libs have something simialr

stark ingot
wheat summit
stark ingot
#

Slash commands are definitely better, so if you can make them work that is best.
Can you show a screenshot of what you mean with the "Circle" bot?

fast osprey
#

Diluting your code to give people 2 ways of doing the same thing (one of them worse), vs just setting the expectation that they do it the right way

wheat summit
stark ingot
#

Yeah, you can have arguments with prefix commands, you just cant have discord Options.
You just need to add arguments to the command definition for it to work with prefix commands

fast osprey
#

It's the same as adding arguments to any python function

#
def my_function(argument1: Type1, argument2: Type2, ...):
wheat summit
fast osprey
#

Typehint it how you want to, discord.Member is one such type. Although if your bot is going to be DM'ing people, you'll want to make sure you got their consent to ahead of time

wheat summit
slate swan
stark ingot
#

What do you have so far? You should just be able to take an argument in the command for the announcement content and send it to the channel with the embed

fast osprey
#

Consider publishing these to an announcement type channel. There's really no need to have a bot as an intermediary

stark ingot
#

I dont think the intent is to spread it to multiple servers. I think the intent is to have an embed. I may be wrong tho

fast osprey
#

Generally it's good to do this off of an existing message rather than an input to a command, that way you can review markdown and have much easier multiline input. Publishing is the first-class way to do this and doesn't need a bot running. You could implement this as a message context menu alternatively

slate swan
stark ingot
#

yeah, just make sure you set allowed_mentions properly

slate swan
stark ingot
#

have you looked at the examples of the library you are using?

fast osprey
#

Which part are you specifically having trouble with? Making a command, period? Making the command accept a message? Having that command send a message to a channel?

slate swan
#

im here gonna move the command to my cogs

fast osprey
#

@bot.tree.command(...) goes over a command function

slate swan
wanton current
#

yes

slate swan
#

Can someone help me with a script for announcements

fast osprey
#

That's...what we're doing?

slate swan
#

this is all i got

fast osprey
#

If you don't know how to make a function in python, you should learn that first

slate swan
fast osprey
#

What is a command folder?

tired pine
#

๐Ÿ’€

drifting arrow
#

I'm trying to make a "level" mechanic for my bot, just for the lulz really. and having difficulties with the math part. anybody got a recommended formula or can help me out with the math?

I want users to level up at a normal rate and not have huge gaps between levels

#

NGL this is such a weird thing to ask lol

obsidian pine
#

I've installed discordpy 1.7.3 but it wouldn't let me run my script showing this error

obsidian pine
golden portal
#

why

obsidian pine
slate swan
#

the API v8 also should've been removed based the timings discord gave, but it hasn't been removed yet

#

so any bots using 1.7.3 may die at any moment when discord decides to delete v8

timber dragon
#

Glad that aiohttp is helping with breaking 1.7

open cobalt
#

so guys, for understanding purpose. Was the discord py library always async or no, and if not, how could it handle such inputs outputs from various commands?

hasty pike
#

Whenever i take input from user and user added emoji to it then it shows :emoji:, how do i fix this?

open cobalt
# tired pine ```py async def ```

async def def(): โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ โ˜ ๏ธ

glad cradle
tropic jackal
#

some1 knows why I get these?

hasty pike
#

And you might want to ask this here

tropic jackal
hasty pike
young dagger
#

How can I detect mentions of channels from other guilds but not in direct message (DM) channels?

elif any(message.guild.get_channel(channel_id) is None for channel_id in message.raw_channel_mentions):

The code above is detecting DM channels as well.

tropic jackal
hasty pike
stark ingot
#

You will have to explain more what a normal rate is. This is something that I came up with quickly. F(x) is how much total XP is needed to reach a level X. G(x) is how much more XP is needed to get from the current level to the next level. Each level gets a little bit harder to get.

#

But if you want even less of a gap you might just want a linear line. Where ever 200 XP a user gets a new level

ancient schooner
#

Hi

fervent frigate
#

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

thorny valve
vapid parcel
#

Bro went to bed at 5am GoofySkull

spiral crypt
#

Can discord bots use custom emotes?

#

Like if I add some custom ones to a private server im in with the bot, and then have it use those emotes in another server its in?

mint pecan
#

what's the type annotation for multiple selections for app commands?

golden portal
#

Literal?

merry cliff
spiral crypt
merry cliff
spiral crypt
#

Im on my phone rn so cant test it out

merry cliff
#

apparently you can do that

spiral crypt
#

Will check out in the morning thankies

merry cliff
#

np

twilit thunder
#

Guys Where can i learn Python faster to code discord bots/tools?

obsidian pine
#

Command raised an exception: TypeError: argument of type 'Member' is not iterable


@client.command()
async def add(ctx, user: discord.Member):
    role = ctx.guild.get_role(1301284017789861950)
    if not role in ctx.author:
        return
    await ctx.channel.set_permissions(user, view_channel=True, send_messages=True)
    embed = discord.Embed(description=f"{user.mention} added to ticket {ctx.channel.mention}")
    await ctx.reply(embed=embed)

@add.error
async def add_error(ctx, error):
    if isinstance(error, commands.MemberNotFound):
        await ctx.send("Member not found, please ask him to join server")
    await ctx.send(error)
#

@merry cliff can you help?

fast osprey
#

You can't check if a role is "in" a member

merry cliff
#

try Member.roles instead

merry cliff
obsidian pine
merry cliff
#

perhaps raise an error / send a message to tell the person they don't have the right role or something similar

fast osprey
#

If this is meant to be a check, it should be implemented as one rather than checking it directly in the command body tbh

merry cliff
#

yup

fast osprey
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check) that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

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

Changed in version 1\.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingRole) or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage) instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure)...
timber dragon
#

Or use if not <Member>.get_role(ROLEID) if you really need it inside

#
  1. Why did you reply to an unrelated message from me?
  2. You're in the wrong server. That's Javascript, not Python.
  3. Selfbots are strictly against the Terms of Service. No one will help you with that.
  4. Refer to point 2 again.
fast osprey
timber dragon
#

Bro deleted all their messages

mint pecan
#

how can i modify my views so when it's timed out and when someone clicks on it, it sends a interaction message?

scarlet tiger
mint pecan
stark ingot
scarlet tiger
stark ingot
fast osprey
#

if you already have a timeout handler, there's no reason to leave the buttons enabled

#

worse user experience and you need hacky code to handle it

stark ingot
#

Depending on the situation it might be better user experience to have a response. You could include why it was closed for example (If it was not a timeout)

fast osprey
#

That could (and arguably should) be captured in the message content rather than visually communicating to them that you want them to interact with this element

fast osprey
#

You didn't call the super init when overriding it

#

999 times out of 1000 you want to do that first

remote hound
#

someone able to help me with a discord bot please message

fast osprey
#

Feel free to ask your question here and get better help with more eyes

dry kelp
#

is pylance being faulty?

hushed galleon
# dry kelp

indeed that class definition does not typehint any support for generics, so pyright is declaring it incorrect as per typing specs

lucid kite
#

<@&831776746206265384>

sick birch
#

Hello, I've deleted this message as we don't allow recruiting or paid work in this server

twilit thunder
#

Guys Where can i learn Python for discord bots/tool

scarlet tiger
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.

mint pecan
#

does commands.is_owner work for app commands?

stark ingot
#

It should, at least it does in Pycord.
Although if you want owner only commands it is best to register them to a guild you own and limit the visibility to yourself. That way users will not get confused why they can't use the command

fast osprey
#

IMO best to not even register this as an app command at all. The entire point of app commands is to be discoverable, which is the exact opposite of what you're trying to do. Unless you're making use of app command specific features like autocomplete, you really shouldn't publish this

stark ingot
#

What do you recommend then? A terminal command?

fast osprey
#

Text commands are the standard, but really any unpublished way to send signals to the process

dusk glade
#

!eval 2+2

unkempt canyonBOT
dusk glade
#

!eval "2+2"

unkempt canyonBOT
scarlet tiger
teal delta
#

!eval console.log("Hello World");

stark ingot
#

This is not #bot-commands by the way

stark ingot
#

I'm not sure what exactly they mean by that word. I see unpublished as anything not available to the public.

fast osprey
#

There isn't any "setup" to text commands though. You write the function and it's there

#

Sure you could jump through hoops to publish to a private guild but like why

stark ingot
#

Does discord.py use the same bot object for app and prefix commands? I just see very little reason to be promoting prefix commands at all.
At least for py-cord the hoop to publish a command to a guild is as simple as passing a guild_id to a kwarg

young dagger
#

Prefix-based commands don't count as activity for the active developer badge, that's BS

#

Call me old school I don't give a damn

#

So all I have to do is add a ping slash command and problem solved

stark ingot
#

It is because discord does not want bots using prefix commands anymore.

I have seen 1.5 valid reason to use prefix commands. Everything else I have seen can be done with app commands

young dagger
stark ingot
#

The problem is the active dev badge is somewhat meaningless. There are plenty of people who are not devs who have it too.

In the end discord makes the requirements and if they dont like prefix commands. they probably will not promote them in any way

smoky sinew
#

pycord ๐Ÿ’ฉ

south yacht
#

So I started my host and my dc bot and it doesnt show commmands, I restarted discord and etc. So I need to wait bcs It needs to configure?

turbid condor
turbid condor
south yacht
turbid condor
#

Well like it's in the code

#

Can you show the code for your main.py

stark ingot
fast osprey
#

The differences are pretty much all pedantic, and the functional ones aren't that impactful in the grand scheme of things

stark ingot
#

@wanton current care to explain?

alpine mist
#

Hi guys, do yall have any good vids or website that can teach me how to create a discord bot?

fast osprey
#

All of the popular libraries will have documentation, though this presupposes some base level of python experience. Videos are ass, don't rely on them at all

open cobalt
#

When I wanted to create a discord bot, First, I made a connection to the gateway in order to receive event updates and then http requests and so on. It gets really deep this kind of stuff, so glad we have discord.py and other wrappers

merry cliff
#

!res

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.

merry cliff
spiral crypt
#

Can discord bots check reactions from messages?

spiral crypt
stark ingot
#

Yes, message.reactions returns a list of discord.Reaction
And you can get the id with message.reference.message_id
You should probably read the docs ๐Ÿ™ƒ

thorny valve
#

in discord.py is it possible to have a alias for a slash command?

fast osprey
#

There's no first-class alias system provided by discord. I'd encourage you not to do this (just making multiple wrappers on the same logic), as this just makes the slash menu far more cluttered and less usable while also eating up the limited number of commands you have available. Because commands are searchable, there's really no need for this if they're intuitively named.

Commands are also permissioned individually, so this adds burden to server managers and margin for error

thorny valve
#

thank you!

#

it probally won't be worth the slight convenience of adding an alias

fast osprey
#

Ideally they add this as metadata on the command at some point in a way that doesn't clutter the UI

thorny valve
#

maybe as some kinda tree view

#

but that seems like it could be a nightmare for mobile

stark ingot
#

Looks like it does but the effectiveness of it will depend on how common the "alias" you are trying to use is in other commands descriptions. (And if you are trying to do the 1-2 character alias it might not work super great)

spiral crypt
#

Can bots run other bots' commands

dry kelp
drifting arrow
#

hhmm

#

Trying to make a discord bot that has a whole bunch of features people may or may not want in their discord bot.. But IDK what people want? ๐Ÿค” any ideas or suggestions?

drifting arrow
#

Interactions being /help (slash commands) and buttons etc.

spiral crypt
#

Ah rip

#

I was trying to setup an auto redraw thing for a lottery bot

drifting arrow
#

assuming you're remaining within TOS, there's no way for 1 bot to use another bots interactions. As far as I am concerned anyway

#

I'm sure someone smarter is going to come wooshing on any moment now, pushing their glasses back up towards their eyes as they say "Well uhhm actually."

spiral crypt
#

Idk if what im trying to do is within tos so x3

drifting arrow
spiral crypt
#

Basically someone wins a giveaway, they can accept or decline in dms, if they decline it automatically rerolls the winner

drifting arrow
#

Okay.. So why would you need a 2nd bot?

spiral crypt
#

The lottery bot isnt mine

drifting arrow
#

Then make a lottery bot

spiral crypt
#

I made a bot to watch for wins and log them

#

Idk how ๐Ÿ˜ญ, thats gonna take so much longer

#

Id have to start from scratch pretty much qww

drifting arrow
#

A lottery bot is literally takes a list of people. rolls a random number, celebrates

#

with some shit in between

spiral crypt
#

The time issue tho

turbid condor
#

well a simple lottery bot shouldn't be hard

drifting arrow
spiral crypt
#

Im not the best programmer so i might have to turn the bot off to fix stuff, and thatll fuck up the timing

drifting arrow
#

Give me a few hours I'll make a basic lottery bot. ;D

#

After my rhett and link episode tho. Not before or during. But after.

turbid condor
spiral crypt
#

Yeah thats getting a bit complicated for me

#

The closest thing i have is a json thats holding lottery wins

drifting arrow
#

!paste

spiral crypt
#

I only use json for storing dictionaries, idk how to do anything else

drifting arrow
#

still a WIP

turbid condor
drifting arrow
#

Made in like 15 minutes using duct tape, gorilla glue and a whole lot of caffeine

spiral crypt
#

Wtf is a cog ๐Ÿ˜ญ

turbid condor
drifting arrow
spiral crypt
#

Mine will probs add a new entry every like 2 days

#

So 175 entries a year

#

Itll be fineee

drifting arrow
#

At such a low volume, you could even use pen and paper technically lol. But in terms of efficiency, you got json files (or similar. doesnt necessary need to be json), then lightweight databases like sqlite. then your more heavier databases. I dare not list one in fear of being struck down from someone from #databases

#

They're ruthless

#

Listed in worst to best. not best to worst

spiral crypt
#

Im taking a database class, but theyre not teaching how to connect to it with languages

#

Theyre just teaching it using a dbms

drifting arrow
#

TBH most of what you're learning now will be transferrable to most languages. The same stuff

turbid condor
spiral crypt
#

Im learning java, im self taught in python for the most part

#

Yeah im pretty good at sql

turbid condor
spiral crypt
#

Just select * and youre good

drifting arrow
spiral crypt
#

Ik x3 im jokin

turbid condor
drifting arrow
#

I do things the absolute laziest way possible. But if you want to be efficient with your resources you really should only grab what you need.

spiral crypt
#

Ikik

drifting arrow
#

Which is partly why a json file is not ideal

spiral crypt
#

Literally i just use it to save a dictionary, and load it when the bot starts

#

Thats all its used for

drifting arrow
#

Is this lottery bot going to be used as part of your classwork?

spiral crypt
#

Naw this is for a guild from a game i play

drifting arrow
#

oh

spiral crypt
#

My class is java

#

My school is java oriented

turbid condor
#

then why not use java for the bot?

spiral crypt
#

Bc im better at python x3

turbid condor
#

I see

spiral crypt
#

And its more convenient

#

Dicts in java are dum maps

#

Theres easy string parsing in python

#

With the silly [::[:[:[:[:[:[:]]]:];];];]

turbid condor
#

well then u should have map for how to go about your bot in mind?

spiral crypt
drifting arrow
spiral crypt
#

Naw it works trust

#

I also dont like writing system.out.println every time i have to test something

turbid condor
#

XD

drifting arrow
#

oh sure

spiral crypt
#

Andddd not having to worry about data types is also nice

turbid condor
#

more like declaring em

#

since u do have to be careful with datatypes in python too

spiral crypt
#

Well in my case its setup pretty strictly so there isnt room for type errors

#

I dont have any user input stuff, anything going into the bot has a data type that i expect

drifting arrow
#

๐Ÿค” How should the lottery setup proccess go? Multiple commands? 1 big ass command? maybe a command and buttons? ๐Ÿค”

#

hhmm..

spiral crypt
#

Ngl id want it like the one thats already made is

#

It like opens a window or something with the info needed

drifting arrow
#

oh

spiral crypt
#

Time for lottery, name, description, and one more thing i forgor

#

Ignore my brainrot RosySleepy

#

Description can have images too

#

I think

turbid condor
#

Tbh u could find a bot on github

drifting arrow
#

Are you watching a minecraft live stream?

spiral crypt
#

Hypixel skyblock

drifting arrow
#

So you'd want the command/setup process to be easier to use on mobile than pc?

spiral crypt
#

On pc its like that too, im just on my phone rn so that's where i yoinked the screenshot from

#

It makes a little box

#

This bot i have to make as ease of use as possible as the people using the lottery bot dont rlly wanna do extra work

#

And since theyre used to the old bot, well yeah

drifting arrow
#

Aight

spiral crypt
#

Im going to have to change my logging conditions Waaaa

#

Oh wells

drifting arrow
#

Well. Then it's really simple.
you want a command like /lottery or some crap. idk you figure that part out.
The command creates that popup dialogue box (forgot the discord name for it, it has a name.)

Fill it out. Then the bot throws an embed into a channel. is like "HEYYYY guys! @ everyone. Checkout my snazzy giveaway!" and people press a button to enter. It logs it.

Then after X time it's like "Oh hey hey. Checkout the winners.. @ <people who won>" and then DMs them

#

simple really

spiral crypt
#

This is how they look

drifting arrow
#

Are they still using reacts?!

#

eeeww that's so <whenever buttons wasnt around>

spiral crypt
#

It uses a button

#

OKAY its 3:30am i need to sleep

#

I have class in 4 hours

#

Goodnight

obsidian pine
#

Sorry to ask but I'm new to this and just if i can play MP3 or any other audio format file in discord bot by connecting it to vc?

hasty pike
#

Yes that's possible

turbid condor
obsidian pine
turbid condor
#

Either they be audio video or others

#

By default most codecs come pre installed with os

obsidian pine
#

So do I need to pass any specific format?

#

And how do i connect it to bot?

turbid condor
#

Just use most commonly used audio format that is mp3

obsidian pine
turbid condor
obsidian pine
turbid condor
#

As for how to actually configure that you might want to look up yt

obsidian pine
#

Oh okay

#

So ffmpeg is what i need

turbid condor
#

As the voice part of discord is pretty much a mystery to me

turbid condor
teal delta
# obsidian pine Sorry to ask but I'm new to this and just if i can play MP3 or any other audio f...

The copyright law of the United States grants monopoly protection for "original works of authorship". With the stated purpose to promote art and culture, copyright law assigns a set of exclusive rights to authors: to make and sell copies of their works, to create derivative works, and to perform or display their works publicly. These exclusive r...

#

Good luck

fast osprey
#

Yeah in all my time doing this I can count on one hand the number of people with a legal and ethical use case for audio lol

turbid condor
#

๐Ÿ‘€

obsidian pine
#

Lol I'll be using it for my personal bot in personal server

fast osprey
#

Doesn't matter

#

The TOS don't make a distinction anywhere that says the word "personal"

obsidian pine
#

So what can they do

#

Terminate the bot

#
  • my audio file will be like soundboard recorded by me and my friends
#

They don't fall under any copyright

stark ingot
#

Yeah, you are fine. They assumed you were downloading off of YouTube

fast osprey
#

This sounds like a use case for the built in soundboard

open cobalt
#

Any of you know good hosting providers for dc bots or just using a raspberry pi?

fast osprey
#

!hosting

unkempt canyonBOT
#
Discord Bot Hosting

Using free hosting options like repl.it or Heroku for continuous 24/7 bot hosting is strongly discouraged.
Instead, opt for a virtual private server (VPS) or use your own spare hardware if you'd rather not pay for hosting.

See our Discord Bot Hosting Guide on our website that compares many hosting providers, both free and paid.

You may also use #965291480992321536 to discuss different discord bot hosting options.

dry kelp
#

Digital Ocean assures you 99.9% of uptime, only in cases as global disaster they drop

open cobalt
#

Indeed, very pricy. I researched and found netcup, sounds great and I think cheap pricing for the VPS

wary torrent
#

why discord profile images not loading iPhone , can anyone help??

slate swan
south yacht
#

So I have purchased A bot and the seller like isnt not responding to me and there is exe file where I can run the bot, and bot is online but its not showing commands, and on cmd its showing this eror:
[ERROR] Failed to load msgcmd cog. Error: Extension 'files.msgcmd' could not be loaded.

turbid condor
#

It only tells tells there's something wrong with a file files.msgcmd and nothing else

south yacht
open cobalt
#

this is a cog file

#

every cog has its structure

turbid condor
#

A file named msgcmd inside a folder called files

#

Tho there is nothing else here that tells what exactly is causing the issue

#

May be look for a log file inside your project directory

south yacht
turbid condor
#

Cuz we can't help without a traceback of the error

blissful crane
#

there really is no reason for someone to sell you the code, as an exe

#

unless you asked specifically for an exe, that's pretty weird

turbid condor
#

Well an exe could be dangerous so i wont trust using one unless it s from a trusted source

fast osprey
#

Somehow I get the feeling even if they got source, they wouldn't be combing through it before running it

ionic pilot
#

hey uhh how do these @ things work and how do i use them

fast osprey
#

They're called decorators, it's a built in python syntax

ionic pilot
#

how can i make one?

fast osprey
ionic pilot
#

ccccccoooool

#

but how do i define client?

timber dragon
#

It's usually whatever you called your Bot instance

skibidi = commands.Bot(...) # <-
# ^^^

@skibidi.event
...

@skibidi.command(...)
...


skibidi.run(...)
ionic pilot
#

how would i do it in an eval?

timber dragon
#

Consider installing jishaku

ionic pilot
#

crazy

timber dragon
#

Lol yeah

ionic pilot
#

so is it possible to define Bot in an eval?

timber dragon
#

Yeah

ionic pilot
#

without extensions ^^

timber dragon
#

You can do something like !jsk py _bot.user.name

#

Or !jsk py await _ctx.send("pog")

||even tho !jsk py "pog" works too||

ionic pilot
#

idk python that much, can you only do it with that library?

timber dragon
#

An eval command?

ionic pilot
#

yes

timber dragon
#

You can do it yourself but it'll probably be unsafe and be less functional

ionic pilot
#

thx bro

robust reef
#

hello

thorny valve
#

how do you add a cooldown to a slash command in a cog? (if it's different from setting it up outside a cog)

robust reef
timber dragon
#

That's for prefix commands

ionic pilot
#

do you guys know how i can add an auto-react with a bot on every message

timber dragon
#

We do

#

But do you really want that

#

Reactions are heavily ratelimited.. adding one to every message can potentially get your bot api banned, temporary

ionic pilot
#

really

timber dragon
#

Well getting banned is a little extreme

ionic pilot
#
async def on_message(message):
    if message.author.id == myid:
        message.add_reaction()

i want it to react me

timber dragon
timber dragon
ionic pilot
#

but idk where to put it so it works

#

idk how to

fast osprey
#

Do you know how make listeners generally?

fast osprey
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready)

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Example...
ionic pilot
#

idk where to place it

open cobalt
#

I think above the async def on_message(....)

ionic pilot
#

idk where to place that tho

fast osprey
#

In the file where your bot is declared, at any point after you declare it

open cobalt
#
# This example requires the 'message_content' intent.

import discord

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

client = discord.Client(intents=intents)

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

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

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run('your token here')
#

the decorater registers the on_message event, kinda like adds it to the bot I think and when an event is received through the gateway that equals that event name, the on_message will be executed

south yacht
#

[ERROR] Failed to load view cog. Error: Extension 'files.view' raised an error: TypeError: SlotView1.init() takes 1 positional argument but 2 were given

#

Anyone could help me what I should change there?

fast osprey
#

Code?

sturdy dragon
ionic pilot
#

idk where add

sturdy dragon
ionic pilot
sturdy dragon
ionic pilot
#

um idk

fast osprey
#

If you don't even know what file runs your bot, you're gonna have a bad time trying to modify that bot lol

#

Did you not make this code?

ionic pilot
#

yes

ionic pilot
fast osprey
#

You should ask them then

#

Or build your own so you understand how the architecture works

sturdy dragon
#

another easy way to tell, which module is grabbing your discord token lol

ionic pilot
#

they said its easy

sturdy dragon
#

its easy if you know whats going on

fast osprey
#

If you don't understand it because you didn't build it, you're effectively asking us to fix something someone else built when they could just do it themselves

sturdy dragon
#

whats the actual issue OLi

fast osprey
#

Somewhere in all of this code should be a line which creates a Bot or Client object

#

Your goal is to find that

sturdy dragon
#

your listener isnt functioning correctly?

ionic pilot
sturdy dragon
#

are you sure the bot has the right permissions

#

setup intents and permissions is important

ionic pilot
#

it can react

#

read messages content and messages and channels

sturdy dragon
#

so you want it to react to what, text messages based on content?

ionic pilot
#

kinda

#

but idk where to make the on_message

#

if it works

#

idk python

#

i want it to react me only

fast osprey
#

That's your first issue lol. Generally you're not going to get people here willing to do it for you for free

sturdy dragon
fast osprey
#

That's an example

sturdy dragon
#

or you can filter responses by user ID

fast osprey
#

If you don't know python, you're asking us to write the code for you

ionic pilot
ionic pilot
sturdy dragon
#

the most basic listener @commands.Cog.listener() async def on_message(self, message: discord.Message): if message.content.lower().strip() == "ping": await message.channel.send("pong")

ionic pilot
#

its imported in all of them

sturdy dragon
#

what imports are at the top of bot.py

ionic pilot
#

asyncio

#

inspect

#

logging

#

math

#

time

#

types

sturdy dragon
#

is there any listener to check message content

ionic pilot
#

datetime.datetime

sturdy dragon
#

I meant is it importing other modules from the same cog

ionic pilot
#

typing.TYPE_CHECKING, cast

#

aiohttp
discord
discord.gateway

ionic pilot
sturdy dragon
#

this is def the module where your bot object is created ๐Ÿ˜›

#

cant tell much else

ionic pilot
#

discord.ext.commands.bot.PrefixType

ionic pilot
#

formatted kwargs.join

fast osprey
#

Imports are a red herring here. You need to find where the bot/client object is instantiated

ionic pilot
#

hmmm

#

ok

delicate cape
#

Does anyone encounter the bug that ephemeral message is showed to all ppl in the channel ?

turbid condor
#

And it's the first time I heard of this

delicate cape
#

I got 2 reports for 2 days but noone take a screenshot. But today I got screenshot that all ppl in the channel saw the message. And message has ephemeral=True set.

delicate cape
#

Very wierd. The problem is that my messages contains passwords ;d

#

Idk how discord decide to not set the message to be ephemeral

slate swan
#

Until then, probably something in your code that's wrong

delicate cape
#

It can't be wrong in my code it's hardcoded ephemeral=True

slate swan
#

Or alternatively the library, but doubt

slate swan
turbid condor
#

Wait is the command you using a hybrid_command?

slate swan
#

Just know that only interactions can respond with ephemeral messages

delicate cape
slate swan
#

So yeah, if you have hybrid commands and use the prefix command, it will never be ephemeral

turbid condor
slate swan
#

Well, as expected, your code that's wrong

delicate cape
#

I can see in the message it says only i can see it

turbid condor
slate swan
#

Non interaction response messages cannot have the ephemeral flag

delicate cape
turbid condor
fast osprey
#

Common hybrid command L

delicate cape
turbid condor
delicate cape
turbid condor
delicate cape
#

slash command yes

turbid condor
#

That's why it's not ephemeral

delicate cape
#

so app command can't be ephemeral

turbid condor
#

It's a prefix command where the prefix is /pm

#

Check the diff in both commands usage in the screenshots u sent

#

On tells that which user has used the command the second one doesn't

fast osprey
#

These systems work completely differently. Setting your prefix to / just makes it more confusing that it already is

turbid condor
#

Back to the topic tho

#

@delicate cape the solution to this problem is making your hybrid command into a pure app command

slate swan
#

Or send in dm if it has been invoked via prefix command

turbid condor
delicate cape
#

aha

#

I have a question is it wrong to use it like this:

@commands.hybrid_group(name="pm")
async def parent_command(self, ctx: commands.Context) -> None:
    ...

@parent_command.command(description="Add/Update Upkeep date for House/Stronghold/Castle.")
@app_commands.describe(name="Name of the House/Stronghold/Castle")
@app_commands.autocomplete(name=get_passwords)
@app_commands.describe(upkeep="Type how much days left")
@app_commands.guild_only
async def upkeep(self, ctx: commands.Context, name: str, upkeep: int) -> None:
fast osprey
#

There's really no good reason to present them with a prefix option when you actively have a better option

delicate cape
#

@turbid condor thanks for the feedback I got it

ionic pilot
#

happiness is merely a social construct..

drifting arrow
#

Anybody able to help out with some quick maths? :D

self.user_stats[member_id]['xp'] >= (self.config['xp_required_to_level'] * (self.user_stats[member_id]['level'] ** 2))

The problem with this formula is it goes quite fast. :/

#

It's a simple chat-level system thing that some discordbots have lol

#

I wanted to recrate it myself but the maths is the hardest part

thorny valve
#

but now I don't know how to get it to stop throwing errors at me and give them to the user

drifting arrow
#

For example this:

    @app_commands.command(name="stats", description="Looks a user up")
    @ app_commands.checks.has_any_role(*roles)
    @guild_only()
    async def stats(self, interaction:Interaction, steam:str):
        await interaction.response.defer(ephemeral=self.config['ephemeral_response'])
        steam_profile = await self.functions.get_steam_profile(steam=steam)
        if not steam_profile:
            await interaction.followup.send("That profile is set to private. To pull data the profile has to be public.", ephemeral=self.config['ephemeral_response'])
            return
        steam = steam_profile['steamid']
        stats = await self.functions.pull_steam_data(steamid=steam)
        if not stats:
            await interaction.followup.send("No stats to be shown.")
            return
        
        steam_embed = await self.embed_factory.steam_embed(steam_profile=steam_profile)
        base_embed = await self.embed_factory.pvp_stats(stats)

        the_buttons = stats_buttons(stats=stats, config=self.config)
        await interaction.followup.send(embeds=[steam_embed,base_embed], view=the_buttons)

    @stats.error
    async def stats_error_handler(self, ctx, error):
        if isinstance(error, app_commands.MissingAnyRole):
            roles = []
            for role in self.config['allowed_roles']:
               guild = self.bot.guilds[0]
               the_role = guild.get_role(role)
               roles.append(the_role.mention)
            error = f"You do not have any of the required roles: {roles}"
            await ctx.response.send_message(error, ephemeral=True)
        else:
            await ctx.response.send_message(error, ephemeral=True)
#

I just check to ensure they have the required role and if they dont i yeet an error at the user

thorny valve
#

seems pretty simple thx

unique snow
#

Hi

drifting arrow
drifting arrow
open cobalt
#

hey guys, getting an error with this code: ```py
country_codes_embed = nextcord.Embed(title="Supported Country Codes", description="").from_dict(
country_codes)

#
 raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.description: This field is required
wanton current
#

why are you using from_dict?

open cobalt
#

it is a method that suggested me and it says this: Converts a :class:dict to a :class:Embed provided it is in the format that Discord expects it to be in.

wanton current
#

what is country_codes?

open cobalt
#

a dictionary with country codes

#

country_codes = {
"AD": "Andorra",
"AR": "Argentina",
"AU": "Australia",

#

...

wanton current
#

That's not how from_dict() and I don't know why you got suggested that