#discord-bots

1 messages · Page 238 of 1

vale wing
#

Then it's as simple as this


from datetime import time


@tasks.loop(time=time(hour, minute, second))
async def your_task():
    ...
#

Don't forget to start the task using suitable method tho

eager portal
#

anyone able to help me

slate swan
#

Yeah that's what I meant though don't you have to give a specific date and time? Which leads to it being executed once only and then when it gets executed you can just set the new interval?

Kind of forgot how dpy handles tasks with the time kek

vale wing
slate swan
#

Makes sense then it's every day at the given time

vale wing
#

And I have sort of "daily reset" task in my bot with time=time(0) it executes correctly

#

But that's disnake

slate swan
#

Yeah probably very similar

eager portal
#

.

vale wing
#

Iirc the permission is called read_messages

#

!d discord.Permissions.read_messages

unkempt canyonBOT
vale wing
#

Yes

eager portal
vale wing
#

Is that if clause the only where you create channel

eager portal
#

channel = await support.create_text_channel(name = f"{interaction.user.name}-{interaction.user.discriminator}-ticket", overwrites=overwrites, reason=f"Ticket Opened for: {interaction.user}")

#

I am mentioning the overwrites every other overwrite works

#

just not that one

vale wing
#

Does the category have permissions

eager portal
#

It does

vale wing
#

Apologies, view_channel is an alias for read_messages

#

Unless you are creating channel in different guild than interaction was created in I see no other issues except interaction.user and interaction.guild.me should be same things

eager portal
#

anyone able to help me out

slate swan
potent spear
slate swan
#

return a bots embed message

#

to then edit it

potent spear
#

discord.TextChannel.get_partial_message(...)
an object is an instance of a class

#

I like how you use the docs, but when they're showing how to use certain methods like
get_partial_message
they refer to discord.TextChannel as an object of that class

#

that why you want to do stuff like

text_channel = client.get_channel(<channel_id>)
partial_msg = text_channel.get_partial_message(<message_id>)```
slate swan
potent spear
# eager portal anyoine

how are you testing that the default role can still see it? you're not giving yourself (as an admin) no roles, right? 🧠

potent spear
#

you see its simplicity?

slate swan
#

first 1 goes through the class structure and the 2nd is self-defined variables as objects? but they return the same value?

potent spear
#

that's why you want to call methods on instances of these classes

slate swan
#

ohhhhhhhhh

#

so im looking for the channel first, then the message

potent spear
#

by name or ID?

#

wait, explain your main goal first

#

maybe getting the channel isn't even needed

slate swan
#

id or it would be harder to find by name

role react buttons and custom embed that i can dynamically add/remove roles to. i got the embed to add/remove from, but it sends a new one each time currently

#

instead of editing 1

potent spear
#

so your message ID will always be the same, correct?

slate swan
#

right

potent spear
#

then you'll have to store that message ID in a database to persist it. are you doing this already?

slate swan
#

yes

potent spear
#

that's good

#

one issue though

#

why are you casting it to an int?
haven't you stored it as an integer?
if it was stored as a string, you should rewrite your database structure
note that a txt isn't a database

#

that isn't a message ID though...

#

so I ask you again, how are you storing the message ID?

slate swan
potent spear
#

yup, should be an int

slate swan
#

it allows input as a slash command.

earnest swift
#

Does anyone know how to make your discord bot give an user a role

potent spear
potent spear
potent spear
eager portal
slate swan
#

So when the command calls for the input of the message id, i should just convert it straight to an int and use int instead of str after that point?

potent spear
#

you cast it to its correct type and move on from there

#

also, I highly discourage you to except all errors, try except a specific error you're expecting

vivid axle
#

im trying to make an api to interact with my discord bot, just to get how many guilds, channels & users it has, how would i start this. im using dpy

slate swan
#

is there a reference for what type of errors each function would throw though? I've just been using the whole error to figure out whats wrong.

vivid axle
#

wdym

potent spear
vivid axle
#

ok

potent spear
#

are you sure you even need a discord bot for this?

potent spear
#

you should make a database which stores the message ID with all info of each guild
if there's no message ID set up in the database for a specific guild the bot joined, the bot will ask the authorized members (most likely the owner of the guild) to give it a channel and message ID to create this info message.
If the bot notices the channel or message got deleted, it'll ask the guild owner AGAIN to set up a new message ID etc

formal forum
#

$help

inland quailBOT
#
MemberJoinMonitoring:
  creation_time All commands related to the Creation time trigger.
​No Category:
  help          Shows this message

Type $help command for more info on a command.
You can also type $help category for more info on a category.
slate swan
potent spear
#

so you'd only have to do an API call when you were editing the message, since it would already know beforehand if the message got deleted (or the channel)... unless the bot was offline while that happened, then you'd have to use some sort of system you currently tried to set up, but way simpler

#

that system would look like
setup_channel_id = get the channel ID out of the database for this guild
message_id = get the message ID out of the database for this guild

setup_channel = client.get_channel(setup_channel_id)
if setup_channel is None:
1. update the database and reset all setup info of that guild, as the channel wasn't found anymore
2. notify the guild owner to set up a new channel and info message
same thing in case the setup_message got deleted while the bot was offline (which means the get_partial_message wouldn't find anything in the given channel)

slate swan
#

hmm ok. so use that data stored more than I am. less API calls = better all around.

potent spear
#

well, idk when you'd make API calls now, but yeah, idk where you'd otherwise get all the setup INFO from besides a DB

vivid axle
potent spear
vivid axle
#

do u know name or link?

potent spear
#

no, google does probably
what would you google in this case?

vivid axle
#

um

#

idk

potent spear
#

yes you do

vivid axle
#

how

potent spear
#

by thinking about it

vivid axle
#

i thought and i cant think of it

slate swan
# potent spear well, idk when you'd make API calls now, but yeah, idk where you'd otherwise get...

so far I haven't made slash commands till this past week. Now that I finally have a grasp on it a bit, I plan on using the db more, but wasn't sure what to use it for yet. this is just some basic command to edit the roles on an embed. then the button view will follow the dataset for the role names in the embed. I was just thinking of setting up the buttons knowledge for a persistent view to be in a db. not the editing the embed part.

potent spear
vivid axle
#

all that comes up is the discord api or dsicord.py api

potent spear
#

what did you try?

vivid axle
#

what i send

potent spear
#

something along the lines of "show discord server statistics on website"

vivid axle
#

firstly

potent spear
#

this isn't discord bot related

vivid axle
#

...

potent spear
slate swan
potent spear
#

you can see them in the link shared above

slate swan
#

so would I have to setup like a query for the custom id to assign the right role from there then?

potent spear
#

well, I think you're worried to much of what's coming

#

have you been able to add / remove a role from a user by clicking on a button in the first place?

#

if that's the case, adding a custom_id to that button would be a piece of cake

slate swan
#

not yet. that was my next step after editing the message

potent spear
#

well, you're thinking too much ahead, try making simple buttons first before thinking about the persistency

vivid axle
#

i looked onlin and it says to make an api or websocket or something which i dont understand

potent spear
vivid axle
#

thank you sniperglitcherz

potent spear
slate swan
#

these change both text and voice channels associated with em. So yeah it should be fine.

#

that was my first project

potent spear
#

making this as user-friendly as possible for users is the main challenge usually

slate swan
junior falcon
smoky sinew
vivid axle
#

ok

vivid axle
smoky sinew
#

asyncio event loop

slate swan
smoky sinew
#

which is what runs async tasks

vivid axle
#

ok

smoky sinew
#

just go to the thread

#

you already made one

slate swan
vivid axle
#

thread

slate swan
#

just curious. with slash command interactions. what can u use to get the thread.id?

earnest swift
#

Does anyone know how to make your bot give an user an role

robust fulcrum
smoky sinew
coral mirage
#

Hello everyone! Is anyone enable to give me a hand?

smoky sinew
#

what about it

coral mirage
# smoky sinew what about it

so, the command is not working. It doesn't send errors, but also doesn't do its function. Function suppose to send +75 to population in table users and +25 in reserves per purchase and it suppose to send +5 citizen in population as well per hour per residential own and +1 to reserves.

I send the command, but no errors, but neither do the function properly. It doesn't send the 75 or 25 and it doesn't add the hours either.

slate swan
#

whar is the problem

sick birch
# slate swan

Hi, this is a Python server so we only help with Python code. Perhaps you could try a JavaScript server for help?

tired pine
# slate swan

well this is a Python server but I can guess that you're not providing any error handlers for the event

slate swan
#
path = None
################################################3


@tree.command(name="choose", description="c", guild=discord.Object(guildid))

@app_commands.choices(account=[
        app_commands.Choice(name="roblox", value="r"),
        app_commands.Choice(name="minecraft", value="m"),
])

async def rbx(ctx, account: app_commands.Choice[str]):

    if app_commands.Choice == "roblox":
        path = robloxpath

this still continues as if path is still none despite me looking at the user choice? im new to slash commands i dont understand

ember glen
vocal snow
#

Your if statement is also incorrect

ember glen
#

path = None
################################################3


@tree.command(name="choose", description="c", guild=discord.Object(guildid))

@app_commands.choices(account=[
        app_commands.Choice(name="roblox", value="r"),
        app_commands.Choice(name="minecraft", value="m"),
])

async def rbx(ctx, account: app_commands.Choice[str]):
    global path
    if account.name == "roblox" : 
      path = robloxpath

Add account.name instead of app_commands.Choice as the choices are formed as key value pair.

#

hope now it is working for u

#

Is there any way to pick custom color for discord embed? I mean I want a color code for discord embed color, so is there any website which will provide me with all the codes?

thin raft
#

you can use hex for colors

ember glen
#

Oh ok, thanks!

#

And is there any way to make name and value in add_field side by side?

thin raft
#

play withdiscord.Embed.inline

#

!d discord.Embed

unkempt canyonBOT
#

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

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

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

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
ember glen
#

I want the output like this -

name : value

But I am getting this

value```
ember glen
thin raft
#

"inline (bool) – Whether the field should be displayed inline."

#

try

#

1 inline one dont

ember glen
#

alright

#

Also, is there any way to create an empty gap in embed?

#

like there is <br> in html

thin raft
#

try making a field that it's name is a space

ember glen
#

and \n in python

thin raft
#

idk

ember glen
#

thanks though, Imma try it

slate swan
idle lantern
#

hi just started learning

#
import discord
import os
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")

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

# client = MyClient(intents=intents)
client = commands.Bot(command_prefix="$", intents=intents)


@client.event
async def on_message(message):
    print(f"Message from {message.author}: {message.content}")
    if message.author == client.user:
        return
    if message.content.startswith("$hello"):
        await message.channel.send("Hi")


@client.event
async def on_ready():
    print(f"{client.user} has connected.")


@commands.command(
    name="say",
)
async def say(ctx):
    await ctx.send("Hi Snowman")


client.add_command(say)

client.run(TOKEN)
#

what am i doing wrong here?

#

the command is not working

#

@client.command(
    name="say",
)
async def say(ctx):
    await ctx.send("Hi Snowman")
``` i tried it like this as well
cold sonnet
#

if you haven't gotten an answer yet

idle lantern
#

ohhhh

glad cradle
#

he/she can use @client.listen() instead

idle lantern
glad cradle
cold sonnet
#

client.listen is a method so you will have to call it with brackets

idle lantern
cold sonnet
#

yes

glad cradle
#

yes, with the parenthesis as Dani said

idle lantern
#

ok thanks i will try that

#

thanks it works now

unkempt mauve
#

discord is restricting my bot from sending interaction to info command. (other commands are interacted), why?

slate swan
unkempt mauve
#

and the interaction to the info command is not sent

unkempt mauve
#

sure

#

the both code and message?

slate swan
#

can be

unkempt mauve
#

The bot is hosted on a private server not repl it, So theres no chances of ip being shared

naive briar
#

How do you know

unkempt mauve
#

Its literally in the console and also seen when the bot is not sending interaction

naive briar
#

How do you know that the IP isn't shared

unkempt mauve
slate swan
unkempt mauve
#

they do send interaction

naive briar
unkempt mauve
#

its only restricting the info command

naive briar
#

Why would they just rate limit a single command

slate swan
#

also @unkempt mauve i would recommend removing the error paste link

#

since it reveals your ip

unkempt mauve
#

🤣

slate swan
#

the error comes from the server so its server ip i belive

unkempt mauve
#

then I delete

#

the link

slate swan
#

did you try reseting the token? or rebooting your bot?

unkempt mauve
#

Okay what do I do? Could it be one of the following reasons?

  1. The for loop that counts guild members and channels
  2. The bot is banned from sending interaction to info command
unkempt mauve
#

I should probably reset the token

#

If the bot was restricted, it should not be sending any interaction but it's only not sending to info command and other commands are working fine. thats so weird

slate swan
#

and replace in your code

unkempt mauve
slate swan
#

okay then

unkempt mauve
#

the bot is still being restricted from sending interaction to info command

#

breh

#

Why the other commands working then

#

its so weird

naive briar
slate swan
unkempt mauve
#

Is discord having issues with guild things

unkempt mauve
#

but the bot is now only restricted to a command

eager portal
#

How can I attach a local image to my embed to send in someones dm for example a captcha code and have them reply to the interaction with the correct code like as a select menu but where the user can input the correct code

eager portal
slate swan
#

You can use Modal

#

!d discord.ui.Modal

unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
robust fulcrum
#

Hi guys, i want to make a discord.py game bot, can anyone suggest me what type of game should I make, like which discord.py games are famous these days

analog snow
#

I know this is probably a stupid question, but do we like, need our own server to keep our bot online or will Discord provide us with one?

analog snow
#

Ok thank you for letting me know

eager portal
#

Can someone help me out, heres my capatcha embed:

I want the user to be able to respond to that with a drop down menu as an input but in dms with the correct capatcha code or just respond saying the code how can I do this

eager portal
#

I can't in dms

smoky sinew
#

!d discord.InteractionResponse.send_modal

unkempt canyonBOT
#

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

Responds to this interaction by sending a modal.
eager portal
#

can I

smoky sinew
#

since when

eager portal
#

how do I? its not working form e

#

await dm.send_modal(CapatchaModel())

smoky sinew
#

why is it not working

#

you need an interaction

#

it's InteractionResponse.send_modal

eager portal
#

how can I send this in dms when a user joins my server

smoky sinew
#

maybe use a button to open the modal

eager portal
#

thanks mate

robust fulcrum
smoky sinew
unkempt canyonBOT
#

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

Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
robust fulcrum
smoky sinew
#

restart it completely?

#

because reloading an extension is like ten times quicker than restarting your bot

robust fulcrum
#

i mean something like nodemon(node js)

smoky sinew
#

yes i know what hot reload means

robust fulcrum
smoky sinew
#

discord.py doesn't have any native support for it, the closest you can get is extension reloading which can be done on the fly, so you will need to build your own program that reloads extensions when their file changes

robust fulcrum
# smoky sinew discord.py doesn't have any native support for it, the closest you can get is ex...

i tried watchdog bt its not working

import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import subprocess


class FileHandler(FileSystemEventHandler):
    def on_any_event(self, event) -> None:
        cmd = "python bot.py"
        subprocess.call(cmd, shell=True)


subprocess.call("python bot.py", shell=True)
event_handler = FileHandler()
observer = Observer()
observer.schedule(event_handler, path=".", recursive=True)
observer.start()
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    observer.stop()
observer.join()
smoky sinew
#

why are you fully restarting the bot

#

that's not what hot reload means at all

robust fulcrum
smoky sinew
#

like i said reload an extension within the bot, you could do it by running watchdog inside a separate thread

robust fulcrum
smoky sinew
#

i wouldn't know i haven't touched watchdog

eager portal
#

How do I get the contents of the input from my modal>

slate swan
eager portal
#

discord py

unkempt canyonBOT
#

examples/modals/basic.py lines 57 to 58

async def on_submit(self, interaction: discord.Interaction):
    await interaction.response.send_message(f'Thanks for your feedback, {self.name.value}!', ephemeral=True)```
eager portal
slate swan
eager portal
#

How can I get the capatcha code to my modal:

        data = Capgen(member.display_name)
        modal = CapatchaModal()
        modal.code = data
slate swan
#

yo, can someone help me with something?

smoky sinew
slate swan
eager portal
smoky sinew
#
def __init__(self, argument: ArgumentType) -> None:
    super().__init__()
    self.argument = argument
slate swan
#

someone know where is problem?

vocal snow
#

why use discord_slash? discord.py 2 has slash command support

smoky sinew
#

yes do not use discord_slash

slate swan
#

so, discord_slash is trash right?

eager portal
#

yes

robust fulcrum
smoky sinew
#

that would be the best solution

eager portal
#
'NoneType' object has no attribute 'roles'
role = discord.utils.get(interaction.guild.roles, name="ᴹᴱᴹᴮᴱᴿ")
await interaction.user.add_roles(role)

Why am i getting that error

smoky sinew
#

your interaction is in a DM, therefore the guild is None

eager portal
#

oh yes

smoky sinew
#

you should also at least be checking if the role exists, because otherwise you will get another error if the role is ever deleted or the wrong server is used

#

even if it's a private bot it's best not to hardcode it and put it as something configurable

eager portal
#

how can I give the user the role in the server from the guild id

smoky sinew
#

get the guild first

eager portal
#

yes got that

smoky sinew
#

remember the user isn't in a guild while in the dm

#

if you have the original member object you can use that since it will have a guild attribute

sterile goblet
#

so I started today and got here

#

how do you input slash commands on discord py

twilit grotto
sterile goblet
#

uhm okay

slate swan
tall temple
#

how can i add option with @ decorator for slash command ?

tall temple
#

like @bot.slash_command

#

etc etc

smoky sinew
#

what is slash command option

tall temple
#

like that

smoky sinew
#

discord.Option does not exist

#

options are created using arguments in functions

tall temple
smoky sinew
tall temple
#

i'm searching to use options with @ decorator bcz i need to add autocomplete but i need an information

smoky sinew
#

in discord.py you would need to use choices, literal, or autocomplete

tall temple
#

from discord.Member selector if you know what i mean x)

#

hm ?

#

that's not what i'm searching for :/

tall temple
#

@smoky sinew

#

i want to await ctx.respond("jsp sah") for first async

#

line 125

#

but how can i process ?

smoky sinew
#

what is option

tall temple
smoky sinew
#

does that exist

tall temple
smoky sinew
#

ok

tall temple
unkempt mauve
smoky sinew
#

true

tall temple
unkempt mauve
#

😑

tall temple
#

bruh

#

it's not the prob now ....

#

i just need to await something to the first async function

#

in 125th line

unkempt mauve
#

i dont think everyone here knows about the library u using

tall temple
smoky sinew
#

decorators can only go on classes or functions

slate swan
tall temple
upbeat otter
ember glen
smoky sinew
# tall temple

like i said decorators can only go on classes or functions

tall temple
vocal snow
#

decorators can only go on classes or functions

tall temple
#

okok but how can i get the result i want with a correct syntax ?
#

okok but how can i get the result i want with a correct syntax ?

ember glen
# tall temple

Use the @Option above async and then align await with other code lines

#

Maybe that would work

tall temple
#

yeah but my option depends on customer option

ember glen
#

Hmm, that would be really complicated. Though, I would check out if I can help u with that

sterile goblet
#

question should i use visual studio with discord py

#

or use something else

#

like replit

vocal snow
#

visual studio code or any other IDE/editor you like is fine

sterile goblet
vocal snow
#

I would also recommend taking the time to learn basic python first, since discord bots can be quite complex

sterile goblet
#

yuh i am doing that right now but just wanted to know the options I would have

sterile goblet
#

can I use pycharm

vocal snow
#

Sure

#

These are just tools to write the python program

#

It doesn't matter which one you use

silent portal
#

:D

slate swan
#

How do i create a button cooldown per user in discord.py?

smoky sinew
vale wing
coral mirage
#

can some one help me with tasks.loops. It's not running.

vale wing
#

You done that?

coral mirage
#

I think I started the right way.

vale wing
#

Not a good way to do startup task

#

You need to subclass the bot and do setup in overwritten setup_hook() method

#

Although regarding tasks I think they can be started literally after they've been defined

#

Like ```py
@tasks.loop(...)
async def your_task():
...

your_task.start()```

coral mirage
#

Thanks a lot!

coral mirage
#

if I don't call the commands it won't update what it suppose to update.

vale wing
unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.

Warning

Calling this inside [`setup_hook()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.setup_hook "discord.ext.commands.Bot.setup_hook") can lead to a deadlock.
vale wing
#

Just add this at the beginning of loop and it won't execute anything until bot is ready

coral mirage
#

Thanks mate!

worthy cliff
#

How do i run a function in discord.py that takes a while to finish? It throws some error saying something took too long or something

#

The function works fine when it doesn't need to run for long

#

Its the gpt-4 api btw

vocal snow
#

!d discord.InteractionResponse.defer

unkempt canyonBOT
#

await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

This is only supported with the following interaction types...
ember glen
#

yeah this one

#

Btw is there any way I can get the most recent message of a member?

vocal snow
#

Although some more information about the issue would be nice; is the GPT4 api wrapper async? Are you using slash commands at all? Etc

eternal shuttle
#

i cant use my clear command, is there anything wrong on my code?

slate swan
dire wind
eternal shuttle
dire wind
eternal shuttle
#

line 443, in delete_messages
raise ClientException('Can only bulk delete messages up to 100 messages')
discord.errors.ClientException: Can only bulk delete messages up to 100 messages

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

dire wind
#

send the script here

eternal shuttle
#

the whole thing?

dire wind
#

just the command where the issue occurs

eternal shuttle
#

alright

slate swan
#

Can't delete more than 100 in one go

eternal shuttle
#

i was only trying to clear 10 messages

eternal shuttle
dire wind
#

np

slate swan
#

Giving straight answers isn't going to make him understand

dire wind
#

use the bulk_delete() method instead of delete_messages()

naive briar
#

!d discord.TextChannel.purge - or just this 🫠

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
dire wind
#

yez

thin raft
#

Does anyone have any resources on how could I make my own cooldown handler?

thin raft
# slate swan wdym?
    @commands.command()
    @commands.dynamic_cooldown(self.db.config.get_cooldown(ctx.author))
    async def fpp(self, ctx: commands.Context):```
#

I want to do that, but I can't for pretty obvious reasons

#

so instead of using the decorator is there any funciton I could use for checking the cooldown?

slate swan
#

rate or per ig

#

@commands.cooldown(rate=1, per=30, type=commands.BucketType.user)

#

like this ig

#

shall i ping?

#

@thin raftsry for ping i just wanna know does this work i learned it currently tho

thin raft
#

Let me a sec

#

Im eating rn

slate swan
#

lol sry

thin raft
#

k back

thin raft
thin raft
#

but I can't use self in the decorator

slate swan
#

ic

slate swan
thin raft
#

ill make my own cooldown handler

slate swan
#

sry for being useless again

#

@thin raftumm, sir can i ask a quick question? pls.....

slate swan
#

umm how do u store data of users?

thin raft
#

I use a database

slate swan
#

like i learned sql but didnt still got how i can use it

#

or apply it

thin raft
#

start with sqlite3

slate swan
#

??

thin raft
#

take a look at it

slate swan
#

ty

thin raft
#

any question ping me

slate swan
twilit grotto
twilit grotto
#

yes but on how big of a scale and whats the purpose of the program

slate swan
twilit grotto
#

oh wait its a discord bot?

slate swan
#

ummm ya

#

?

twilit grotto
#

then i dont see any problem storing it in a json file, depending on how large of a scale you'd be saving though

#

want an example of how to do so?

slate swan
#

ya

#

fs

#

pls

#

json is not a database

twilit grotto
#

well, its easy to store data for a small scale

#

i never claimed it was a database

slate swan
#

it shouldnt be used to store dynamic data

#

only to transfer data

twilit grotto
#

meh, for a discord bot it doesn't really matter lets be frank

slate swan
#

doesnt matter what it is

#

databases are for storing data

slate swan
slate swan
twilit grotto
#

i understand that but for a small scale discord bot, storing data in a json file is not a bad idea. i know plenty of people who do it, and frankly, it results in faster response times when grabbing the information out of the json file instead of a MySQL database for example, could purely be hosting and specifications of the server its hosted on but I'm not sure.

slate swan
#

meaning you will update it once something happens

slate swan
slate swan
slate swan
#

ic

#

in short terms you should not update json file from code

#

oki

#

@slate swan ^

slate swan
thin raft
eager portal
#

how can i get 'voice_client' using interaction: discord.Interaction

eager portal
#

anyone

#

Im using DiscordUtils libary

vocal snow
white citrus
#
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 490, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\Maja-Beta\bot.py", line 241, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 890, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\Maja-Beta\modules\voice\cog.py", line 25, in voice_join
    await inter.user.voice.channel.connect()
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\abc.py", line 1768, in connect
    voice = cls(client, self)
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\voice_client.py", line 212, in __init__
    raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice```
slate swan
white citrus
slate swan
white citrus
#

nextcord

slate swan
#

Then try pip install nextcord[voice]

#

Not sure if it is a thing tho

ember glen
#

I wanna create a music bot which will search through keywords, so anybody has a good idea who can provide me tutorial or something like that?

slate swan
#

can someone give me eample discord_components code?

earnest swift
# slate swan can someone give me eample discord_components code?

here's an example of how to use the discord_components library to create a button in a Discord bot using Python and Discord.py:

import discord
from discord_components import DiscordComponents, Button, ButtonStyle

client = discord.Client()
DiscordComponents(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('!button'):
        btn = Button(style=ButtonStyle.blue, label="Click me!")
        await message.channel.send("Here's a button:", components=[btn])

@client.event
async def on_button_click(interaction):
    if interaction.component.label == "Click me!":
        await interaction.respond(content="Button clicked!")

client.run('your_token_here')

In this example, the on_message() event handler checks if the message starts with !button. If it does, it creates a Button object with the label "Click me!" and a blue style, and sends a message to the channel containing the button using the components parameter.

When the button is clicked, the on_button_click() event handler checks if the label of the clicked button is "Click me!" and responds with a message saying that the button was clicked using the interaction.respond() method.

Note that you need to install the discord-components library using pip in order to use it in your bot:

pip install discord-components

Also, make sure to enable the SERVER MEMBERS INTENT and GUILD MESSAGE REACTIONS intents in your bot's Discord Developer Portal in order to use the discord_components library.

slate swan
#

Also it's outdated

unkempt canyonBOT
#

10. Do not copy and paste answers from ChatGPT or similar AI tools.

slate swan
earnest swift
fierce crag
#

it's alright, just avoid copy+pasting answers from chatgpt next time.

slate swan
#

i have chat gpt too

#

so ik every response i got

mossy bluff
#

Since it's completely different now

#

It often sends outdated info

slate swan
#

!discord buttons

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.

slate swan
#

!discord button bots

#

!discord interaction

#

!list

unkempt canyonBOT
#
List comprehensions

Do you ever find yourself writing something like this?

>>> squares = []
>>> for n in range(5):
...    squares.append(n ** 2)
[0, 1, 4, 9, 16]

Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:

>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]

List comprehensions also get an if clause:

>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]

For more info, see this pythonforbeginners.com post.

slate swan
#

can i have the code? for test

#

!d list

unkempt canyonBOT
#

class list([iterable])```
Lists may be constructed in several ways:

• Using a pair of square brackets to denote the empty list: `[]`

• Using square brackets, separating items with commas: `[a]`, `[a, b, c]`

• Using a list comprehension: `[x for x in iterable]`

• Using the type constructor: `list()` or `list(iterable)`...
slate swan
unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
slate swan
#

can you provide me simple code?

ember glen
#

Why's replit not favoured for 24/7 bot hosting?

white citrus
#

How can i force the bot to mute his in and ouput in a vc

white citrus
#

Selfmute in a vc

upbeat otter
unkempt canyonBOT
#

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

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
upbeat otter
#

set the mute attr to True

white citrus
upbeat otter
white citrus
#

Wrong error sry

upbeat otter
#

Lmao

white citrus
#

Here we go

#
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 490, in _run_event
    await coro(*args, **kwargs)
  File "c:\Discord\Maja Projekt\Maja-Beta\bot.py", line 241, in on_application_command_error
    raise error
  File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 890, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Discord\Maja Projekt\Maja-Beta\modules\voice\cog.py", line 82, in voice_join
    await inter.client.edit(mute=True)
AttributeError: 'Bot' object has no attribute 'edit'
#

@upbeat otter

#

And i want that the bot is deaf

upbeat otter
unkempt canyonBOT
#

property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
upbeat otter
#

Use this

#

inter.guild.me.edit(mute=..., deafen=...)

slate swan
#

!d nextcord.ext.commands.Bot.user

unkempt canyonBOT
slate swan
#

or this

upbeat otter
#

Where did nextcord come from

#

💀

white citrus
#

Read the Error xD

slate swan
#

from here File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py"

upbeat otter
#

Oh

#

Nice

white citrus
# slate swan or this

Mhh Traceback (most recent call last): File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 490, in _run_event await coro(*args, **kwargs) File "c:\Discord\Maja Projekt\Maja-Beta\bot.py", line 241, in on_application_command_error raise error File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 890, in invoke_callback_with_hooks await self(interaction, *args, **kwargs) File "c:\Discord\Maja Projekt\Maja-Beta\modules\voice\cog.py", line 82, in voice_join await self.bot.edit(mute=True, deafen=True) AttributeError: 'Bot' object has no attribute 'edit'

#

Confused

slate swan
#

self.bot.**user.**edit()

white citrus
#

Oh true

#

Not used a long time

white citrus
steady flume
#

how can i can send message and edit other at the same time? (exaclty in view)

await interaction.response.edit_message(view=self)
await interaction.response.send_message(embed=embed, ephemeral=True)

this doesnt work

slate swan
#

i have this code:

import discord
from discord.ext import commands

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

@client.event
async def on_ready():
    print("Bot connected!")

@client.command()
async def ping(ctx):
    await ctx.send("Pong")
    print('\033[37mThe ping command has been ran by {0}\033[0m'.format(ctx.author.id))

client.run("token")

it works fine when ran in vsc but when i run it directly from the folder (as a .py) it just closes the window instantly

slate swan
unkempt canyonBOT
#

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

Edits the original interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.
slate swan
#

alr wait

#

i mean i know i can just do python -i code.py

slate swan
#

by double clicking the python file

#

when i do that it instantly closes

#

also the text isnt grey idfk why it should be

slate swan
#

well i'll fix that another time for now but what do i do about the closing

slate swan
#

maybe you run into errors but that shouldnt happen since you dont get any when running in vs code

#

i would just say to run it using command line

#

yeah i will, probably just gonna make a batch file to do it for me

steady flume
#

AttributeError: 'Interaction' object has no attribute 'edit_original_response'
thats strange actually

steady flume
#

That’s good question 😹

#

1 year ago I downloaded it

slate swan
steady flume
#

2nd version

slate swan
#

or just pip show discord.py

steady flume
#

2.0.0a

#

This one

slate swan
#

update to the newest version current one is 2.2.3 i belive

steady flume
#

Okay bruh

slate swan
#

pip install -U discord.py

#

to update

slate swan
#

personally JavaScript is better in every way possible for making discord bots but for some reason idk how to make a command prompt console print like python has

eager portal
#

how can i fix this: cannot import name Mapping' from 'nextcord.utils'

#
import nextcord, aiosqlite, os, wavelink
slate swan
eager portal
slate swan
#

!pypi wavelink

unkempt canyonBOT
eager portal
#

I literally copied the example and same issue with importing wavelink

slate swan
#

try updating both nextcord and wavelink to latest version then

#

pip install -U nextcord wavelink

eager portal
#

same issue

slate swan
#

so its possibly outdated

eager portal
#

does anyone know the fix

glad cradle
#

!pypi lavalink

unkempt canyonBOT
#

A Lavalink WebSocket & API wrapper built around coverage, reliability and performance.

glad cradle
#

ah no

#

there's mafic for nextcord

eager portal
#

what?

glad cradle
#

!pypi mafic

unkempt canyonBOT
eager portal
#

where can I find node pools to use

slate swan
#

TypeError: Invalid class <class 'discord.message.Attachment'> used as an input type for an Option

#

can anyone help me with this?

slate swan
smoky sinew
#

that's not what i asked

slate swan
#

sorry im new to python

smoky sinew
#

which discord library are you using

slate swan
#

im new to python

slate swan
smoky sinew
#

which python package are you using for your discord bot

slate swan
smoky sinew
#

can you figure out

magic topaz
#

Pex: Is good to tell what you tried to do and what you exactly did and When the error came up. Otherwise not easy for them to help sometime. 😉

slate swan
slate swan
smoky sinew
#

that doesn't help at all

smoky sinew
slate swan
smoky sinew
#

which ones

slate swan
#

can you do pip list and look if you see any of these:

discord.py
nextcord
disnake
py-cord
slate swan
#

so you are using py-cord

slate swan
slate swan
slate swan
slate swan
magic topaz
#

Can show Down the code you wrote maybe?

slate swan
slate swan
magic topaz
#

or send it him in private?!

slate swan
#

this is an error

#

im asking for the code that throws it

#

i dont know thats why im asking in here hoping for help

magic topaz
#

Can't sell a pair of gloves if only offer the left one ^ ^

slate swan
slate swan
slate swan
smoky sinew
#

bruh

slate swan
#

i dont want to reveal

smoky sinew
#

then we can't help

#

lmaoo

tropic ruin
#

i am making discord bots with python which db should i use

slate swan
#

depends if you want sql or nosql

slate swan
smoky sinew
#

nope

#

you can show it here

#

@young peak

smoky sinew
#

his bot was against tos lmao

tacit sentinel
#

Writing to channel.

#
import discord

client = discord.Client()
TOKEN = 'your_bot_token_here'
CHANNEL_ID = 'your_channel_id_here'

def send_to_channel(message):
    channel = client.get_channel(CHANNEL_ID)
    return channel.send(message)

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

client.run(TOKEN)
#

How can I write to a channel without using events?

#

I want to use it like print().

unkempt mauve
vocal snow
#

get_channel -> channel.send

ember glen
#

is there any good tutorial, i can refer to create a music bot which will search using keywords and link both?

sick birch
vale wing
#

His own music database with license obtained for each track obviously

vale wing
ember glen
glad cradle
#

!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)
azure quiver
#

Recently, I switched my bot's library from discord.py to py-cord (a fork of discord.py) and I am finding it to be better so far with less modules being depreciated.

vale wing
azure quiver
# meager chasm Better in what way?

I ran into issues with a few modules being depreciated and having to look for different solutions around it or what not, haven't ran into that so far with py-cord.

vale wing
# meager chasm Better in what way?

For example in disnake you have the following pros

  1. Automatic handling of common stuff, i.e. tree syncing
  2. If in dpy you gotta do interaction.response.send_message and interaction.followup.send, in disnake you have it too + automatic inter.send (and yeah inter name there is conventional)
  3. Disnake has interaction events and errors differentiation, eg. on_button_click, different classes for different interactions, on_slash_command_error, on_message_command_error while dpy doesn't even have event for app commands error handling, it has @tree.error
  4. Universal checks, you don't have to write discord.app_commands.checks.has_role, it's just commands.has_role, just as for prefix commands

However some cons

  1. I don't like disnake modals implementation (I use my own)
  2. No setup_hook, but you can just overwrite start so not a big deal
rugged shadow
topaz pumice
ember glen
#

is there any other way?

vale wing
vale wing
dry kelp
#

Why i can't decode that url?

vale wing
vale wing
dry kelp
#

Yeah, httpcache is blocking it then

vale wing
#

🧐

dry kelp
#

?

knotty mountain
#

I have a bot with some commands and a cog with a couple commands in it as well, would it be better to move all commands to cogs?

golden portal
dry kelp
#

I am having another issue with some API, can't pull out some data from a HTML url

#

This will be sent

vocal snow
#

You have to await the coroutine

dry kelp
#

Doesn't work

vale wing
vale wing
#

And typically for webscraping you would use selenium or beautifulsoup

fossil abyss
#

Hi Everyone, I'm Jasper!
I'm Looking To Start A New Project(Discord Bot) I Already Have Some Bot's Commands If Anyone Wants To Join The Project, Feel Free To Join & Make, If You Want More About Details About The Bot DM Me I'll Be Sharing You A Server Where We Test The Server, We'll Be Using replit.com for the writing code of the bot, at it will be easier, Just A Quick REMINDER NOTE: I'm Not Gonna Be Paying Anyone This Is Just A Fun Discord Bot Project Which Will Be Made And Used By Other Users & Servers, For More Details & Discussion About How It's Gonna Go With Bot, All of Your Questions Can Be Asked In Dm's, If Your A Beginner in discord.py No Problem As While You Develop The Bot You Can Learn More While Coding It, I Would Be Really Hoping Anyone Would Join This Project And Work Together. : D

unkempt canyonBOT
#

6. Do not post unapproved advertising.

lucid kite
#

i'm not sure if it is, but comes off like it

fossil abyss
# lucid kite i'm not sure if it is, but comes off like it

Hi Dude!, It's Not Advertising, I'm Just Asking Others To Join The Project I Noted That I'm Not Paying Anyone So It Dos Not Come In Jobs, And This Is Not Advertising As I Did Not Say Anyone To Use This Or That, This Is Just, "Hiring Other People To Make A Project For Fun Without Payment, No Matter What Stage Of Learning Your In Discord.py".

lucid kite
#

This Is Just, "Hiring Other People"

#

sounds like unpaid work in disguise to me

vale wing
#

Not a big deal imho

abstract relic
#

Should Be Banned For Capitalization In Any Case

vale wing
#

But Why Type Everything From Capital Letter It's Literally Impossible To Read

fossil abyss
vale wing
#

"we'll be using replit to write code" already prevented most of experienced developers from joining your project

#

No offense

abstract relic
vocal snow
#

Pydis should add an lfg channel specifically for those looking for contributors

vale wing
#

Live coding is very inconvenient, trust me, when I was inexperienced and still showing my leadership skills it failed real hard. Git is the way for collaboration and now I am managing bobux bot project with like 6 other developers

#

Ofc learning from own mistakes is more efficient but it's better just to take recommendations into account

still sentinel
fossil abyss
vale wing
#

"Live coding" is the thing you should avoid (for this case)

#

"Version control system" is what you need to learn

knotty mountain
#

Can I have functions other than setup in an extension

fossil abyss
vale wing
fossil abyss
fossil abyss
vale wing
#

Nah thanks as I already mentioned I am project manager of bobux bot

fossil abyss
#

Your Choice, The Bot We're Working On Is'nt Going To Be Big Like bobux bot, It's Just A Simple Bot Not Very Big Something Like Dank Or Bobux.

broken jackal
#

Is there a bot that will play a random yt video from a playlist at a random time?

vocal snow
#

What do you mean by "play" a video

broken jackal
fossil abyss
broken jackal
fossil abyss
#

Zeffo, Can You Join?

#

Your Not A Manager In Any Other Bot Right

#

Please 🥺

vocal snow
fossil abyss
broken jackal
vocal snow
fossil abyss
fossil abyss
broken jackal
#

ah ok thanks anyway, if you know another way to that without bots please share so

vale wing
#

YouTube ToS prohibit streaming of their content on other platforms so there's no other legal way

fossil abyss
#

@vocal snow will u join???

#

Could Anyone Really Just Join The Project? It Will Be A Fun Now, Please?

glad cradle
#

stop continously asking, if someone is interested he'll respond

slate swan
#

Replit is my religion

cloud dawn
#

It's definitely a cult, enclosed and unrecognized lol

rugged shadow
#

oh man I sure do love hosting all of my Discord bots on Replit

#

hopefully nothing goes wrong when my bot gets big

slate swan
#

Also make sure not to use secrets

rugged shadow
#

of course, I love hardcoding my secrets into my 2k+ line main.py

#

and using f-strings to place user input into SQL queries

slate swan
#

Obviously

fossil abyss
slate swan
#

Join?

fossil abyss
#

The Project

fossil abyss
#

It Will Be Really Good If You Join @slate swan

slate swan
#

Look the message above

#

damn sir u found that for me

thts so kind of u

#

btw i forgot the site from where i was learning sqlite3

thin raft
fossil abyss
#

Right Now 2 ppl are there

#

me & @robust fulcrum

fossil abyss
#

Can You Work On It?

slate swan
fossil abyss
#

Like On A Ecnomic Bot???

#

??

slate swan
#

guess i am not worthy currently to work sry for wasting ur time

fossil abyss
slate swan
#

sry

fossil abyss
#

Join, your accepted

thin raft
#

@fossil abyss send the github repo

fossil abyss
#

@slate swan, You Can Join 😄

slate swan
fossil abyss
thin raft
#

I just want to see the code

fossil abyss
slate swan
#

sry for saying crew

#

🙇

fossil abyss
#

either, i'm making this bot with same expierence in bot like u

#

so no problem, @slate swan any more question?

#

@thin raft is this ok? or shall i use paste and send here in discord???

thin raft
#

you should check what classes and cogs are

fossil abyss
slate swan
fossil abyss
slate swan
#

no GitHub?

cloud dawn
#

You leaked your token

slate swan
slate swan
#

oof

thin raft
fossil abyss
fossil abyss
#

github

slate swan
slate swan
cloud dawn
#

@fossil abyss And please look at the date of the tutorial you used to make the current code. This is from 2019 or smth.

slate swan
fossil abyss
slate swan
slate swan
fossil abyss
#

uhmm, in github how do you make a new file in github?

fossil abyss
slate swan
cloud dawn
#

Yeah if you work in a team just use Docker then you are certain everyone has the same environment.

slate swan
#

Then add files and push them to GitHub

slate swan
fossil abyss
#

no problem we can use vscode, if u want let's use it

#

So, @slate swan your joining or not???

slate swan
#

one sec

fossil abyss
slate swan
#

sir lancebot

#

@lament depot

#

sir robin

#

@dim ruin

#

And many other sir s

slate swan
fossil abyss
#

@slate swan Yes Or No???

slate swan
#

ya am in

#

ty

fossil abyss
brisk bobcat
#

Hey, can someone help me with my bot?

thin raft
brisk bobcat
#

So, i just made 'Bridge' bot

You send a message to #channel1
Bot copies the message and send it to #channel2
And i need to add 'Owner WhiteList' - Normal user can't use it, only WhiteListed user can.

#

DM's open.

white citrus
#

How can i force a bot to deaf him his self on a vc join

cloud dawn
unkempt canyonBOT
white citrus
vocal snow
#

!d discord.Member.edit

unkempt canyonBOT
#

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

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
vocal snow
#

deafen

#

you can get the bot's Member object from guild.me

cloud dawn
cloud dawn
vocal snow
cloud dawn
#

If you define a voice client you can just pass the self_deaf.

#
self.voice_client = await inter.user.voice.channel.connect(reconnect=True, timeout=None, self_deaf=True)
plucky sun
#

how to fix error? Traceback (most recent call last): File "C:\Users\KokoG\PycharmProjects\Logger\venv\Lib\site-packages\discord\ui\view.py", line 427, in _scheduled_task await item.callback(interaction) File "C:\Users\KokoG\PycharmProjects\Logger\main.py", line 86, in button_callback await interaction.response.send_message('test') ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Button' object has no attribute 'response' code: class Whitelist(discord.ui.View): # Create a class called MyView that subclasses discord.ui.View @discord.ui.button(label="Whitelist", style=discord.ButtonStyle.primary, emoji="📃") # Create a button with the label "😎 Click me!" with color Blurple async def button_callback(self, button, interaction): await interaction.response.send_message('test')

vocal snow
plucky sun
vocal snow
#

the error says the interaction variable is Button object, which should make that clear

vocal snow
plucky sun
#

thx

#

@vocal snow how to make slash commands ?

vocal snow
#

which library are you using?

plucky sun
#

I didn't understand the question

vocal snow
plucky sun
plucky sun
#

not working @bot.tree.command(name="ping", description="...") async def _ping(interaction: discord.Interaction) -> None: await interaction.response.send_message("pong")

cloud dawn
#

Please keep reading. This tutorial is good.

reef gazelle
#

Which tutorial? The discordpy docs ?

reef gazelle
#

Are people still creating bots with prefix checks or is it better to just purely use slash commands now?

#

Seen with slash commands could be hard to test stuff if using global slash commands cause of the time it takes to register them?

#

Just use guild specific ones for testing as an alternative?

vocal snow
#

and for testing, you should just sync the commands to your testing guild instead of globally

reef gazelle
#

Thanks 🙂

#

Ah see i can just use hybrid commands also

#

So offers prefixed and slash command

white citrus
vocal snow
#

What

reef gazelle
#

I got no clue but i think he’s on about how music bots will join a channel deafened and if you try undeafen them they will just deafen themselves

vocal snow
eager portal
#

I'm using nextcord IPC, I can't seem to find what commands I can use like py await ipcClient.request("get_guild_count") in the get_guid_count

cloud dawn
unkempt canyonBOT
cloud dawn
#

It does.

white citrus
#

Yeah but i need a bot event if a user undeafs the bot

cloud dawn
#

Why?

#

It's a self dead no one could even undeaf it.

cold sonnet
#

prolly wants to be server deafen

cloud dawn
#

True but that would make 0 sense.

cold sonnet
#

it's what most bots did I don't know what's up with them

reef gazelle
#

Oh yeah forgot that

#

I use a music bot and it used to be server deafened

#

But it’s actually self deaf now

cloud dawn
#

Yeah idk why people still server deaf it.

reef gazelle
#

Just do that so much easier and you won’t need the extra code for change

cloud dawn
#

Saves so much trouble

reef gazelle
#

If i’m looking to write a bot will be first one in python done one in JS before tho it was basic, should I Integrate postgres from the start if i want to use it down the line like is it hard to put in at a later date

#

Basically wanna add some fun gambling games into the bot so will need to store UID and a integer for balance

#

But then can obviously build to like per guild prefix and setting log channels

slate swan
#

If you already have plans, why not preparing the database from the start already?

reef gazelle
#

Yeah i will was basically asking if that’s best

#

I’m gonna do the basic commands first though

#

But i’ll just implement the database and prepare it from start

rustic panther
#

is there such a thing of a bot generating random numbers in a number range ?

reef gazelle
#

Like picking a number between 1-1000?

rustic panther
#

similar but like 2,5,19,23,45,31

cold sonnet
#

random.choice(range(10000000))

reef gazelle
#

Can just use pythons random module and use a for loop

cold sonnet
#

either you think a module's gonna reduce the abilities of python or you don't know how to choose a random number in python at all

#

neither of the cases is really good

rustic panther
#

we gonna go with I dont know how to use python at all and the last time i tried learning a programming language was back in the 90's

cold sonnet
#

holy

rustic panther
#

lol

cold sonnet
#

he could be my father

rustic panther
#

yes im old

reef gazelle
#

you can use numpy also i believe

it has: random.randomint(1,100, size=(1,5))

would give you an array of 5 integers