#discord-bots

1 messages Β· Page 678 of 1

small igloo
#

idk, from my POV

sick birch
#

Nah haha

untold token
#

Do I know you ?

small igloo
#

the heck is dat

jade tartan
#

Ok well i wanna create a warn command

slate swan
#

robin

quick gust
#

yep, my vps was giving me the,
Task was destroyed but is pending error and just crashes when I use run_until_complete

sick birch
slate swan
#

i have ran into something

sick birch
#

Yes?

slate swan
#

when using .param, and the command has more then one arg it only sends the first one

sick birch
#

I'll do some testing as I'm on linux atm

slate swan
#

how could i fix?!?!

jade tartan
small igloo
quick gust
sick birch
untold token
#

Mostly I use it with asyncpg

sick birch
#

It is MissingRequiredArgument and not MissingRequiredArguments after all

quick gust
untold token
#

so I create a pool and connect to my postgres database and never really faced any problems

#

and I use linux distro(pop!_os) too

#

So dunno

slate swan
small igloo
#

what the heck is thiss ;-;

sick birch
#

I use arch, maybe your VPS runs ubuntu server or something of the sort?

quick gust
#

yeah ubuntu

sick birch
#

Can only guess it's with that

sick birch
#

Though it does seem like an oversight

#

Perhaps the error is raised multiple times for each missing parameter?

quick gust
#

yep, I found a, what feels like a good, stackoverflow result but I understand none of it

small igloo
#

oh right @sick birch how to edit the database value E

untold token
#

Also I would recommend you to use listeners, like Bot.listen() that bot.event, they are generally better and they external, so you can use multiple listeners of the same event type

untold token
sick birch
slate swan
sick birch
small igloo
untold token
small igloo
untold token
#

I can explain you why it is better

untold token
#

Hold up

small igloo
sick birch
quick gust
#

@slate swan I didn't understand your question, are you trying to show all the args a command takes, in let's say, a help command?

sick birch
#

I suggest you find a quick sql beginner's article to understand it better

supple mortar
small igloo
sick birch
small igloo
sick birch
#
SET column_name = new_value
small igloo
untold token
#

and optional arguments aren't raised

slate swan
#

I don't care about optional I just want required 😒

untold token
#

You want the argument names of the missing arguments?

slate swan
#

yeah

#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, MissingRequiredArgument):
        await ctx.send(embed=discord.Embed(description=f"![warning](https://cdn.discordapp.com/emojis/920156504152240188.webp?size=128 "warning") Error occurred while performing command **{ctx.command.name}**. Please try again with the required argument(s), **{error.param}**", color=color))```
#

I have that but it doesn't raise more then one missing argument

visual island
#

you can't

#

it will only show 1

untold token
#

Yeah it will only show for the argument that is missing,

#

For example

slate swan
#

So I run a command that has 2 required arguments, it will only show the first one that is missing?

untold token
#
async def func(a, b):
   ...

if you didn't pass any values to a, the error will raised that you didn't pass any values to a and b

#

Oh this reminds of something

visual island
#

you can actually do

complete_missing_args = inspect.signature(ctx.command.__callback__)[inspect.signature(ctx.command.__callback__).index(error.param):]

maybe?

upbeat otter
untold token
upbeat otter
#

You use, commands.Cog.listener() in a cog and pass in another argument self

untold token
#

This will eat up all your errors that you are not handling

frigid elm
slate swan
#

how do i make my bot execute on_message commands while ignoring its own messages

#

should i just use an if statement

#

or is there a specific thing i can do

untold token
#

You can use the commands framework

untold token
slate swan
#

perhaps commands was the wrong word to use

#

just on_message to listen to specific words users type

untold token
#
if message.author == bot.user:
    return
slate swan
#

i see thanks, sorry for the confusion

quick gust
# slate swan yeah

you can perhaps send all the required arguments but that will include the one they already gave, if any

obsidian ledge
#

what is the ban permission name in python?

maiden fable
#

!d discord.Permissions.ban_members

unkempt canyonBOT
maiden fable
#

@obsidian ledge

obsidian ledge
#

oh

shadow wraith
maiden fable
#

I got a ghost ping from here

tawdry perch
#

imagine getting random pings

keen talon
maiden fable
tawdry perch
#

indeed

#

how can I overwrite the help command?

shadow wraith
#

overwrite it and make the same class like 3,530,502 times idk

#

oh hey a discord bot is typing but they added a u at the end of their name

slate swan
#
@client.command() 
async def Kosenanat(ctx):
   await ctx.send("kir be ghabret bebare ! ")   

what is problrm

maiden fable
slate swan
shadow wraith
#

wait

tawdry perch
#
class MyNewHelp(commands.MinimalHelpCommand):
    """Bots help command class"""
    async def send_pages(self):
        
        destination = self.get_destination()
        for page in self.paginator.pages:
            emby = disnake.Embed(description=page)
            await destination.send(embed=emby)

bot.help_command = MyNewHelp()
``` so.. I can overwrite it by creating any sort of embed I want?
maiden fable
shadow wraith
#

it's case sensitive, you have to type Kosenanat not kosenanat because case sensitive

#

hunter i will legitimately kill you for stealing my point

slate swan
shadow wraith
#

how can you possibly fetch the id of a channel but use the name to find the channel

maiden fable
shadow wraith
maiden fable
slate swan
#

from persian to english @maiden fable

maiden fable
#

Bro

#

Delete that message 🀦

tawdry perch
#

so.. when I do !help it should send Help, right? but it sends a help embed instead... ```py
class MyNewHelp(commands.MinimalHelpCommand):
"""Bots help command class"""
async def send_pages(self):
desti = await bot.get_channel(self.context)
await desti.send("Help")

tawdry perch
#

why are you sending messages like that....

#
bot = commands.Bot(
    command_prefix=commands.when_mentioned_or('.'), 
    activity=disnake.Game(name="Command !help"), 
    case_insensitive=True,
    intents=intents,
    sync_commands_debug=True)
...#the help command code
bot.help_command = MyNewHelp()
shadow wraith
#

i translated what you said πŸ’€

#

don't translate

tawdry perch
#

I alrd did

quick gust
maiden fable
#

Bruh

quick gust
#

<@&831776746206265384>

tawdry perch
#

<@&831776746206265384> maybe

maiden fable
shadow wraith
#

dynou wtf

maiden fable
#

Tf

tawdry perch
#

lol wtf

quick gust
#

uhh 3 pings

maiden fable
#

Sorry mods ;-;

quick gust
#

RIP lmao, sorry

shadow wraith
#

my guy let's talk about this

tawdry perch
#

I was first, right..?

manic wing
#

nice pings...

manic wing
quick gust
manic wing
#

infernum was

shadow wraith
#

ok let's talk about something else

maiden fable
tawdry perch
#

sorry!

manic wing
shadow wraith
#

guys whenever i do from discord.ext.buttons import blahblahbalbhalbha it always says discord.ext.buttons is undefine

tawdry perch
unkempt canyonBOT
#

discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
manic wing
unkempt canyonBOT
manic wing
#

ohh you meant 2.0

#

lol

maiden fable
shadow wraith
#

ye 2.0

languid jungle
#

!mute 806427658862854174 1h Inappropriate messages. Obscenities in other languages doesn't fly here. Please re-read our #rules and #code-of-conduct .

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1639471595:f> (59 minutes and 59 seconds).

tawdry perch
shadow wraith
#

steak bot awesome

tawdry perch
#

if I do bot.help_command

maiden fable
#

Yea

tawdry perch
#

I did that

quick gust
maiden fable
#

Seems like u have another help class with the same name

tawdry perch
#

hm?

#

I don't

shadow wraith
tawdry perch
#
class MyNewHelp(commands.MinimalHelpCommand):
    """Bots help command class"""
    async def send_pages(self):
        desti = await bot.get_channel(self.context)
        await desti.send("Help")

bot.help_command = MyNewHelp()
``` this is the way I did it, which should be correct
shadow wraith
#

just to inform.

manic wing
#

how tf does he get 1h mute and i get a 2d mute for calling some don an idiot

shadow wraith
#

i think its his first warn

quick gust
shadow wraith
#

anyways we are getting off-topic

#

how can you import discord.ext.buttons without getting an undefined error

tawdry perch
maiden fable
#

Yea

#

It should

arctic python
shadow wraith
tawdry perch
#

hm?

languid jungle
shadow wraith
#

np

languid jungle
tawdry perch
#

oh my god I'm dumb

languid jungle
#

if you have any moderation related question, DM @novel apex

shadow wraith
shadow wraith
tawdry perch
#

that's not the problem atm

#

also yes, that is wrong

shadow wraith
#

ye so fix it 🚎

#

can't you just get the destination with self

tawdry perch
#

what?

shadow wraith
#

self.get_destination()

tawdry perch
#

oh

shadow wraith
#

i fixed 1 problem but that's not the main problem

tawdry perch
#

uuh

#

so.. I have 2 bots, with the same code except the second bot is the development bot...

shadow wraith
#

are they somewhat connected

tawdry perch
#

and I might have used the wrong prefix..

shadow wraith
#

bru

tawdry perch
#

they have same pfp and name

shadow wraith
#

dude

#

aer you crazy how else would you find them are they twins

tawdry perch
#

I have been stuck with this for 2 days because of that

shadow wraith
#

πŸ’€

tawdry perch
#

They are twins, they have 97% the same code

#

uuh

#

why. intensified inner screaming

maiden fable
#

Been more than one month and still no answer ;-;

tawdry perch
#

It took me 2 days to realize that breeeh

maiden fable
#

My bot has already reached 93 servers... Rip

tawdry perch
#

is that bad?

maiden fable
#

?

tawdry perch
#

oh wait, now I remember what it is about

manic wing
#

yeah cus hunters bot needs message intents lol

tawdry perch
#

dang

maiden fable
#

They both are different things

manic wing
maiden fable
#

I won't lose it till April

manic wing
#

well yes i know that but you get the fucking point

maiden fable
#

Yea

manic wing
#
for guild in bot.guilds[75:]:
  await guild.leave()```
#

there ya go

#

your welcome

tawdry perch
#

make it leave a new guilds from now on if it's the case.

maiden fable
tawdry perch
#

okhay

manic wing
#

for now...

maiden fable
tawdry perch
#

I hate my self so much now

maiden fable
#

Me too

boreal ravine
#
async def on_member_join(m):
    await m.ban()β€Š

Rate my anti-raid code

tawdry perch
#

good

shadow wraith
#

50/100

tawdry perch
#

9/10

shadow wraith
#

problem is it bans bots too

tawdry perch
#

that's good

valid barn
#

i have this piece of code, but its not working at all and it doesn't give an error either..? The first part of it works, but when i type verify me it doesn't do anything, but after the timelimit is gone it shows a timeout error

@client.event
async def on_message(message):
  if message.channel.id == 919221774858723398:
    if message.content.lower() == 'latte':
      await message.delete()
      role = message.guild.get_role(920027402749501480)
      await message.author.add_roles(role)
      role = message.guild.get_role(919970184545058897)
      await message.author.remove_roles(role)
      await message.author.send(embed=discord.Embed(description="Type `verify me` to complete verification."))
      def check(m):
        return all([m.author == message.author, m.channel.type == 'private', m.content.lower() == 'verify me'])
      try:
        msg = await client.wait_for('message', check = check, timeout=40)
      except asyncio.TimeoutError:
        return await message.author.send(embed=discord.Embed(description = "Sorry, you took too long to respond!"))
      if msg.content.lower() == 'verify me':
        await msg.author.send(embed=discord.Embed(description = "You're now a verified member."))
      else:
        await msg.author.send(embed=discord.Embed(description = "...That's not it! Try typing `latte` in the verify channel again."))
  await client.process_commands(message)
tawdry perch
#

great... now the pagination works

valid barn
#
if msg.content.lower() == 'verify me':
        await msg.author.send(embed=discord.Embed(description = "You're now a verified member."))
      else:
        await msg.author.send(embed=discord.Embed(description = "...That's not it! Try typing `latte` in the verify channel again."))

this is the part that doesnt work

maiden fable
#

And what is it sending

valid barn
#

just not working but the timeout works

maiden fable
#

Bro I meant what is it sending

valid barn
#

like how?

#

do u mean what the bot is sending in the dms?

maiden fable
#

Yea

valid barn
#

Type verify me to complete verification. or this part py await message.author.send(embed=discord.Embed(description="Type `verify me` to complete verification."))

maiden fable
#

Hmm

shadow wraith
#

how do you get the bot to detect messages without prefix like for example

#
bot: wuts your fav animal
someone: tiger
``` like without prefixes and stuff
sullen shoal
#

idk looks like you want commands.Bot.wait_for

#

or maybe a listener for on_message event idk

#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

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

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

Example...
sullen shoal
#

!d discord.ext.commands.Cog.listener

unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
sullen shoal
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
tawdry perch
#

for some reason it keeps saying it failed, but it still changes the page

slate swan
#

Dude why ping

#

Use @bot.event

valid barn
#

in the image section of an embed is there a way i can add a video?

tawdry perch
#

15min long gif

tawdry perch
#

disnake

upbeat otter
#

code?

tawdry perch
upbeat otter
#

line?

tawdry perch
#

i yeeted it from the repo in pinned messages

upbeat otter
#

uh nvm

tawdry perch
#

Also, there are no tracebacks and I'm debugging it first if I find the error

tawdry perch
#

I don't yet think it's worth to see it here because I stole the code

slate swan
#
    async def play(self, ctx, *, url):
        player = await YTDLSource.from_url(url, loop=self.client.loop, stream=True)
        ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None)
        play1 = discord.Embed(title=">>> MUSIC :musical_note:", description="β–Ί Now playing: {}")
        play1.timestamp = datetime.datetime.utcnow()
        play1.set_footer(text="β˜† Creator LL#0884 β˜†")
        await ctx.reply(embed=play1)
        await ctx.reply('Now playing: {}'.format(player.title))
     
    @play.before_invoke
    async def ensure_voice(self, ctx):
        if ctx.voice_client is None:
            if ctx.author.voice:
                await ctx.author.voice.channel.connect()
            else:
                play2 = discord.Embed(title=">>> MUSIC :musical_note:", description="β–Ί You are not connected  \nto a voice channel.")
                play2.timestamp = datetime.datetime.utcnow()
                play2.set_footer(text="β˜† Creator LL#0884 β˜†")
                await ctx.reply(embed=play2)
                raise commands.CommandError("Author not connected to a voice channel.")
        elif ctx.voice_client.is_playing():
            ctx.voice_client.stop()```
#

why this dont play music

#

but bot join

#

ok

upbeat otter
#

Interesting

#

anyways, I'm bad at music commands, so best of luck

slate swan
#

xd

valid barn
#

how to configure an error for an unknown command?

upbeat otter
upbeat otter
unkempt canyonBOT
#

exception discord.ext.commands.CommandNotFound(message=None, *args)```
Exception raised when a command is attempted to be invoked but no command under that name is found.

This is not raised for invalid subcommands, rather just the initial main command that is attempted to be invoked.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError").
upbeat otter
#
@<client/bot>.event # if you are not in a cog "@commands.Cog.listener()" if you are in a cog (without strings)
async def on_command_error(ctx, exc): #add a self argument as the first argument if you are in a cog
  if isinstance(exc, discord.ext.commands.CommandNotFound):
    pass
#

@valid barn

copper gulch
#

anyone know a way to like edit an embed description only

unkempt canyonBOT
#

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

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

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

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

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

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

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

Edits the message.

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

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

is there someone like
await MYembed.description.edit(description="message2")
like this?

boreal ravine
#

no

copper gulch
#

just the description

visual island
#

embed.description = "my string"

upbeat otter
#

that's what I suggested but well fine

boreal ravine
#

get the message obj, get the embed, edit it ```py
msg = ...
await msg.embeds[0].edit(**kwargs)

slate swan
#

That'll easily error lol

boreal ravine
#

why would it

upbeat otter
slate swan
#

Doesn't exist

#
msg = ...
em = msg.embeds[0]
em.description = ...

await msg.edit(embed=em)
#

you need the edit the message object instead

boreal ravine
upbeat otter
slate swan
upbeat otter
#

I said that on purpose but you guys humor ded so uhhh

slate swan
#

Nor does embed have any async method

boreal ravine
#

o

valid barn
slate swan
#

Forbidden.MissingPermissions why error

boreal ravine
boreal ravine
slate swan
#

-.-

maiden fable
valid barn
maiden fable
#

Just those?

#

Seems like commands is already a Command object

quick gust
#

from discord.ext.commands import command

#

iirc

slate swan
#

they just have a command named commands already

boreal ravine
slate swan
#

^ command function

tough lance
#

So what is the way to pass options in a slash commands as a dict key and getting the value as dict value?

#

Disnake help

crisp haven
#

Hey guys, I tried to make a simple discord bot and I am not sure what the problem is over here. Could someone help me?

#

`import os
import discord
from discord.ext import commands

my_secret = os.environ['TOKEN']

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

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

#purge messages
@bot.command()
@commands.has_permissions(manage_messages = True)
async def purge(ctx, amount = 2):
await ctx.channel.purge(limit = amount)

@bot.command()
async def on_message(message):
if message.author == bot.user:
return

if message.content.startswith("hey guys"):
await message.channel.send("hello there")

if message.content.startswith("bruh"):
await message.channel.send("bruh")
elif message.content.startswith("breh"):
await message.channel.send("breh")
elif message.content.startswith("lol"):
await message.channel.send("lol")

bot.run(my_secret)`

boreal ravine
#

nothing seems wrong

crisp haven
#

I cant seem to run this command

#

@bot.command()
async def on_message(message):
if message.author == bot.user:
return

if message.content.startswith("hey guys"):
await message.channel.send("hello there")

if message.content.startswith("bruh"):
await message.channel.send("bruh")
elif message.content.startswith("breh"):
await message.channel.send("breh")
elif message.content.startswith("lol"):
await message.channel.send("lol")

boreal ravine
#

@crisp haven stop sending your code i already see it

crisp haven
#

sorry, just showing which part doesnt work

boreal ravine
#

change .command() to .event

crisp haven
#

once I do that the purge part doesnt work

boreal ravine
#

use .listen() then

crisp haven
#

ahh finally

#

thanks @boreal ravine

boreal ravine
#

ok

shadow wraith
#

i don't hate on peoples markdown preferences but just saying i recommend using this instead of that

twin moon
#

Why does this

f"'''ini\n[{current_prefix}help]'''"```

print this

```txt
'''ini
[!help]''' ```

' = `
vocal plover
#

' != `

#

if they were the same it would work

small igloo
#

is there any tutorial to use sqlite?

#

hello?

hallow oak
#

Are there any profilers which i can use too monitor the usage of my bot?

small igloo
slate swan
#

yw

small igloo
valid galleon
#

change stuffToPlot

upbeat otter
valid galleon
#

to name

#

btw how can i check if the message starts with the bot prefix?

small igloo
slate swan
#
c.execute(" CREATE TABLE IF NOT EXISTS ? ( unix REAL , ............ ) " , (name))```
valid galleon
#

its for an afk command to make sure the command and event dont override each other

upbeat otter
valid galleon
#

alright i'll try that

slate swan
unkempt canyonBOT
#

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

Retrieves the prefix the bot is listening to with the message as a context.
upbeat otter
valid galleon
slate swan
valid galleon
slate swan
upbeat otter
valid galleon
upbeat otter
#

uhh, ignore my solution then

slate swan
valid galleon
#

ok i'll use message.content.startswith()

slate swan
#

^ yea

small igloo
unkempt canyonBOT
#

saving_data/sqlite3_usage.py lines 77 to 85

'''
    INSERT INTO query is used to add a row in database , FORMAT :

    INSERT INTO <table-name>
    ( attribut1 , attribute2 .......)
    VALUES ( ? , ? ........) ;

    ? gets relaced by the tuple with values following the query ( the values variable here)
'''```
small igloo
valid barn
#

why does it do this ?

small igloo
#

code and error, what's wrong

shadow wraith
#

do f"links that may related to your question {ctx.author}"

shadow wraith
#

why need an author variable

dapper cobalt
shadow wraith
#

i missed the f string πŸ’€

small igloo
small igloo
dapper cobalt
shadow wraith
#

i am a rookie cookie coder

valid barn
upbeat otter
upbeat otter
#

lol

dapper cobalt
maiden fable
#

Fixes most of the issues ngl

dapper cobalt
#

I remember this has something to do with not having {} in your JSON file. Didn't use JSON in a while; so I'm not completely sure.

maiden fable
#

Also tell the error, not only traceback

unkempt canyonBOT
#

When using JSON, you might run into the following error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This error could have appeared because you just created the JSON file and there is nothing in it at the moment.

Whilst having empty data is no problem, the file itself may never be completely empty.

You most likely wanted to structure your JSON as a dictionary. To do this, edit your empty JSON file so that it instead contains {}.

Different data types are also supported. If you wish to read more on these, please refer to this article.

dapper cobalt
valid barn
#

oh it worked, i forgot to add {} in the .json file

#

ty!

upbeat otter
valid barn
#

i-

upbeat otter
#

lol

shadow wraith
upbeat otter
valid barn
maiden fable
valid barn
#

also how do i get the person's icon url ctx.author.icon_url doesnt work

upbeat otter
valid barn
#

(sorry for asking useless questions i get confused easily) ty!

upbeat otter
dapper cobalt
maiden fable
#

Yea, you did it

dapper cobalt
maiden fable
#

I just spam tags

dapper cobalt
maiden fable
dapper cobalt
#

You know that I'm joking.

lament mesa
#

How does the dpy library get all users the bot can see?
does it hit the http endpoint or will the users be dispatched through the ws?

small igloo
#

hmmm
so basically i have a variable named "name", it's to store the uh like the ppl who be pinged (i wanna make a code to see each other's profile use !p @someone) this is the code

async def profile(ctx, user=None):`
  if user == None:
    name = ctx.author.name
  else:
    name = user```
however how to change this "ctx.author" from this code to that "name" variable
`profile.set_thumbnail(url=ctx.author.avatar_url)`
maiden fable
#

Just clearing things out

maiden fable
tawdry perch
#

oop wrong channel

maiden fable
#

And then adds to the cache whenever a new person joins or a new guild is added in bot.guilds

lament mesa
dapper cobalt
#

That would make sense for why large bots take long time to boot up.

lament mesa
visual island
#

see chunk_guild_at_startup

dapper cobalt
humble siren
#

does anyone by any chance know a Voice Receive function or a way to filter user audio's stream in a voice chat?

as in make the bot listen to only 1 person between multiple people.

small igloo
humble siren
#

ive searched quite a few libraries, and I believe someone recommended me nextcord here. nextcord's voice receive isnt ready yet but I was wondering if someone knows one that is

dapper cobalt
#

But then, user will become a discord.Member/discord.User object, and not an str.

lament mesa
tawdry perch
maiden fable
small igloo
brisk helm
#

How to get all message in selected channel wich will start with "$m" and from choose user

upbeat otter
dapper cobalt
unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
tawdry perch
unkempt canyonBOT
#

discord/state.py lines 513 to 515

if self._guild_needs_chunking(guild):
    future = await self.chunk_guild(guild, wait=False)
    states.append((guild, future))```
lament mesa
#

thanks

visual island
#

the main part

tawdry perch
humble siren
upbeat otter
tawdry perch
#

oh

upbeat otter
#

yes

small igloo
#

...... why

tawdry perch
#

hmm where is the disnake version, do you happen to remember

upbeat otter
unkempt canyonBOT
tawdry perch
#

for buttons I mean

#

menus*

vocal plover
tawdry perch
#

ty πŸ˜„

brisk helm
upbeat otter
brisk helm
#

lol

brisk helm
upbeat otter
boreal ravine
visual island
maiden fable
humble siren
#

well how about this, is't possible to have a bot local mute someone?

small igloo
maiden fable
unkempt canyonBOT
#

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

Edits the member’s data.

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

It had a mute kwarg

valid barn
#

how do i set cooldown for a command?

visual island
humble siren
visual island
#

no

#

its vc mute

maiden fable
small igloo
slate swan
humble siren
#

so local mute is possible by a bot?

small igloo
slate swan
#

why not just use a single table tho?

humble siren
#

as in the bot can disable it self hearing from x person, but other people can hear x person?

small igloo
humble siren
#

because ive been looking for this for quite a good week now

maiden fable
#

icy just answered you tho

humble siren
#

i need clarification, theres 2 types of mute, server mute which disables the user from speaking, and local mute, which just mutes the person locally, whilst other people could still hear that person

visual island
slate swan
visual island
maiden fable
humble siren
#

oh thats a cool fact. wb local mute?
i want to make it so the bot could hear people with @role, so i'd just make it local mute anyone that doesnt have @role

valid barn
maiden fable
maiden fable
unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
visual island
humble siren
#

oh shit its fake?

visual island
#

yes

maiden fable
visual island
#

you dont need csv in voice receive

maiden fable
#

Hmmm true tho

visual island
maiden fable
#

Yea

small igloo
# slate swan everyone does , you insert rows in tables for that , not make new table for ever...

ok, now i have this code

def add_user(name):
  conn = sqlite3.connect('database.db')
  c = conn.cursor() 
  c.execute('CREATE TABLE IF NOT EXISTS data (name TEXT, coin INT, level INT, exp INT, max_exp INT, energy INT, rice INT, carrot INT, fish INT, log INT, meal INT)')
  c.execute("INSERT INTO data VALUES(null,0,1,0,125,100,0,0,0,0,0)")
  conn.commit()
  c.close()
  conn.close()

the "null" is for "name" how to do it

maiden fable
#

Wait nvm

#

It wasn't merged. Just closed

visual island
#

tweepy is a twitter scraper lol

maiden fable
#

Lmfaoo

visual island
#

ikr

maiden fable
visual island
#

and also the imports

#

..

small igloo
#

......

humble siren
#

πŸ˜ƒ

slate swan
small igloo
slate swan
#

thats not at all how u use a sql table

maiden fable
maiden fable
small igloo
small igloo
#

A ok thanks

shadow wraith
humble siren
#

i want to make it so that the bot local mutes anyone that doesnt have @role.

shadow wraith
maiden fable
#

What u even mean by Local Mute @humble siren

humble siren
#

can you join Voice Chat 0 for 1 sec

#

so I could screenshot

maiden fable
#

Cz it is (:

junior terrace
#

hey guys

maiden fable
#

That, along with 1603

junior terrace
#
# Moderazione verifica
    verifica_channel_id = 817447845149409300
    
    for message in verifica_channel_id:
        if message.content == 'blender verify':
            pass
    else:
        await message.send("Error eeeheh")```
#

i have made this

#

if a message in a channel is different from "blender verify"

#

the bot has to send you error

#

but it doesnt work

humble siren
#

like this @maiden fable

#

i muted that person in my client, but others can still hear him.

maiden fable
#

U mean volume?

humble siren
#

volume, or the Mute button below it.

placid skiff
humble siren
#

is't possible for a bot to do it? or can it only do "Server Mute"?

junior terrace
placid skiff
#

Send code in PM, i'm ita too

maiden fable
junior terrace
visual island
#

@maiden fable will disnake impl voice receive?

humble siren
maiden fable
visual island
#

I thought you were friends with eq

maiden fable
#

He's hardly active. University stuff

#

πŸ€·β€β™‚οΈ

visual island
#

I see

#

and Danny, "Medical stuff"

maiden fable
#

He ain't busy

valid barn
visual island
#

I would like to know him more though, such as what doctor and stuff

maiden fable
#

Well, sadru and shiftinv are the two main contributors for disnake

maiden fable
shadow wraith
visual island
#

you typed so fast lol

maiden fable
valid barn
#

i-

shadow wraith
maiden fable
maiden fable
shadow wraith
#

first of all we got this voice funny troll pull request blajhblabhalbahblah on github and they imported every type of asyncio

visual island
visual island
#

no one knows really

shadow wraith
#

second of all someone names one of their commands commands

#

πŸ’€

maiden fable
slate swan
maiden fable
maiden fable
valid barn
maiden fable
unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
maiden fable
#

And that's the error haha

visual island
#

oh f dumb me

slate swan
maiden fable
#

It's fine

visual island
#

Ignore what I said really

maiden fable
maiden fable
#

???

visual island
slate swan
#

ow

maiden fable
#

Damn HunAI got famous all of a sudden. 5 servers in a single day 😢

slate swan
#

gg

maiden fable
#

Even when it hardly gained 5 in a week

#

But no response from Discord ;-;

slate swan
visual island
maiden fable
maiden fable
#

I won't complain, since hardly anyone trusts unverified bots πŸ€·β€β™‚οΈ

visual island
#

verified bots arent safe enough though

maiden fable
slate swan
visual island
#

yea fact

tawdry perch
#

Hunter, how many people are in avg on the servers your bot is in?

maiden fable
#

I met this person who said I won't add HunAI to my server cz he thinks it's gonna nuke the server just cz it was unverified, even when it didn't need any admin perms, just send message and embed perms 🀣

tawdry perch
#

lol

humble siren
#

if you local mute someone, other people will still hear him.
if you server mute somoene, no one will hear him.

#

ist possible for the bot to local mute?

maiden fable
visual island
#

return statistics.mean([len(g.members) for g in bot.guilds]) @maiden fable

tawdry perch
#

are there any 1k + member servers?

visual island
#

dpy os maybe

maiden fable
tawdry perch
#

cool

maiden fable
tawdry perch
#

what about disnake server?

maiden fable
tawdry perch
#

oh I see

maiden fable
#

discord.py and disnake server are just dummy sorta servers

#

None uses HunAI in there

tawdry perch
#

facts

slate swan
#

Good morning

visual island
visual island
maiden fable
humble siren
#

lads, do you know a solution?
my eyes are bleeding and ive been looking for over a week πŸ’€

maiden fable
#

Bro

maiden fable
#

Have u tried member.edit?

humble siren
#

say what now

maiden fable
#

!d discord.Member.edit

unkempt canyonBOT
#

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

Edits the member’s data.

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

Have u tried it?

humble siren
#

let me double check because im pretty sure it server mutes.
||@cobalt shoal||

maiden fable
#

Yea it server mutes

#

And if u wanna mute the user only in your client with yr bot, u can't

humble siren
#

yeah ive checked it before.
it only server mutes

maiden fable
#

Czzzz, the bot can't "hear" the person

humble siren
#

πŸ’€

pliant gulch
#

Is there any reason why you must local mute them?

tawdry perch
#

Imagine bot recording voice chat, no thx

humble siren
#

voice receive function isnt really implemented well.

cobalt shoal
pliant gulch
#

Depending on the implementation you may filter packets to only a specific user

cobalt shoal
#

jus listen to their stream πŸ’€

humble siren
cobalt shoal
#

we goto javascript then

humble siren
#

no.

cobalt shoal
tawdry perch
#

Why would you listen to users in VC?

pliant gulch
#

Voice activated commands

humble siren
pliant gulch
#

Β―_(ツ)_/Β―

cobalt shoal
pliant gulch
#

Do keep in mind you'd need to ask for consent to record for all users you are listening onto

cobalt shoal
#

meh, put it in rules

humble siren
visual island
tawdry perch
#

Gotta spam hunAI in there

pliant gulch
cobalt shoal
#

we use it to train AI to replace human relationships make funny voices with

pliant gulch
#

You gotta wait for people who are good to figure it out

#

Currently my collaborator on my dapi wrapper is working on voice recv as well

brisk helm
#
i.content.startswith(r"($m|$ban|b|$mute|$tb|$tempban|w|warn)"):``` why this is not working
small igloo
small igloo
#

is this ok....?

tawdry perch
small igloo
lament mesa
small igloo
small igloo
tawdry perch
#

eh I explained it a bit wrong

lament mesa
tawdry perch
#

there is a module to view .db files?

slate swan
#

i think so

lament mesa
tawdry perch
#

Interesting I always used my editor ext

small igloo
lament mesa
unkempt canyonBOT
#

Source code: Lib/sqlite3/

SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.

The sqlite3 module was written by Gerhard HΓ€ring. It provides a SQL interface compliant with the DB-API 2.0 specification described by PEP 249, and requires SQLite 3.7.15 or newer.

small igloo
#

C?

small igloo
#

lol wut

tawdry perch
#

do you know SQL?

brisk helm
small igloo
tawdry perch
brisk helm
#

there is a lot of the $m .... commands

pliant gulch
#

Your checking if the message content starts with a regex pattern itself,

tawdry perch
#

oh

pliant gulch
#

Your not actually using the regex module to compare a string to the pattern

#

!d re.findall

unkempt canyonBOT
#

re.findall(pattern, string, flags=0)```
Return all non-overlapping matches of *pattern* in *string*, as a list of strings or tuples. The *string* is scanned left-to-right, and matches are returned in the order found. Empty matches are included in the result.

The result depends on the number of capturing groups in the pattern. If there are no groups, return a list of strings matching the whole pattern. If there is exactly one group, return a list of strings matching that group. If multiple groups are present, return a list of tuples of strings matching the groups. Non-capturing groups do not affect the form of the result.
small igloo
#

A

slate swan
slate swan
unkempt canyonBOT
#

Hey @small igloo!

It looks like you tried to attach file type(s) that we do not allow (.db). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

small igloo
#

breh

slate swan
#

ow , you can dm it

lyric tusk
#

how can i fix this
this is my erro message: in on_member_join await member.add_roles(role)
the code py @client.event async def on_member_join(member): role = discord.utils.get(member.guild.roles, id="the id") await member.add_roles(role)

slate swan
#

the id must be a integer

#

*an

lyric tusk
#

ok ty

maiden fable
maiden fable
tawdry perch
#

What's that?

maiden fable
#

Try it out yourself :D

tawdry perch
#

If I remember

boreal ravine
quick gust
slate swan
boreal ravine
#

ah

maiden fable
# quick gust

It makes a new AI Chat Session without setting a channel

stiff nexus
quick gust
#

Yeah, I was just talking abt the response kekw

valid barn
#

i have 2 questions, but here's my code first

@client.command(name='bal', aliases = ('inv','balance'))
async def balance(ctx, user : discord.Member):
  if user == None:
    user = ctx.author
  await register(user)
  with open("bank.json", "r") as f:
    users=json.load(f)

  embed = discord.Embed(color = 0xF5F5DC)
  embed.set_author(name= user.name, icon_url= ctx.author.avatar_url)
  bal = users[str(user.id)]["balance"]
  embed.add_field(name=f"Balance", value = f"{bal} :cherries_:")
  embed.add_field(name="Inventory", value = "> you have no items, purchase them at `m.shop`!")
  await ctx.channel.send(embed=embed)
  1. if i type .bal without any user, it shows a missing argument error, how can i make it that it doesn't do that?
  2. in the embed part, py embed.add_field(name=f"Balance", value = f"{bal} :cherries_:") embed.add_field(name="Inventory", value = "> you have no items, purchase them at `m.shop`!")
    the 2 fields are on the same horizontal line, i want them to be one after the other, how do i do that?
quick gust
#
  1. Add a new kwarg, inline=False
valid barn
sage otter
#

Don’t type hint it to None. Make it’s value None

quick gust
#

so the default value stays None

#

yes

placid skiff
valid barn
#

ok ty!

#

should i remove the discord.Member?

quick gust
#

No

#

Add it after discord.Member

valid barn
#

k

slate swan
#

@valid barn member: discord.Member = None

#

Is there a event for when a channel is moved? I am trying to make something which allows a sort of lock for moderators so if a channel is accidentally moved, the bot fixes it

slate swan
valid barn
#

ok i have another set of questions, here's the code:

@client.command(name="give", aliases = ('send','dash'))
@commands.cooldown(1, 30, commands.cooldowns.BucketType.user)
async def give(ctx, user : discord.Member, amount = 0):
  await register(ctx.author)
  users = await get_bank_data()
  bal = [users[str(ctx.author.id)]["balance"]]
  if amount > bal[0]:
    await ctx.send(embed=discord.Embed(":( poor child. You don't have enough money to give out", color = 0xf5f5dc))
  elif amount <= 0:
    await ctx.send(embed=discord.Embed("Don't be selfish! No negative numbers >:(", color = 0xf5f5dc))
  else:
    await update_bank(user, amount, "balance")
    await update_bank(ctx.author, -1*amount, "balance")
    await ctx.send(embed=discord.Embed(f"Done! {ctx.author.mention} just gave {user.mention} {amount} :cherries_:", color = 0xf5f5dc))

this part doesnt work but it doesn't give any errors, from here:

if amount > bal[0]:
    await ctx.send(embed=discord.Embed(":( poor child. You don't have enough money to give out", color = 0xf5f5dc))
elif amount <= 0:
    await ctx.send(embed=discord.Embed("Don't be selfish! No negative numbers >:(", color = 0xf5f5dc))
else:
    await update_bank(user, amount, "balance")
    await update_bank(ctx.author, -1*amount, "balance")
    await ctx.send(embed=discord.Embed(f"Done! {ctx.author.mention} just gave {user.mention} {amount} :cherries_:", color = 0xf5f5dc))

in my code, update_bank is defined as:

async def update_bank(user, change = 0, mode = "balance"):
  users = await get_bank_data()
  users[str(user.id)][mode]+= change
  await edit()
  bal = users[str(user.id)]["balance"]
  return bal

edit is:

async def edit():
  users = await get_bank_data()
  with open("bank.json","w") as f:
    json.dump(users,f)
slate swan
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

placid skiff
#
    def setup(self):
        for cog in COGS:
            try:
                print(f"    loadin {cog}")
                self.load_extension(f"lib.cogs.{cog}")
            except NoEntryPointError:
                print(f"    failed to load {cog}\nNo setup found")
            except ExtensionFailed:
                print(f"    failed to load {cog}\nThe extension or its setup had an execution error")
            else:
                print(f"    {cog} loaded")

So guys I have this function here where i load the cog from the cog list the only problem is, when one of those exception raise, it don't show me the traceback of the exception in the console. I tried different ways to print it but without success, how can i do it?

valid barn
slate swan
slate swan
#

you do it for each exception

placid skiff
sage otter
#

Honestly just catch ExtensionError it’s raised when any exception related to extensions or cogs are raised.

#
except ExtensionError as e:
    print(e)
brisk helm
#
if i.content.startswith(""):``` how to use regex here
boreal ravine
#

should be something like ```py
regex = ...

data = re.findall(regex, message.content)

visual island
#

re.compile(r"^thestring") should be enough

shadow wraith
#

how can you fetch/get the amount of members there is in a server

#

i mean how can you fetch or get the amt of members in the server the bot is in

lyric tusk
#

this is my proplem: line 45, in on_member_join channel = client.get_channel() TypeError: Client.get_channel() missing 1 required positional argument: 'id' what id do i need to get ?
my code: ```py
@client.event
async def on_member_join(member):
channel = client.get_channel()
role = discord.utils.get(member.guild.roles, int(id=i have id haer))
await member.add_roles(role)

valid barn
lyric tusk
#

oh ok

#

ty

valid barn
#

yw :)

slate swan
#

and yea , what latte told , the parameter must be an int tho

lyric tusk
#

oh ok ty

lyric moat
#

why when i try add Intents it gives an error?

Traceback (most recent call last):
  File "c:\Users\`srtpc\OneDrive\Desktop\jamaicaisthebestlol\zoro.py", line 5, in <module>
    intents = discord.Intents.default()
AttributeError: module 'discord' has no attribute 'Intents'
slate swan
#

seems like you have some other file name discord.py

lyric tusk
valid barn
lyric moat
#

im mad confused

lyric moat
cloud dawn
velvet tinsel
#

Show code

cloud dawn
#

Example:
Show code line 1 to 5
How discord is defined an if it is installed

velvet tinsel
cloud dawn
#

πŸ₯› typing

sinful pasture
#

ok so, I need my bot to send a random joke from the dadjokes library every minute but whatever I try, it either doesn't send a joke, or sends the same joke every time.

@client.event
async def on_message(message):
  if message.content.startswith('Dadjoke!'):
    await message.channel.send(dadjoke)
cloud dawn
sinful pasture
timber crescent
#

is there a good way to implement a check for any command being run?

lyric moat
#
import discord
import os
from discord.ext import commands

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

#prefix center
client = commands.Bot(command_prefix=commands.when_mentioned_or('z'), case_insensitive=True, help_command=None,owner_id= {737448363418452019}, intents= intents)
client.remove_command('help')
sinful pasture
#

you were the one who cursed me with asyncio

lyric moat
#

thats the code

timber crescent
#

like the check in bot.wait_for

unkempt canyonBOT
#
No way, JosΓ©.

No documentation found for the requested symbol.

sinful pasture
valid barn
cloud dawn
sinful pasture
#
import dadjokes
from dadjokes import Dadjoke

dadjoke = Dadjokes()
lyric tusk
timber crescent
cloud dawn
lyric moat
cloud dawn
timber crescent
#

like check if the user id for the person running the command is say in a specific database and on that basis return a different output

valid barn
sinful pasture
cloud dawn
#

!d discord.Intents

unkempt canyonBOT
#

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

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

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

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

New in version 1.5...
lyric moat
cloud dawn
#

Inherit is discord.ext.commands.Bot.intents

sinful pasture
cloud dawn
lyric moat
#
Traceback (most recent call last):
  File "c:\Users\srtpc\OneDrive\Desktop\jamaicaisthebestlol\zoro.py", line 5, in <module>
    from discord import intents
ImportError: cannot import name 'intents' from 'discord' (unknown location)```
visual island
#

capital i

timber crescent
#

caps perhaps

cloud dawn
lyric moat
#

BRO it still shows error ong

timber crescent
#

could you show me an example of how i could set this up? like say if user id belongs in a pre defined tuple

cloud dawn
lyric moat
#
Traceback (most recent call last):
  File "c:\Users\srtpc\OneDrive\Desktop\jamaicaisthebestlol\zoro.py", line 5, in <module>
    from discord import Intents
ImportError: cannot import name 'Intents' from 'discord' (unknown location)```
timber crescent
#

does it continue with the command after this?

#

whatever is inside the on_command

cloud dawn
lyric moat
cloud dawn
cloud dawn
slate swan
#
@bot.command()
async def buttton(ctx):
  await ctx.send(
    'This is a button',
    components = [
      Button(label= 'Click Me!')
    ]
  )
  interaction = await bot.wait_for("button_click", check=lambda i: i.component.label.startswith('Click'))
  await interaction.respond(content="Button Clicked!")
cloud dawn
#

Just same joke over and over?

sinful pasture
sinful pasture
timber crescent
cloud dawn
lyric moat
#
Traceback (most recent call last):
  File "c:\Users\srtpc\OneDrive\Desktop\jamaicaisthebestlol\zoro.py", line 5, in <module>
    from discord import Intents
ImportError: cannot import name 'Intents' from 'discord' (unknown location)```

it still showing this
cloud dawn
#

print(dir(discord))

upbeat otter
lyric moat
sage otter
#

I honestly don’t know why people still use DiscordComponents

timber crescent
sage otter
#

It was cool around 1.7 dpy but it’s just useless now.

cloud dawn
oak warren
#

how to solve opus not loaded py Task exception was never retrieved future: <Task finished name='Task-55' coro=<MusicPlayer.player_loop() done, defined at Music.py:158> exception=OpusNotLoaded()> Traceback (most recent call last): File "Music.py", line 185, in player_loop self._guild.voice_client.play(source, after=lambda _: self.bot.loop.call_soon_threadsafe(self.next.set)) File "discord\voice_client.py", line 609, in play self.encoder = opus.Encoder() File "discord\opus.py", line 360, in __init__ _OpusStruct.get_opus_version() File "discord\opus.py", line 353, in get_opus_version raise OpusNotLoaded() discord.opus.OpusNotLoaded traceback

cloud dawn
upbeat otter
cloud dawn
lyric moat
oak warren
oak warren
cloud dawn
valid barn
#
  {"name":"blue","price":500,"description":"color role blue"},{"name":"red","price":500,"description":"color role red"},{"name":"yellow","price":500,"description":"color role yellow"},
]```
```py
@client.command(name='shop')
async def shop(ctx):
  embed = discord.Embed(description = "Here are the items available in the shop.", color = 0xF5F5DC)
  for item in shop:
    name= item["name"]
    price= item["price"]
    desc= item["description"]
    embed.add_field(name = f"{name} ・ {price} :cherries_:", value=f"{desc}", inline = False)
  embed.add_field(value = "Not sure how to earn :cherries_:? run `m.help`", inline = False)
  await ctx.send(embed=embed)```
sinful pasture
#

@cloud dawn sooo, is there a way I can fix my bot?

lyric moat
cloud dawn
upbeat otter
cloud dawn
lyric moat
#

so say pip install discord?

upbeat otter
cloud dawn
# oak warren ok np

Thanks for understanding, if a moderator approves we will of course help you.

shadow wraith
upbeat otter
slate swan
# upbeat otter Your code please
from discord_components import DiscordComponents, Button, ButtonStyle, component
bot = commands.Bot(command_prefix="!")
DiscordComponents(bot)


@bot.command()
async def button(ctx):
  await ctx.send(
    'This is a button',
    components = [
      Button(label= 'Click Me!')
    ]
  )
  interaction = await bot.wait_for("button_click", check=lambda i: i.component.label.startswith('Click'))
  await interaction.respond(content="Button Clicked!")
shadow wraith
#

name is shop

#

which is basically meaning, it's a shop

cloud dawn
shadow wraith
#

πŸ’€

lyric tusk
slate swan
cloud dawn
upbeat otter
# slate swan

I see, try printing something after every line, and see where the text stops printing

sinful pasture
upbeat otter
sinful pasture
lyric tusk
sinful pasture
upbeat otter
#

@sinful pasture wait, you imported Dadjoke, and use the class Dadjokes

cloud dawn
sinful pasture
upbeat otter
#

Hmm, what error tho?

sinful pasture
sinful pasture
cloud dawn
slate swan
upbeat otter
unkempt canyonBOT
#

dadjokes/dadjokes.py line 25

r = cached_request(self.url).json()```
valid barn
cloud dawn
#

Pypi also isn't async...

lyric tusk
upbeat otter
upbeat otter
cloud dawn
upbeat otter
slate swan
cloud dawn
sinful pasture
upbeat otter
upbeat otter
valid barn
# lyric tusk No

well try using this instead (it usually works for me), as in:

role = member.guild.get_role(your_id)
await member.add_roles(role)

(the id should be an integer)

small igloo
#

announcement: i finnaly quit replit πŸ˜„ it sucks

cloud dawn
#

I'll cheer to that any day 🍻

upbeat otter
lyric moat
#

how can i add Intents to my bot cause i had one and its confusing

sage otter
lyric moat
#

i use to use it on replit and it works now im on vsc and it does not work

cloud dawn
#

I even gave you an example.

lyric moat
#

i do not know what is that

slate swan
fading harness
#

hi, how could i know that if a member has a role by id in a different server?
(the bot in the server which has role uwu)

slate swan
#

hey guys does anyone know how i can make a channel counter for my discord bot?

lyric moat
#

what is "dir discord"

slate swan
# upbeat otter if interaction.user.id == ctx.author.id: await interaction.send

like this

@bot.command()
async def buttton(ctx):
  await ctx.send(
    'This is a button',
    components = [
      Button(label= 'Click Me!')
    ]
  )
  print('part one')
  interaction = await bot.wait_for("button_click", check=lambda i: i.component.label.startswith('Click'))
  if interaction.user.id == ctx.author.id:
    await interaction.send(content="Button Clicked")

?

cloud dawn
lyric moat
#

i did not go sm stuffs when i use it on replit

cloud dawn
lyric moat
#

should i put it in the code?

cloud dawn
cloud dawn
cloud dawn
sage otter
slate swan
sage otter
#

Grab the server then ig

lyric tusk
sage otter
#

And grab his member object in server

small igloo
#

tysm @cloud dawn, @upbeat otter and @sage otter sorry late, lag

slate swan
#

Bro the syntax in list comprehensions makes me wanna learn jsyert

valid barn
cloud dawn
lyric moat
cloud dawn
lyric tusk
# valid barn wdym?

The Erro role = member.guild.get_role(317730229760163855) ^ IndentationError: expected an indented block after function definition on line 44

slate swan
cloud dawn
slate swan
lyric tusk
lyric moat
valid barn
lyric tusk