#discord-bots

1 messages · Page 218 of 1

wicked atlas
#

Are all your versions the same between your computer and the host?

scarlet aurora
#

yes discord.py==2.2.2

#

nothing else was changed

#
discord.ext.commands.errors.CommandNotFound: Command "help" is not found```
smoky sinew
#

what's your code though

scarlet aurora
#

for every command idk why

smoky sinew
#

is it possible that the code is different

scarlet aurora
#

what code do u want

#

@smoky sinew

smoky sinew
#

sure

scarlet aurora
#
import os
import discord
from discord.ext import commands

intents = discord.Intents.all()

class Bot(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix=">",
            intents=intents
        )

    async def setup_hook(self):
        for filename in os.listdir("./cogs"):
            if filename.endswith('.py'):
                await self.load_extension(f'cogs.{filename[:-3]}')
                print(f"Loaded {filename}")
            if filename.startswith("__"):
                pass
        await bot.tree.sync()
    
bot = Bot()

bot.remove_command('help')

@bot.event
async def on_ready():
    await bot.change_presence(activity = discord.Streaming(name = ">help", url = "https://www.twitch.tv/tmgwolv"))
    print("TMG - Bot is online")

bot.run("token")
#

requirements.txt discord.py==2.2.2 colorama==0.4.4 requests==2.25.1 pytz==2021.1 youtube_dl==2021.12.17 regex==2022.3.15 CurrencyConverter==0.16.13

smoky sinew
#

you're doing remove_command("help")?

scarlet aurora
#

yes so I can make my on >help command

smoky sinew
#

why are you using requests too

smoky sinew
#

do you know if it's being loaded on the host?

scarlet aurora
#

prolly not if it can't pick up any of the commands

#
class Utils(commands.Cog):

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

    @commands.command()
    async def help(self, ctx):
        embed = discord.Embed(
            colour=0x2F3136
        )
        embed.add_field(name="Main", value=">help (shows this command)\n>crypto\n>music help\n>changelog", inline=False)
        embed.add_field(name="Fun", value=">fun help\n>quote\n>cmds", inline=False)
        embed.add_field(name="Admin", value=">admin help\n>media help", inline=False)
        embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/949733110050857051/964831939989209138/tmgmidvitelogonowords.png")
        await ctx.send(embed=embed)

    @app_commands.command(name="help", description="Shows commands")
    async def s_help(self, interaction: discord.Interaction):
        embed = discord.Embed(
            colour=0x2F3136
        )
        embed.add_field(name="Main", value=">help (shows this command)\n>crypto\n>music help\n>changelog", inline=False)
        embed.add_field(name="Fun", value=">fun help\n>quote\n>cmds", inline=False)
        embed.add_field(name="Admin", value=">admin help\n>media help", inline=False)
        embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/949733110050857051/964831939989209138/tmgmidvitelogonowords.png")
        await interaction.response.send_message(embed=embed)
smoky sinew
#

you duplicate your code for each command?

#

what does the file structure look like on the host

scarlet aurora
#

what is there an easier way?

smoky sinew
scarlet aurora
#

how does one use hybrid commands?

scarlet aurora
#

same as how u have it on your pc

#

worked for my last version which was 1.7.3

#

now it's 2.2.2 it just doesn't wanna work

#

none of it works

slate swan
#

how do you get the slow mode data from voice channels?
AttributeError: 'VoiceChannel' object has no attribute 'slowmode_delay'

slate swan
#

!d discord.VoiceChannel.slowmode_delay exists 🤷‍♂️

unkempt canyonBOT
slate swan
#

f you know discord.py, kindly please help me with my issue: How do I force the user to chose from a list when providing input in discord.py?

slate swan
smoky sinew
slate swan
slate swan
smoky sinew
#

what thread

slate swan
#

@smoky sinew any reason why discord does this:
'Command' object has no attribute 'param'

    @commands.command(
        name = 'help',
        description = "Gets help information from lain.",
        usage = "yaml\nSyntax: ,help (command) <subcommand>\nExample: ,help settings ban",
        information = "None",
        param = "command",
        aliases = ["h"])```
shrewd fjord
#

There is no uses of param on the command deco

stone gate
#

how do i do optional variables like this?

smoky sinew
smoky sinew
#

you can't just make arguments up

slate swan
#

i know let me do something else then

stone gate
smoky sinew
#

no

#

produccion: str = None

stone gate
#

oh, i see

#

thanks

smoky sinew
#

produccion: typing.Optional[str] = None is technically correct though

dense jackal
#

when I send py -3 -m pip install -U easy-pil it keeps telling me

  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": <https://visualstudio.microsoft.com/visual-cpp-build-tools/>
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aiohttp
Failed to build aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects

sick birch
dense jackal
# sick birch You need microsoft visual C++ 14.0 or greater

did it and now I get this

error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe' failed with exit code 2
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aiohttp
Failed to build aiohttp
ERROR: Could not build wheels for aiohttp, which is required to install pyproject.toml-based projects

shrewd fjord
#

!d discord.Member.send

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

Sends a message to the destination with the content given.

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

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

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

its samew

#

same*

#

wdym?

shrewd fjord
#

if u r asking your embed is correct or not, yes its ok

copper gulch
#

is it legal to ask for help about youtubedl here?

#

or no

naive briar
#

!ytdl

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

!pynacl

glad cradle
#

!pypi pynacl

unkempt canyonBOT
#

Python binding to the Networking and Cryptography (NaCl) library

karmic nimbus
#

how do i find user without mentioning? similar to ?whois command on Dyno bot

maiden fable
#

use their ID?

karmic nimbus
maiden fable
#

Restart IDE
Make sure the correct Python version is selected

#

Python version

#

How many python versions do u have

#

Make sure u r installing and using the correct Python version

#

Then u r using the wrong Python version

slate swan
#

How can i get an user's status like dnd, online etc via the discord api

vocal snow
#

whats the issue?

vocal snow
#

a specific one or\

#

which IDE is this?

#

which python version is selected in bottom bar?

#

and what does py -V give you?

slate swan
vocal snow
#

and python -V?

vocal snow
#

!d discord.Client.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user "discord.Client.get_user") instead.

Changed in version 2.0: `user_id` parameter is now positional-only.
vocal snow
#

and then use user.activity/status

slate swan
vocal snow
#

make sure your presence intents are enabled

vocal snow
slate swan
#

Yeah, im using the raw api

vocal snow
#

then just check the api docs for the endpoint

#

well, switch the vsc interpreter to 3.11.2

#

or fix your pythonpath

#

bottom bar

#

click the version and it'll show a menu

#

well which one is 3.11

#

you can also manually enter the interpreter path

#

!dashmpip

unkempt canyonBOT
#
Install packages with `python -m pip`

When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.

Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.

Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.

vocal snow
#

you forgot to call .all()

young dagger
#

Is this correct?

@client.command(name = 'setup')
@commands.guild_only()
@commands.cooldown(1, 5.0, commands.BucketType.user)
async def setup(ctx, *, summoner_name: str=None):
    ... code here ...

@setup.error
async def setup_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send(str(error))```
young dagger
sick birch
#

Give it a try

raw dock
#

bot = commands.Bot(command_prefix='.',intents="default") not run why?

slate swan
raw dock
#

?

#

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='.',intents="default")

@bot.command()
async def testy(ctx):
await ctx.send('test1 :)')

bot.run
raw dock
#

intents = intents.discordIntents.default() (all)?

slate swan
#

?

#

default would be that you have set up in your bot

raw dock
#

sorry i m new on programing 3 years ago be good now is nev update etc

sick birch
slate swan
#

but you can as well use intents = discord.Intents.all()

raw dock
#

wery thx bro

#

hmm

#

@slate swan can you have traning bot discord

#

script*

slate swan
#

?

#

wym can I hava? and wym training?

raw dock
#

because I would like to learn because I wanted to have a moderation boda when it was good and now I have problems with intents

slate swan
#

import discord
import requests
from bs4 import BeautifulSoup

client = discord.Client()

@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
if message.content.startswith('!networth'):
username = message.content.split(' ')[1]
url = f'https://sky.shiiyu.moe/stats/{username}'

    try:
        response = requests.get(url)
        soup = BeautifulSoup(response.text, 'html.parser')

        networth = soup.find('div', {'data-text': 'NET WORTH'}).find('span').text
        await message.channel.send(f"{username}'s net worth is {networth}.")
    except:
        await message.channel.send(f"Unable to retrieve {username}'s net worth.")

client.run('token')

#

any chacnce anyone can tell me why this wont work

#

cause it should in theory

thin raft
#

"doesn't work"

#

what doesn't work

sick birch
#

Pardon?

vale wing
#

No way reaction permissions in discord bots

slate swan
#

help guys pls

slate swan
#

what do you mean

slate swan
#

could you help me ?

slate swan
#

@client.event

#

use @client.command

#

like this

#
@client.command()
async def doSomething(thing: str):
  await ctx.reply(embed = discord.Embed(title = thing))
#

Ill write it for you

slate swan
#
@client.command
async def ping(ctx):
  ping = round(client.latency @ 1000)
  embed = discord.Embed(title = "Client to Bot Ping", description = ping, color = int(colors[red]))
  await ctx.reply(embed = embed)
#

try this

#

huh

#

og

#

😹

#

oh

slate swan
#

oh and you need this

#
colors = {
  "default": 0,
  "teal": 0x1abc9c,
  "dark_teal": 0x11806a,
  "green": 0x2ecc71,
  "dark_green": 0x1f8b4c,
  "blue": 0x3498db,
  "dark_blue": 0x206694,
  "purple": 0x9b59b6,
  "dark_purple": 0x71368a,
  "magenta": 0xe91e63,
  "dark_magenta": 0xad1457,
  "gold": 0xf1c40f,
  "dark_gold": 0xc27c0e,
  "orange": 0xe67e22,
  "dark_orange": 0xa84300,
  "red": 0xe74c3c,
  "dark_red": 0x992d22,
  "lighter_grey": 0x95a5a6,
  "dark_grey": 0x607d8b,
  "light_grey": 0x979c9f,
  "darker_grey": 0x546e7a,
  "blurple": 0x7289da,
  "greyple": 0x99aab5
}
#

thats just a dictionary I made

#

it makes it easier

#

colors[(the color that you want)]

#

so, if you wanted red: colors["red"]

slate swan
#

lemme save this thanks

#

oh

#

I mean I was talking to @slate swan

#

but yeah you can use it to

slate swan
#

i just took the chance 😹

#

do you want me to teach you to use slash commands?

#

it works for me

#

whats the error

#

make sure you use the dictionary @slate swan

#
colors = {
  "default": 0,
  "teal": 0x1abc9c,
  "dark_teal": 0x11806a,
  "green": 0x2ecc71,
  "dark_green": 0x1f8b4c,
  "blue": 0x3498db,
  "dark_blue": 0x206694,
  "purple": 0x9b59b6,
  "dark_purple": 0x71368a,
  "magenta": 0xe91e63,
  "dark_magenta": 0xad1457,
  "gold": 0xf1c40f,
  "dark_gold": 0xc27c0e,
  "orange": 0xe67e22,
  "dark_orange": 0xa84300,
  "red": 0xe74c3c,
  "dark_red": 0x992d22,
  "lighter_grey": 0x95a5a6,
  "dark_grey": 0x607d8b,
  "light_grey": 0x979c9f,
  "darker_grey": 0x546e7a,
  "blurple": 0x7289da,
  "greyple": 0x99aab5
}
#

put it above the function

#

@slate swan it's not working

#

uhh

#

strange

slate swan
#

you are using @

#

instead of *, prob my bad

#

use the dictionary

#

above

slate swan
slate swan
#

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

#

use bot instead of client, imo its better

#

so its

@bot.command
async def ping(ctx):
  ping = round(client.latency * 1000)
  embed = discord.Embed(title = "Client to Bot Ping", description = ping, color = int(colors[red]))
  await ctx.reply(embed = embed)
#

paste this at before you pasted the function:

#
colors = {
  "default": 0,
  "teal": 0x1abc9c,
  "dark_teal": 0x11806a,
  "green": 0x2ecc71,
  "dark_green": 0x1f8b4c,
  "blue": 0x3498db,
  "dark_blue": 0x206694,
  "purple": 0x9b59b6,
  "dark_purple": 0x71368a,
  "magenta": 0xe91e63,
  "dark_magenta": 0xad1457,
  "gold": 0xf1c40f,
  "dark_gold": 0xc27c0e,
  "orange": 0xe67e22,
  "dark_orange": 0xa84300,
  "red": 0xe74c3c,
  "dark_red": 0x992d22,
  "lighter_grey": 0x95a5a6,
  "dark_grey": 0x607d8b,
  "light_grey": 0x979c9f,
  "darker_grey": 0x546e7a,
  "blurple": 0x7289da,
  "greyple": 0x99aab5
}
#

@slate swan hmm ?

#

bot = discord.Client()

#

@slate swan

#

and use @bot.command instead of @client.command

#

...

#

above the function

#

ohhhh

#

remove client = discord.Client

#

or it should be bot = discord,Bot

slate swan
#

hold up

slate swan
#

no

#

outside of the command, above it

patent wagon
#

hi. im making a bot that plays a game with you

#

it prints this first one

#

but it cant detect when lenCround becomes 1

#

how do i fix it

#

did i make a mistake in async code?

#

if someone know how do i make it work please ping

gusty flax
patent wagon
#

this

#

it never prints "1"

#

it cant detect when len(Cround) becomes 1

gusty flax
patent wagon
#

huh

#

... it does work

#

bruh this is wierd

#

i dont know why it wont detect Cround

#

i set it to global variable

#

for some reason it is not appending anything to Cround

smoky sinew
patent wagon
#

why does Cround variable remains empty after this function

smoky sinew
patent wagon
#

it should append one element into it

#

it completely fails to either append anyting to Cround it doesnt delete the element from pHand variable and it doesnt change the player

hasty bison
#

i use this to check channel but it doesnt work

fading marlin
smoky sinew
#

there's always a better choice than using globals

lone ivy
#

Are there any pros/cons to using one over (discord.py and nextcord)?

smoky sinew
#

it's personal preference really

#

you might find more help with discord.py unless you go to the nextcord server

#

but there are a lot of other libraries like pycord, disnake, hikari, etc

lone ivy
#

I appreciate the info 🙂 thank you

patent wagon
#

i defined it in the beginning and just used global everywhere

jade needle
#

const Discord = require('discord.js');
const client = new Discord.Client();

const weeklyRequirements = {
"[L3] Admiral": {"recruited": 4, "events": 4}, // ADMIRAL Member must have recruited at least 10 members and attended at least 5 events per week
"[L2] Vice Admiral": {"recruited": 20, "events": 10}, // Member must have recruited at least 20 members and attended at least 10 events per week
"[L1] Rear Admiral": {"recruited": 30, "events": 15} // Member must have recruited at least 30 members and attended at least 15 events per week
};

client.on('message', message => {
if (message.content === '!leaderboard') {
const members = message.guild.members.cache.sort((a, b) => a.displayName.localeCompare(b.displayName));

    const leaderboard = [];

    members.forEach(member => {
        const roles = member.roles.cache.map(role => role.name);

        if (roles.includes("[L3] Admiral") || roles.includes("[L2] Vice Admiral") || roles.includes("[L1] Rear Admiral")) {
            const roleRequirements = weeklyRequirements[roles.filter(role => Object.keys(weeklyRequirements).includes(role))[0]];
            
            const meetsRequirements = member.recruited_members >= roleRequirements.recruited && member.events_attended >= roleRequirements.events;
            
            leaderboard.push([member.displayName, meetsRequirements]);
        }
    });

    leaderboard.sort((a, b) => a[0].localeCompare(b[0]));

    let messageContent = '```LEADERBOARD:\n';
    leaderboard.forEach((entry, index) => {
        messageContent += `${index + 1}. ${entry[0]}: ${entry[1]}\n`;
    });
    messageContent += '```';
    message.channel.send(messageContent);
}

});

#

.

could someeone please help me on why that is not working?

smoky sinew
gaunt pagoda
#

Hey folks! I'm not sure if it's done before but I just made a discord bot using bing chat on top of @acheong08's EdgeGPT. Used bing chat because it's one of easiest ways to interact with GPT-4 imo together with active web browsing. The bot is able to handle /ask and /imagine commands. Happy to have your feedbacks or issues if you encounter with any
https://github.com/ediziks/BingGPT-Discord-Bot

GitHub

BingGPT Discord Bot using @acheong08's reverse engineered API of Microsoft's Bing Chat - GitHub - ediziks/BingGPT-Discord-Bot: BingGPT Discord Bot using @acheong08's revers...

jade needle
fading marlin
#

server, not channel

jade needle
#

Python?

fading marlin
#

yes

jade needle
#

And?

fading marlin
#

what you provided is js code

jade needle
#

Oh

#

Ok

smoky sinew
vital glacier
#

Any reason this all of a sudden broke?
I'm talking ab the

VoiceMaster Interface is constrainted to ...

#

It works properly in the value part of the fields, but not the description of the embed

slate swan
#
from discord.ext import commands

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

@client.event
async def on_ready():
    # print a message when the bot is ready
    print(f'{client.user.name} has connected to Discord!')

@client.event
async def on_guild_join(guild):
    # send a message to the default channel when the bot joins a server
    default_channel = guild.text_channels[0]
    await default_channel.send('Have a good day!')

# run the bot with your Discord bot token
client.run('YOUR_BOT_TOKEN')
#

can someone help me with this because it dose not work

smoky sinew
#

looks like your markdown is not being escaped

smoky sinew
vital glacier
#

uh sec

unkempt canyonBOT
#

@vital glacier Per Rule 6, your invite link has been removed. If you believe this was a mistake, please let staff know!

Our server rules can be found here: https://pythondiscord.com/pages/rules

vital glacier
#

oh shi right

#

!paste

smoky sinew
#

hmm

#

maybe it has something to do with the string being on a new line but that shouldn't affect it

vital glacier
#

thats what i thought

#

because the fields have it the same way

ionic garden
#
        msg = await i.response.send_message(embed=embed, view=view)
```why does this return none
shut surge
#

Hi, does anyone know about an issue with the ctx.voice_client.play command? It throws the error CommandInvokeError: Command raised an exception: ClientException: Not connected to voice even though the bot is actually in a voice channel. I have already tried reconnecting it, but it's not working.

smoky sinew
#

!d discord.Interaction.original_response

unkempt canyonBOT
#

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

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).

Repeated calls to this will return a cached value.
ionic garden
#

i want to reply w/ a msg that i ediit later down the line

smoky sinew
ionic garden
#

so i call i.og_response()?

smoky sinew
#

it's a coroutine it needs to be awaited

ionic garden
#

but i fricked around and found out

#

that is what you call apparently

dense jackal
smoky sinew
#

because you have two channel.send lines

dense jackal
#

How can I make both into one?

smoky sinew
#

by putting the file argument into the first one

dense jackal
#

Cause I have a file + text

#

await channel.send(f"Hello{member.mention}! Welcome To **{member.guild.name} For more informations, go to #rules**")(file=file) like that?

#

Looks like that’s not it @smoky sinew

smoky sinew
#

a function can have multiple arguments like this function(a, b, c)

dense jackal
#

Oh

smoky sinew
#

in your example you are calling the return value of channel.send which is a message

#

and you cannot call a message

dense jackal
#

Didnt know ty

dense jackal
#

Alright ty it worked

smoky sinew
#

!e ```py
class MyClass:
def call(self):
print("the class has been called")

def my_function():
print("the function has been called")

calling the class

my_class = MyClass()
my_class()

calling the function

my_function()

unkempt canyonBOT
#

@smoky sinew :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | the class has been called
002 | the function has been called
smoky sinew
#

@dense jackal

slate swan
#

Anyone know how to do the usage styling

#

I don’t remember how to do that

smoky sinew
#

ansi colors

#

check the pins

slate swan
#

Hm ok

dense jackal
slate swan
#

Ty

smoky sinew
#

!e ```py
class Message:
pass

message = Message()()

this is likely the error you were getting before
unkempt canyonBOT
#

@smoky sinew :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 4, in <module>
003 |     message = Message()()
004 |               ^^^^^^^^^^^
005 | TypeError: 'Message' object is not callable
dense jackal
#

@smoky sinew my welcome message stopped sending but no error codes appear

smoky sinew
#

what is your code

dense jackal
#

@smoky sinew

smoky sinew
#

your file path is the image bytes? pithink

dense jackal
#

It was working earlier, I didnt even touch a thing idk why its acting weird now

dense jackal
#

Nvm figured out the problem @smoky sinew , sucrose cant see that channel idk why

#

Bot cant see any channels anymore

smoky sinew
#

sucrose?

dense jackal
vital glacier
#
        if command.extras:
            perms=command.extras.get('perms')
            if "_" in perms:
                perms=perms.replace("_", " ")
            if commands.parameters:
                e.add_field(name='Parameters', value=', '.join(command.params), inline=True)
            e.add_field(name="Permissions", value=perms, inline=True)
#This works properly, its the bottom part thats broken
        else:
            if command.parameters:
                e.add_field(name='Parameters', value=', '.join(command.params), inline=True)
            e.add_field(name='Permissions', value='Send Messages', inline=True)

Error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/help.py", line 982, in command_callback
    return await self.send_command_help(cmd)
  File "/home/void/cogs/Information.py", line 121, in send_command_help
    if command.parameters:
AttributeError: 'Command' object has no attribute 'parameters'

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jishaku/features/invocation.py", line 168, in jsk_debug
    await alt_ctx.command.invoke(alt_ctx)
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'parameters'
#

Anyone got an idea on why it's doing this? Even tho it has parameters.

naive briar
#

There's no parameters property

vital glacier
#

How do you mean?

#

You know that parameters are like user: discord.Member, reason='none'

#

Right?

smoky sinew
vital glacier
#

How do you mean

smoky sinew
#

there is no such thing as Command.params

naive briar
#

!d discord.ext.commands.Command.clean_params

unkempt canyonBOT
#

property clean_params```
Dict[[`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.11)"), [`Parameter`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Parameter "discord.ext.commands.Parameter")]: Retrieves the parameter dictionary without the context or self parameters.

Useful for inspecting signature.
vital glacier
#

so i gotta do clean params then?

unkempt canyonBOT
#

discord/ext/commands/core.py line 117

def get_signature_parameters(```
naive briar
vital glacier
#

wait sec

#

i think i mightve fixed it

naive briar
#

And those are called arguments

vital glacier
#

i prob mistyped it LOL

smoky sinew
vital glacier
#

Well, explain to me how it works if i add the extras to my command

#

with commands.parameters

smoky sinew
#

what is commands.parameters

#

where did you find that

vital glacier
#

idk where i found that, ive had it for so long in my code LOL

#

Like genuinely months up to a year most def

vital glacier
#

and that works as it should, its the part where if I don't have the extras in my command code, it doesnt work

smoky sinew
#

!d discord.ext.commands.Command.extras

unkempt canyonBOT
smoky sinew
#

it's just a dictionary, nothing beyond that

vital glacier
#

ok so, this is what i have for my kick cmd right

#
    @commands.command(
        name='kick',
        usage=
        'Syntax: (user) <reason>\n'
        'Example: void#0480 calm down',
        aliases=['boot'],
        extras={'perms': 'Kick Members'})
    @commands.has_permissions(kick_members=True)
    async def kick(self, ctx, user: discord.Member, *, reason: str = 'No reason provided'):
#

but if i dont have the 'extras' part in there, it should put Permissions: Send Messages

#

which it doesn't

vital glacier
#

which works as it should

naive briar
#

What

vital glacier
#

!d discord.ext.commands.Command.brief

unkempt canyonBOT
vital glacier
#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
smoky sinew
#

huh

vital glacier
smoky sinew
#

yeah

vital glacier
#

that's what i mean

#

for some reason commands.parameters does work, but it doesnt want to work if there is no command.extra

#

cus then it says it doesnt have params to the command, which it does tho

naive briar
#

Do you know the difference between app_commands.Command and ext.commands.Command

vital glacier
#

i dont use app commands

naive briar
#

And what are you even trying to do

#

!d discord.app_commands.Command.parameters

vital glacier
unkempt canyonBOT
naive briar
#

The parameters only exists for app_commands.Command

#

Where did you get the information that the parameters property exists for ext.commands.Command

vital glacier
#

I tried it one time and it works like i wanted, so i always used it

#

Since it gives me what i need

dense jackal
#

if member.content == "!test": await channel.send(f"Hello{member.mention}! Welcome To **{member.guild.name} For more informations, go to #rules**", file=file) else: return

It doesn't send my message idk why

#

When I do channel.content it still doesn’t work

smoky sinew
#

member.content?

#

what content can a member have

vital glacier
dense jackal
smoky sinew
dense jackal
#

Then how am I supposed to do my test command

smoky sinew
#

by using the commands extension

dense jackal
#

Its ctx right?

dense jackal
#

Never heard of that

smoky sinew
#

i thought i saw you use it in your modmail bot

#
@bot.command()
async def test(ctx: commands.Context) -> None:
    await ctx.send("hi")
dense jackal
smoky sinew
#

yes

dense jackal
#

Then how

smoky sinew
#

that's because you are in a different scope

dense jackal
#

Yes ik

smoky sinew
dense jackal
#

I dont get it

smoky sinew
#

!scope

unkempt canyonBOT
#
Scoping rules

A scope defines the visibility of a name within a block, where a block is a piece of python code executed as a unit. For simplicity, this would be a module, a function body, and a class definition. A name refers to text bound to an object.

For more information about names, see /tag names

A module is the source code file itself, and encompasses all blocks defined within it. Therefore if a variable is defined at the module level (top-level code block), it is a global variable and can be accessed anywhere in the module as long as the block in which it's referenced is executed after it was defined.

Alternatively if a variable is defined within a function block for example, it is a local variable. It is not accessible at the module level, as that would be outside its scope. This is the purpose of the return statement, as it hands an object back to the scope of its caller. Conversely if a function was defined inside the previously mentioned block, it would have access to that variable, because it is within the first function's scope.

>>> def outer():
...     foo = 'bar'     # local variable to outer
...     def inner():
...         print(foo)  # has access to foo from scope of outer
...     return inner    # brings inner to scope of caller
...
>>> inner = outer()  # get inner function
>>> inner()  # prints variable foo without issue
bar

Official Documentation
1. Program structure, name binding and resolution
2. global statement
3. nonlocal statement

dense jackal
#

Im a little bit lost @smoky sinew

#

Does that mean I have to give access from my member to my ctx block outside of blocks?

smoky sinew
#

no just put the welcome message outside the function where you defined it

dense jackal
#

The await channel.send (f"hello… line?

smoky sinew
#

i don't know what your welcome message is since you said you can't use it

dense jackal
meager chasm
slate swan
#
async def vanitysnipe(ctx, code):
    while True:
        response = requests.get(f"https://discord.com/api/v9/invites/%7Bcode%7D%22)
        if response.status_code == 404:
            await ctx.guild.edit(vanity_code=code)
            await ctx.send(f"Vanity invite '{code}' has been set!")
            break
        else:
            await asyncio.sleep(10)``` would this be able to work?
#

(basically checks for the availability of a certain vanity every 10 seconds & if its available then change it to this vanity name

glad cradle
#

requests.get is a blocking function you shouldn't use it

#

and you should use a @tasks.loop instead of a command if you need to periodically check it

slate swan
#

ok wait

slate swan
forest hatch
glad cradle
slate swan
#

i forgot

glad cradle
#

and in a tasks.loop you don't have a ctx object

#

tasks.loop let you be able to run a task in background periodically

slate swan
#

ok i replaced ut with the bot object

#

@tasks.loop(minutes=1)
async def vanity_snipe():
code = "fbi"
async with aiohttp.ClientSession() as session:
async with session.get("https://discord.com/api/v9/invites/<code>") as response:
if response.status == 404:
guild = discord.utils.get(bot.guilds, id=<guild_id>)
await guild.edit(vanity_code=code)
channel = bot.get_channel(<channel_id>)
await channel.send(f"Vanity invite '{code}' has been set!")
vanity_snipe.stop()

#

hey guys i am getting a issue in tht my bot is not responnding to the hi message need help

slate swan
#

In versions prior to 1.7.0, there was a known bug that could cause voice connections to become stuck when disconnecting from a voice channel

#

Yo @forest hatch try to add more debugging code to find out whats wrong

#

@client.command()
async def leave(ctx):
if ctx.voice_client is None:
await ctx.send("I'm not in a voice channel.")
return
elif ctx.author.voice is None:
await ctx.send("You are not in a voice channel.")
return
elif ctx.voice_client.channel.guild != ctx.author.voice.channel.guild:
await ctx.send("I'm not in a voice channel in this server.")
return
else:
print(f"Leaving {ctx.voice_client.channel.name}")
await ctx.voice_client.disconnect()
await ctx.send("Left the voice channel.")

#

@slate swancan i get help??

#

send your script

glad cradle
slate swan
#

am i supposed to send my token as well??

slate swan
slate swan
#

import discord
from discord.ext import commands

client = commands.Bot('commands_prefi = '!')

@client.event
async def on_ready():
print ("The bot is ready for use!")
print ("---------------------------")

@client.command()
async def hello (ctx):
await ctx.send ("welcome..... chl ja bhai")

client.run ("")

#

.

slate swan
#

message content intent

slate swan
#

do this

#

import discord

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

slate swan
forest hatch
slate swan
slate swan
forest hatch
slate swan
#

oh ya i remeber

#

Scroll down to the “Privileged Gateway Intents” section and enable the ones you want.

#

this page

slate swan
#

dont k me

#

sry

#

sorry

#

did it work

#

am checking

#

how to take ss on pc lol??

thin raft
#

windows + shift + s

#

supposing ur in windows

slate swan
#

oki

slate swan
thin raft
#

!code

unkempt canyonBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

slate swan
#

.

thin raft
#

!traceback

unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

bruh

slate swan
#

sry for pings

slate swan
#

“prefi”

thin raft
#

im just confused

#

why do you have client and bot?

slate swan
#

oh

slate swan
thin raft
#

discord.Bot is not a thing

slate swan
#

bruh

thin raft
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.

Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client"), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree "discord.app_commands.CommandTree") and is automatically set upon instantiating the class.

async with x Asynchronously initialises the bot and automatically cleans up.

New in version 2.0.
slate swan
#

unto bot

thin raft
#

Do you know python?

slate swan
#

but on utube tut showed it

thin raft
slate swan
#

of*

thin raft
slate swan
slate swan
#

i know other coding lang like c#

thin raft
#

you can't jump without knowing how to stand up

slate swan
slate swan
#

pls

thin raft
#

the issue is

#

I will tell you what bot is, then you will ask me smt about bot, then something about bot about bot

slate swan
#

.

#

bruh

thin raft
#

have you checked the official docs?

slate swan
#

please

slate swan
#

tell

thin raft
#

check this

slate swan
#

i actually want to learn

thin raft
slate swan
#

lol

slate swan
naive briar
#

🥄

slate swan
#

oh

#

thanks for help sir

slate swan
thin raft
#

Learn python first then

slate swan
#

did u actually learn from here

slate swan
thin raft
#

I learnt python before discorspy

#

Not apparently man

slate swan
thin raft
#

And btw you leaked your token

slate swan
#

oh lol

#

but i dont think some gonna type so much

#

someone*

blissful badge
#

Does anyone have any good python sticky bot code examples by any chance?

#

Or maybe can point me in the right direction as to where to get started with that kind of functionality

slate swan
#

bruh wdympithink

blissful badge
#

The functionality to sticky a message in a chat and keep it at the bottom

slate swan
#

dont send links they are complicated

#

@thin raftping this guy he is smart

blissful badge
#

@thin raft will take any pointers!

thin raft
#

?

blissful badge
#

You familiar at all with python code that enables your bot to pin a message at the bottom of chat and keep it pinned?

thin raft
#

I won't spoon feed code

slate swan
#

broo guess it wrked

blissful badge
#

Of course not, was seeing if you knew of any resources

slate swan
#

hee will spoon feed code

blissful badge
#

But if you are just gunna assume im looking for you to spoon feed me code then I will just look for help elsewhere, sorry for tagging you.

thin raft
#

Nah dw

#

Try to do it urself

thin raft
#

And tell what's wrong with the code

naive briar
slate swan
naive briar
#

That bot sure is trustworthy

slate swan
#

hey u ignoring me

#

bruh

blissful badge
#

For context I have found some and have been working with it, but struggling with figuring out how to keep it at the bottom.

I've got

@bot.command(sticky)
async def pin_message(ctx):
  await ctx.message.pin()

@tasks.loop(seconds=1)
async def pin_message():
    message = ('message id ')
    await message.pin(message id)

but I am getting a bit confused on the args. Will, with this format, will it just pull whatever is after "sticky" and use it as the message?

#

Or do I need to use something like ctx.fetch_message? Is that only for a message outside of what the user pinged it with?

blissful badge
#

Why, lol

slate swan
#

u have nitro so i asked

blissful badge
#

Oh

#

I am an adult

slate swan
#

oh

blissful badge
#

I think aha

quick gust
#

so the latest message?

slate swan
#

Hello

naive briar
#

Hi 🐈

blissful badge
# quick gust so the latest message?

It would be whatever message the user sent with it, or thats what I want.

So for example ?stick test message

and it would keep "test message" at the bottom of the chat

quick gust
#

idk if that's possible without repeatedly sending it and deleting the previous message every time someone sends something

slate swan
#

You store your message somewhere then periodically re-send the contents of the message (probably either with task loop or on_message) whilst deleting the previous sticky message

blissful badge
#

Yeah that would be the goal

#

So I guess thats where I would get stumped, at how/where to store the message contents

quick gust
#

you can use a database

slate swan
#

Just storing it inside a script variable would be quick and easy, but you can also use some sort of database to keep your data safe between restarts

quick gust
#

I guess?

blissful badge
#

That is definitely where my python knowledge starts to waver, so imma have to do some research. If anyone has any good resources for setting up a database that I can try and learn from that would be awesome, if not imma dive in and start looking around.

Appreciate the answers!

quick gust
#

For such a small task you could use json for the time being, until you learn how to use a database

slate swan
#

My recommendation is to familiarise yourself with SQL and install aiosqlite or a similar library, which makes database operations pretty simple

#

umm can anyone tell me how to learn python lol

#

#databases is also a good place to ask questions regarding SQL as well

slate swan
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.

slate swan
#

DM?

uneven hearth
#

can someone help me please? i'm using discord:Member for certain commands, and when i'm kicking/banning someone, it keep showing me the list of members in the server, even if the user is not even there anymore.

unkempt canyonBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

uneven hearth
#

?

hushed galleon
#

what keeps showing the kicked/banned member? the Guild.members attribute? the autocomplete on a slash command? sharing your code makes it easier to figure out what's happening

willow hawk
#

How does the dank memer bot include commands in the about me? When you click on them, it executes the command in the current channel.

hushed galleon
willow hawk
#

How do you find the id?

hushed galleon
#

not sure of an easy way to do so while in-app but you can fetch it through their api

willow hawk
#

Thanks!

tough lance
#

@willow hawk for you ^

hushed galleon
#

oh right, i heard that before but forgot how to do it and was right clicking the literal text

ionic garden
#

how do i insert a button between two other buttons?

#

there's a generic thing i wanna use in multiple classes

#

but i don't want it to just be tacked at the end

tough lance
#

Remove last button, add the middle button. Re add the last button.

ionic garden
#

jesus that's scuffed

ionic garden
#

after running this the backpack button is still at the back

tough lance
smoky sinew
#

@blissful badge i don't know if this will work, but try this

sticky_messages = {}

@bot.command()
async def sticky(ctx, message: discord.Message) -> None:
    if message.author != bot.user:
        await ctx.send("Sender must be bot")
        return

    sticky_messages[message.channel.id] = message.id
    await ctx.send("Stickied the message")

@bot.event
async def on_message(message: discord.Message) -> None:
    if message.channel.id in sticky_messages:
        sticky_message = await bot.fetch_message(sticky_messages[message.channel.id])
        await sticky_message.delete()
        await message.channel.send(sticky_message.content)
blissful badge
smoky sinew
#

this will only work temporarily, you will probably want sqlite

#

i will make a better version hold on

fading marlin
#

you need a channel to use fetch_message 🤔

smoky sinew
#

yeah

fading marlin
#

you can also just get a partial message

hushed galleon
#

well re-sending the message requires knowing the original content so fetching is probably necessary (unless you don't mind caching the content)

fading marlin
#

oh I didn't see the message.content

smoky sinew
#

but PartialMessage works for that

ionic garden
tough lance
ionic garden
#

i did

#

result:

#

nvm i had to do some weird stuff w/ the ordering first

#
        exit_button = self.children[1]
        self.remove_item(exit_button)
        self.add_item(Backpack(row=1))
        self.add_item(exit_button)
        self.add_item(DecisionSelect(choices))
```god, this is cursed
slate swan
#
async def on_message(message):
    if not message.content.startswith(client.command_prefix):
        # Check if the message contains an IP address
        import re
        ip_pattern = re.compile(r"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")
        if ip_pattern.search(message.content):
            # Timeout the user and delete the message, unless the user is a server owner
            if message.author != message.guild.owner:
                await message.channel.send(f"{message.author.mention}, please do not post IP addresses in the chat.")
                await message.delete()
                await message.author.timeout(reason="Posting IP address", timeout=60)  # Timeout duration in seconds
                return

    await client.process_commands(message)```
#

i want to make this timeout the discord user for 60 secs if they post a ip

potent spear
#

also, I highly suggest you to use "guard clauses" in programming, it prevents indentation like yours
(where you're 3 indentations deep already and it becomes unclear what if statement is where)

slate swan
#

i want it to use the discord /timeout then the user thats posting ips it would time them out for 60 secs

potent spear
#

and what's currently going wrong in your implementation?

slate swan
#

its not timing the user out

potent spear
#

does it ever send this message
await message.channel.send(f"{message.author.mention}, please do not post IP addresses in the chat.")

slate swan
#

yeah

potent spear
#

does it delete the message?

slate swan
#

yeah

slate swan
potent spear
#

so this line
await message.author.timeout(reason="Posting IP address", timeout=60)
never gets executed? that's your actual issue?

slate swan
#

it never get executed

potent spear
#

are you sure? can you print something underneath that line and check if it does get printed?

slate swan
#

i want it to timeout the person who posting a ip for 60 secs

potent spear
#

you already said that...

slate swan
#

ok

potent spear
#

no private DMs, I'm not a private tutor, just keep everything in this discord server and someone else can also help...

slate swan
#

ok

potent spear
#

maybe you should time the author out first and then delete the msg, not sure

slate swan
#

i cant timeout my self out im a owner

#

can someone help me please ?

#

you named varriable bot and used client instead

#

!d discord.ext.commands.Bot.latency

unkempt canyonBOT
#

property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.

This could be referred to as the Discord WebSocket protocol latency.
slate swan
#

oh yeah my bad 😂

#

thanks

smoky sinew
#

it's positional-only and it requires a timedelta or datetime

#
await member.timeout(
    datetime.timedelta(seconds=60),
    reason="Posting IP address"
)
slate swan
slate swan
#

is this code correct ?

#

@slate swan

ionic garden
smoky sinew
potent spear
smoky sinew
#

commands.author is not a thing

slate swan
slate swan
smoky sinew
#

you probably meant ```py
print(f'".ping" command used by {ctx.author}')

but you should do this as a global check instead
ionic garden
potent spear
#

Can’t disagree with that

potent spear
#

It’s not bad

slate swan
#

@smoky sinew what "f" means ?

smoky sinew
#

!f-strings

unkempt canyonBOT
#
Format-strings

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

smoky sinew
#

there is also b"" r"" and other types of strings

slate swan
#

oh ok

#

tysm for help

#

worked yes_ecp

slate swan
hushed galleon
smoky sinew
#

the person who invoked the command

slate swan
smoky sinew
#

of what

ionic garden
#

i mean idk what an example would be in this scenario

#

it just gives the discord user that invoked the command- simple as that

smoky sinew
#

doing what with it

smoky sinew
#

that doesn't make sense

#

you can just print it, would that count as an example

#

it returns a union of Member or User

slate swan
#

this was just funny

#

love copilot

ionic garden
#

this is beautiful

cinder tulip
#

how can i make something like this??
i tried making something already but i got no idea on how to proceed (ignore that "group" i put there i was trying something lmao)

@client.tree.command(name="h", description="desc")
@app_commands.describe(general="general")
@app_commands.describe(admin="admin")
@app_commands.describe(dev="dev")
async def h(interaction: discord.Interaction, general: group)
hushed galleon
# cinder tulip how can i make something like this?? i tried making something already but i got ...

do the choices have to be dynamically generated? if so, you'd want to add an autocomplete for that command option
decorator-style: https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.Command.autocomplete
transformer-style: https://discordpy.readthedocs.io/en/stable/interactions/api.html#transformer
if not, hardcoding choices using the @app_commands.choices() decorator or one of its alternatives would be sufficient
https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.app_commands.choices

slate swan
#

could you help me please ?

#

my token is valid :/

#

and my script too

#

@slate swan @smoky sinew my heroes

smoky sinew
#

it tells you what to do

#

in the error message

#

it has the link too

slate swan
#

OH YEAH MY BAAAD

#

lmfao tysm i'm dumb

uneven hearth
smoky sinew
#

that's probably just your client cache

graceful ermine
#
import akinator as ak


class buttons(nextcord.ui.View):
    def __init__(self):
        super().__init__()
        self.ak = ak
        self.bot = bot
 


    @nextcord.ui.button(label="yes?", style=nextcord.ButtonStyle.success)
    async def yes(self, button: nextcord.Button, interaction: nextcord.Interaction):

        
        aki = ak.Akinator()
        while aki.progression <= 80:
            await msg.edit(content=q)
            msg = await bot.wait_for("message")
            try:
                q = aki.answer(msg.content.lower())
            except ak.InvalidAnswerError as e:
                await interaction.send(e)
                continue
        aki.win()
        await interaction.send(f"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?(y/n)\n{aki.first_guess['absolute_picture_path']}\n\t")





@bot.slash_command(name="guess", description="test")
async def akinator(interaction: nextcord.Interaction):
    msg2 = await interaction.send("Akinator is here to guess!")
    msg2
    view = buttons()

    try:
        aki = ak.Akinator()
        q = aki.start_game()
        msg = await msg2.edit(content=q, view=view)
        msg = await bot.wait_for("message")
        if msg.content.lower() == "b":
            try:
                q=aki.back()
            except ak.CantGoBackAnyFurther:
                await interaction.send(e)
                
        aki.win()
        await interaction.send(f"It's {aki.first_guess['name']} ({aki.first_guess['description']})! Was I correct?(y/n)\n{aki.first_guess['absolute_picture_path']}\n\t")
        correct = await bot.wait_for("message")
        if correct.content.lower() == "y":
            await interaction.send("Yay\n")
        else:
            await interaction.send("Oof\n")
    except Exception as e:
        await interaction.send(e)```
How could I make it where after pressing a button it edits the message to the next question?
vital glacier
#

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

exotic maple
#

can someone help? please
i loop through a list of role ids (could be empty btw)
i get this error?
heres my code also:

this is also whats in the addroles list

#

I am also 100% that the role exists in the server

smoky sinew
#

what is server

#

wait

#

are you doing guild.get_role([role_id])?

#

that would explain why

exotic maple
smoky sinew
exotic maple
smoky sinew
#

what is roleid

exotic maple
#

the variable above#

smoky sinew
#

what

#

that does not help

exotic maple
#

what will help

#

@smoky sinew

smoky sinew
#

tell me what roleid is

exotic maple
#

im looping through the list addroles
each time it checks if it is not equal to None
if so then i want it to reply with the role and mention it

smoky sinew
#

yes but what is the value of roleid

exotic maple
#

the discord roles id that i want to mention

smoky sinew
#

lol

exotic maple
#

what

smoky sinew
#

just print it

exotic maple
#

i select the ID from the database depending on something

#

i dont know the actual id until the code runs

smoky sinew
#

then print the id when the code runs

exotic maple
#

as it will be a public bot

#

thats what im trying to do

#

it prints this variable

smoky sinew
#

just add print(roleid)

exotic maple
#

this is what it prints

#

the role id i want to mention

smoky sinew
#

then it should be fine

exotic maple
smoky sinew
#

what is your full code

#

of the command

smoky sinew
#

@exotic maple do you still need help?

sick sleet
#

🙏its been staring me in the face this whole time.

slate swan
#

idk what to choose
ive done disnake and hikari
dpy is almost gibberish to me
pycord seems like its bad and nextcord--whatever nextcord is

smoky sinew
smoky sinew
#

if you want you can just spin a wheel or something

sick sleet
#

I did, was stuck on this until I thought to search this chats history

smoky sinew
#

that's what i usually do when im stuck on something software development related

slate swan
#

aaaaaaaaaaaaaaaa

smoky sinew
#

hikari does not have much documentation online apart from the official site

smoky sinew
#

#bot-commands

dense jackal
#

I would like to code something like that, does someone have a documentation or any ideas how?

#

When you type in, message deletes and is replaced by the embed with an autothread

drifting arrow
#

Anybody worked with mongodb before?

smoky sinew
smoky sinew
smoky sinew
dense jackal
drifting arrow
# smoky sinew i have

Would you happen to know how I'd set my index type to be string?

playerids = db["playerids"]
playerids.create_index("steamid", unique=True)

Currently it sets the index type to Int64

smoky sinew
drifting arrow
smoky sinew
#

ah true

#

mongodb doesn't enforce data types does it

drifting arrow
#

¯_(ツ)_/¯

#

first time using it.

smoky sinew
#

i switched to sql 😭

drifting arrow
#

Trying to move from aiosqlite to a better database

#

since apparently aiosqlite doesnt handle high traffic well

smoky sinew
#

there are many different types of sql databases

drifting arrow
#

Tried postgresql first 😛

#

Friends system said no

smoky sinew
#

huh?

drifting arrow
#

idk it wouldnt work on my friends system and since he's in a different country I didnt wanna bother troubleshooting it lol

#

So he told me he already has a mongodb so I had to change to mongodb ;-;

#

it's great coz it means I get to change my code for a 3rd time 😄

#

anyway. ty anyway @smoky sinew

#

i'll just go change all my inserts to be str()

vale wing
vale wing
unkempt canyonBOT
slate swan
#

i fr ttributeError: 'ClientUser' object has no attribute 'token' tried to fix it so many times

vale wing
#

And for what reason are you even making calls to discord API manually

#

!d discord.Guild.invites

unkempt canyonBOT
#

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

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

You must have [`manage_guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") to get this information.
vale wing
#

What the hell does that code even do tho

slate swan
vale wing
#

To start with, you don't even need to do manual requests to discord API

slate swan
#

listen

#

I know what Im doing fr

vale wing
#

Lib's got coverage

slate swan
#

i just need to fix this attribute issue

vale wing
#

Bring token out to variable and use it

vale wing
slate swan
#

LOL

slate swan
#

but its not changing the vanity. ill just add some checks to help debug the issue

slate swan
vale wing
unkempt mauve
#

Code: https://paste.pythondiscord.com/izipujojaz
Issue: discord.app_commands.errors.CommandInvokeError: Command 'chapter' raised an exception: UnboundLocalError: cannot access local variable 'chap_name' where it is not associated with a value

slate swan
#
        if chap_name_information:
            chap_name = chap_name_information["name"]
            chap_name_arabic = chap_name_information["arabicname"]
            chap_name_english = chap_name_information["englishname"]
            revelation_place = chap_name_information["revelation"]
            number_of_verses = len(chap_name_information["verses"])
``` what if `chap_name_information` will be False

then `chap_name` wont be defined and when you try to use this varriable later on it will throw this error
unkempt mauve
#

is there issue with the index?

slate swan
#

add else and do something with chap_name when chap_name_information is false

#
if chap_name_information:
    ...
else:
    ...
unkempt mauve
#

the issue is the index for sure

unkempt mauve
drifting arrow
#

has mongodb got an upsert statement?

shrewd fjord
#

"vanity snipe" 💀

slate swan
slate swan
#

pls what's wrong with this line ?

async def ping(ctx, code : discord.Option(str or float, "First operation term", required = True), discord.Option(int or float, "Second operation term", required=True)) :
#

send traceback not pylance error

#

run code and see if you get one

glad cradle
slate swan
#

yeah that as well

#

!pep 604

unkempt canyonBOT
#
**PEP 604 - Allow writing union types as ``X | Y``**
Status

Accepted

Python-Version

3.10

Created

28-Aug-2019

Type

Standards Track

slate swan
#

how can i do for ?

glad cradle
slate swan
#

!discord.Option lets see

#

it works with my other bot

#

forgot doc

#

is there even something like discord.Option

glad cradle
#

what library are you using @slate swan

glad cradle
slate swan
#
async def ping(ctx, code : discord.Option(float, "First operation term", required = True), discord.Option(float, "Second operation term", required=True)) :
#

i corrected

glad cradle
slate swan
slate swan
#

first is code

glad cradle
#

pycord is imported like d.py too but they diverge, so again, what library are you using?

glad cradle
slate swan
#

you can but

#

you can do import nextcord

#

and most peoples do import nextcord

and me as well

slate swan
glad cradle
# slate swan

I'm not asking if it can be done, I'm just proving that this doesn't answer my question

slate swan
#

to @glad cradle too 🫂

slate swan
#

import discord means nothing

glad cradle
#

lemme check pycord since he's hiding it

slate swan
#

but most likely its going to be d.py

glad cradle
slate swan
#

so you are telling me he is using pycord and doesnt even know he is using pycord

glad cradle
#

ahahha yeah

slate swan
#

and how can i create options like this ?

#

in pycord

no idea

glad cradle
#

they're options with a default value so they're Optional

slate swan
#

huh ?

#

Optional meaning they are not required meaning required=False

#

my guess

#

ah

shrewd apex
#

they need a default argument

#

in the function signature

slate swan
#

and like this one (required) ?

shrewd apex
#
async def foo(inter: Interaction, arg: str = "") -> None:
#

arg is optional here

#

cuz it has a default value

glad cradle
#

but maybe the required False works too, lemme check pycord shit docs

shrewd apex
#

🤔

#

maybe

glad cradle
glad cradle
slate swan
shrewd apex
slate swan
#

and like this one (required) ?

#

this one is Channel type or something like that

#

could you give me code line or something like that to make my own options (required) ?

#

no i mean instead of saying its float type you say its channel type and it should display channel picker

#

but no idea what name Channel class have in pycord

glad cradle
#

let's see

slate swan
glad cradle
#

my ass is saying he need to pass abc.GuildChannel as type

slate swan
#

i don't want to pick channels, i want to make my own options :/

slate swan
slate swan
#

i just meant that i need required options buddy :D

#

not many people here know pycord well if you want to receive help faster you should look into their support server: discord.gg/pycord

glad cradle
#

should be something like that

async def foo(ctx, channel: discord.Option(abc.GuildChannel, "desc", required=True), ...):
    ...
slate swan
#

ok tnks

glad cradle
slate swan
#

i dont see any huh

#

can i get help to bot isnt sending the list

#

@slate swan

#

sry for ping

#

error?

#

umm when i am sending message on the server its not sending message

#

error in console i mean

#

none

#

console and terminal are same thing right??

#

yes

#

ya none error

#

it is running

#

add a simple print statement inside this if and see if it prints

#

ya that works

#

but this dosent

#

need server link??

#

no why

#

Are you using discord ui buttons

#

i thout it would help

slate swan
#

The interaction buttons decorator

#

Or the view.

#

n

#

i am sending message

#

Oh. You only have member intents.

#

huh?

slate swan
#

so? lol

#

You need message intents

slate swan
#

message content or message lol@slate swan

#

@slate swanthanku sir it worked

slate swan
#

Hello

#
    @voice.command()
    async def lock(self, ctx):
        id = ctx.author.id
        self.c6.execute("SELECT channelID FROM voiceChannel WHERE userID = ?", (id,))
        voice = self.c6.fetchone()
        if voice is None:
            await ctx.channel.send(f"{ctx.author.mention} You don't own a channel.")
        else:
            channelID = voice[0]
            channel = self.bot.get_channel(channelID)
            if channel is None:
                await ctx.channel.send(f"{ctx.author.mention} You are not connected to any voice channel.")
            else:
                role = ctx.guild.default_role
                await channel.set_permissions(role, connect=False)
                await ctx.channel.send(f"{ctx.author.mention} Voice chat locked! 🔒")
        self.conn6.commit()

i want to make this into a button

#

someone help me pls

dull terrace
#
await c.execute(
    """CREATE TABLE IF NOT EXISTS scheduled(
        guild INTEGER,
        channel INTEGER,
        post_type TEXT,
        time INTEGER,
        index INTEGER DEFAULT 0
    )"""
)```

sql is mad at me, am i blind... where is the error
#

says near index 7739monkathink

slate swan
#

seems correct

dull terrace
#

is index able to be used in sql or

slate swan
#

yes

#

the index name may be used already by sql

dull terrace
#

yeah i googled, it's reserved

slate swan
#

DOWN

#

could you possibly help me

slate swan
#

I want to make that into a button

#

when pressed it will do exactly that lock button

#

check if the user is the vc owner if so it will lock the channel from @everyone - default role

#

simple as that.

#

I know how to do simple buttons, i'm having issue with making a button to do what i want.

#

i dont see any button in code you provided

#

I know as i told you, i want to convert the script into a button

#

So when pressed it will do what the script does.

#

I am using @voice.commands

#

and what voice varriable is?

#

what?

#

how you defined voice

#

;voice <command>

smoky sinew
#

what

slate swan
blissful badge
#
@bot.event
async def on_message(message: discord.Message) -> None:
    print('Turlington has been mentioned.')
    if bot.mentioned_in(message):
            await message.channel.send(f"Hello! I am Turlington, say `?command` for more info on what I can do! If you are having any issues with my functions please tag ian `@blissful badge`.")

Hey everyone, tryna figure out why this isn't responding in chat.

Any ideas?

blissful badge
# smoky sinew where is this event?

Same as it is in the GH you have! Actually it's the first command after all the identifying stuff. Just stepped out for coffee will give line # in a sec.

blissful badge
#

@smoky sinew replaced the command at line #85 in the GitHub

smoky sinew
#

the code looks different from what you showed

blissful badge
#

Yeah the code there is outdated, I am trying to replace it with the above but its not working

#

Let me update the GH

#

@smoky sinew ok its been updated with the new code