#discord-bots

1 messages Β· Page 1065 of 1

maiden fable
#

{} means all documents

elfin island
#

ye

#

but update_one

abstract kindle
#

update one means not all of them

maiden fable
#

πŸ˜” I think I will just clear everything and then send the info to the db again, since this will kill all my braincells

elfin island
#

i'd recommend you restructure your data

abstract kindle
#

I wouldn't do that. updating is the best way to do it

maiden fable
#

And what should be the updated struct?

elfin island
#

mongo's lack of structure lets you start stuff like this, and then it'll get frustrating

abstract kindle
#

Just have different columns for each piece of info you would need for each user

elfin island
#

doing this lets you filter for a specific user's data, which wouldn't be possible if the key itself is the user ID

maiden fable
#

Ah, so u mean a separate table for each user?

abstract kindle
#

no

elfin island
#

a separate document

abstract kindle
#

Just separate rows for each user

maiden fable
#

(I am still new to Mongo's terminology)

#

Hm lemme see

abstract kindle
#

and each user would have multiple columns to store their data

elfin island
#

rows and tables are SQL lingo

maiden fable
#

Ah

maiden fable
elfin island
#

(and columns)

maiden fable
#

Oh

elfin island
#

the mongo analogue to an SQL table would be a collection

abstract kindle
maiden fable
#

Wait did u set the _id by yourself?

abstract kindle
#

This is one of my documents for example, just has an id and then all of the info

elfin island
#

and each collection would contain many documents (rows)

abstract kindle
#

I did that so I could match their ID's with their discord ID's

#

But that is not something you have to do, you can keep it default

elfin island
maiden fable
#

I thought Mongo set the _id itself lol
That will make stuff easy tho, no? If I set the ID to user id

elfin island
#

yes, that's what i suggested

maiden fable
#

Ah missed that, yea

#

So how to send custom _id then

elfin island
#

just pass an _id field when you're inserting the data

maiden fable
#

Gotcha

elfin island
#

insert_one({"_id": user.id})

maiden fable
#

Thanks

elfin island
#

oh also, i'd suggest trying out prisma-client-py, it's a fully type-safe ORM with support for mongo as well

maiden fable
#

Oh thanks!

heavy shard
#

guys do you know any resources on what to pay attention for if you want your bot to grow big (many guilds)?
like command cooldown etc

green bluff
#

Unique command choice

maiden fable
heavy shard
#

i mean like limit 50 websocket commands per second

#

that's 1 message per second for 50 guilds

maiden fable
heavy shard
#

none

#

i mean bot communicates through websocket. channel.send() is 1 websocket command

maiden fable
#

Ah

#

.send is a HTTP method, not a ws

heavy shard
#

really?

maiden fable
#

Yes

heavy shard
#

ok i know nothing πŸ™‚

maiden fable
#

Its fine haha

heavy shard
#

so d.py is just a translator layer for GET / POST API calls?

slate swan
slate swan
maiden fable
#

Its just an easier interface between yr code and an API, the Discord API, in this case

#

@slate swan do u know of any dunder which is called whenever I do dict(classA) or smth?

slate swan
#

not that im aware of, lemme see

maiden fable
#

Thanks

slate swan
#

!e ```py
class MyClass:
def iter(self):
return iter([("key","value")])

print(dict(MyClass()))

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

{'key': 'value'}
slate swan
#

there may be more dunders~

maiden fable
#

Its fine I got it to work

#

Thanks!

#

Lol its a read only attr

unkempt canyonBOT
#

A dictionary or other mapping object used to store an object’s (writable) attributes.

warped mirage
#

Il need some help probs tommorrow or so or later on today

maiden fable
#

Hey @abstract kindle sorry for the ping but this code doesn't seem to work:

async def update_db():
    ai_session = ai
    session = ai_session.db
    users = ai_session.get_all_info()
    num = 0
    for user in users:
        num += 1
        my_user = AIUser({"_id": "1", "name": "Hun", "iter": str(num)})
        await session.update_one({"_id": str(user)}, {"$set": dict([*my_user])})
#

Wait nvm seems like my code issue

keen talon
#

Wdym lol

sullen pewter
#

How to send a message.content without the first letter?

#

If someone said NBob

#

Bot would respond with Bob

vocal snow
#

Oh nevermind it's an update

sullen pewter
#

What's wrong with this code?

#

It's not sending errors and not sending the message on join

class MyClient(discord.Client):
    async def on_ready(self):
        print("Bot running with:")
        print("Username: ", client.user.name)
        print("User ID: ", client.user.id)
        print('-----')
    
    async def on_message(self, message, interaction):
        # To prevent the bot replying to itself
        if message.author.id == self.user.id:
            return

        if message.content.startswith('N') and discord.ChannelType.private:
            await self.interaction.response.send_message(f'Nickname set to{message.content[1]}')

    async def on_member_join(self, member):
        view = Introduction()
        await self.member.send(f'Welcome to the server {member.mention}! Use the button below to make an introduction and get access to the server.', view=view)
warped mirage
#
@commands.guild_only()``` guys what does this mean?
sullen pewter
#

maybe commands that are only useable inside a guild(can't use them in private chat/direct messages)

warped mirage
#

rip

#

!d client

sullen pewter
#

bruh

warped mirage
#

idc ima just use @commands.command()

maiden fable
#

!d discord.ext.commands.guild_only

unkempt canyonBOT
#

@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a
guild context only. Basically, no private messages are allowed when
using the command.

This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage")
that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
sullen pewter
#

@warped mirage

warped mirage
maiden fable
#

It will work only in guilds

warped mirage
#

Like is it possible .

maiden fable
#

Yea

manic path
#

Does archive fall under on_thread_update?

placid skiff
#

ban is a method of Guild object, not member

#

!d discord.Guild.ban

unkempt canyonBOT
#

await ban(user, *, reason=None, delete_message_days=1)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Bans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to
do this.
maiden fable
unkempt canyonBOT
#

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

Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.ban "discord.Guild.ban").
placid skiff
#

Sorry, User*

#

hahaha

sullen pewter
#

np

heavy shard
#

won't discord.error.Forbidden be raised when bot not user has no ban permission?

sullen pewter
#

lol why are you sorry

#

How to send message content [1, +∞]

heavy shard
sullen pewter
#

Ty

heavy shard
sullen pewter
#

Yea ik

heavy shard
#

discord.ChannelType.private will always be true

sullen pewter
#

I forgot

sullen pewter
sullen pewter
heavy shard
#

you want message.channel.type == discord.ChannelType.private

sullen pewter
#

ok ty

placid skiff
#

Forbidden inherits from HTTPException, MissingPermission inherits from CheckFailure, which inherits from CommandError which inherits from DiscordException

sullen pewter
#
    async def on_message(self, message):
        # To prevent the bot replying to itself
        channel = message.channel
        if message.author.id == self.user.id:
            return

        if message.content.startswith('N') and message.channel.type == discord.ChannelType.private:
            await channel.send(f'Nickname set to **{message.content[1:]}**')
            await message.author.edit(nick=message.content[1:])
#

How can I set user nickname to message content

placid skiff
#

You will need a Member object to use edit()

warped mirage
#

`βœ…

regal pulsar
sullen pewter
#

ic

regal pulsar
#

!d disnake.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timeout=..., 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...
regal pulsar
#

since members are specific to guilds

warped mirage
#

\β›”

regal pulsar
#

user is just any discord user

placid skiff
#

wdym?

regal pulsar
#

hmm

warped mirage
#
    @commands.guild_only()
    async def giveaway(self, ctx):
        await ctx.send("Lets Start this giveaway, answer the questions I ask and we can proceed.")

        questionList =[
            ["What channel should it be in?", "Mention the channel"],
            ["How long should this giveaway last?", "d|h|m|s"],
            ["What are you giving away?", "E.G. Pizza"]
        ]
        answers = {}

        for i, question in enumerate(questionList):
            answer = await GetMessage(self.client, ctx, question[0], question[1])

            if not answer:
               await ctx.send("You failed to answer, please answer quicker next time!")
               return

            answers[1] = answer

        embed = discord.Embed(name="Giveaway Content")
        for key, value in answers.time():
            embed.add_field(name=f"Question: `{questionList[key][0]}`", value=f"Answer: `{value}`", inline=False) 

        m = await ctx.send("Are all these valid?", embed=embed)
        await m.add_reaction("βœ…")
        await m.add_reaction("β›”")  ``` GetMessage is not defined , how do i fix
regal pulsar
#

!d disnake.ext.commands.Bot.guilds

unkempt canyonBOT
sullen pewter
regal pulsar
#

just use discord instead

#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., 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...
heavy shard
#

that's a bad idea

sullen pewter
placid skiff
#

this is a little advanced

heavy shard
#

"how do i break into houses of people that bought my tv?"

sullen pewter
placid skiff
#

since there isn't a method to find the guild invite from a guild, you can only get all active invites from a guild

regal pulsar
sullen pewter
#

ok

heavy shard
#

say i have a private server and i use your bot, suddenly owner appears on my server

regal pulsar
#

hmm wait

maiden fable
#

Okay so I forgot, but the tasks.loop's first iteration is done as soon as the bot starts or after the time I specified in the deco?

regal pulsar
#

!d disnake.Guild

unkempt canyonBOT
#

class disnake.Guild```
Represents a Discord guild.

This is referred to as a β€œserver” in the official Discord UI...
maiden fable
#

Rip

placid skiff
#

i don't remember the workaround to fix this sadly

maiden fable
#

Oof

placid skiff
#

wait i remembered that i've sold a bot which does something with tasks

maiden fable
#

Ouh

heavy shard
placid skiff
heavy shard
#

you use @task_name.before_loop decorator

maiden fable
placid skiff
#
class MainLoop(Cog):
    def __init__(self, bot):
        self.bot = bot
        self.check_news.start()
        self.first_launch = 0

    @loop(minutes=40)
    async def check_news(self):
        if self.first_launch == 0:
            self.first_launch += 1
            return
        #your stuff
maiden fable
#

What the

sullen pewter
heavy shard
#

so just:

@task_name.before_loop
async def wait_some_time(self):
    asyncio.sleep(60 * 10)
placid skiff
maiden fable
#

hm good idea

sullen pewter
slate swan
maiden fable
#

i wish there was smth like before_first_iter lol

glad coral
#

When I try and use the command, it doesn't respond back

import discord
from discord.ext import commands

intents = discord.Intents()
intents.guilds = True
intents.guild_messages = True
intents.message_content = True

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

@bot.command()
async def pdc(ctx):
    await ctx.reply('is awesome', mention_author=True)

bot.run('REMOVED')
maiden fable
#

Wait, what if I start the task after 10 min

glad coral
#

I tried that too

regal pulsar
slate swan
maiden fable
maiden fable
#

oh wait nvm

#

Yea u right sorry

placid skiff
maiden fable
#

No

regal pulsar
#
@bot.command()
async def nickname(ctx: commands.Context, *, nick: str):
    await ctx.author.edit(nick = nick)
    await ctx.channel.send(f”{ctx.author.mention}’s nickname set to {nick}”)
#

or something

#

im on mobile so i may have made a mistake

slate swan
#

it never says restart

maiden fable
#

Yea I just remembered u r correct

placid skiff
#

||Fuck this shit ||

slate swan
#

eh

livid hinge
#

try the discord version maybe

placid skiff
#

!d discord.ext.tasks.Loop.before_loop

unkempt canyonBOT
#

@before_loop```
A decorator that registers a coroutine to be called before the loop starts running.

This is useful if you want to wait for some bot state before the loop starts,
such as [`discord.Client.wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready").

The coroutine must take no arguments (except `self` in a class context)...
slate swan
#

...

maiden fable
#

Greyblue...

#

Go touch some grass, u r using VSC since 17 hours

placid skiff
#

so as i said, the coroutine is called before the loop starts

#

so if you wait 10 minutes in the before, then the loop starts and waits another 10 minutes

livid hinge
#

no its just sitting on my pc

slate swan
placid skiff
#

lol

placid skiff
#

I do it too sometimes D_D

regal pulsar
maiden fable
placid skiff
#

Like i use pycharm for work but i'd open it but never close it

slate swan
placid skiff
#

Why a loop could not start after the time lol

maiden fable
#

Lmao no one likes to disable their presence and show off that they are working since hours @slate swan

maiden fable
#

And, well I prefer to turn off my laptop so that no one edits my code

placid skiff
slate swan
placid skiff
#

We are your friends cryapetta

#

Better, we are your family cryapetta

slate swan
#

lol I was kidding

maiden fable
#

Lmao no one really cares if I am working on VSC or smth

slate swan
maiden fable
#

lmao

placid skiff
#
class Life:
  def __init__(self, people: 'People'):
    self.people = people

  def switch(self, with_: 'People'):
    tmp: 'People' = with_
    with_ = self
    self = tmp

class People:
  def __init__(self, name):
    self.name = name

Ash = People("Ashley")
Hunt = People("Hunter")
AshLife = Life(Ash)
HuntLife = Life(Hunt)
AshLife.switch(HuntLife)

smth like this, let's develop it

heavy shard
#

self, with_ = with_, self

#

err

placid skiff
#

Lol that's something i've done in C

#

The universe is trying to tell me something

heavy shard
#

get_human(name="BlvckTvrsier").feed(food.Pizza)

placid skiff
#

Are you accusing me of being italian? because yes, I am D_D

heavy shard
#

italian language is cool πŸ˜› but i failed to learn it to the conversational level

placid skiff
#

Bruh listen an Iitalian, italian is not cool lmao

regal pulsar
#

lol

placid skiff
#

also only few italians speak it correctly

#

Bruh why Chrome icon has a box on my desktop D_D

slate swan
#
class uwuClient(Client):
    def __init__(self):
        self.boot_time = round(datetime.utcnow().timestamp())

client = uwuClient()

@tasks.loop(seconds=10)
async def uwu_loop():
    print(round(datetime.utcnow().timestamp()) - client.boot_time)

@uwu_loop.before_loop
async def _():
    await sleep(10)

@placid skiff this is why it only waits before the first iter

heavy shard
#

is sleep from time or asyncio?

#

wait, it's awaited so it's asyncio

slate swan
#

yeah

#

ofc im not using time

#

blocking

heavy shard
#

sorry for even thinking about it :>

slate swan
placid skiff
slate swan
#

no comments

placid skiff
#

Who wants to create a fork to subclass Loop class and make a method that waits the time before execute the function? KillMeLmao

slate swan
#

a fork for just task manipulation?

#

better create a separate api wrapper

#
wait = True

@loop(...)
async def foo():
   if wait:
      await sleep(10)
      wait = False
    # stuff
``` L
#

i forgot to global it^

#

bye

placid skiff
#

lol

slate swan
placid skiff
#

Bruh literally here we are doing a job

slate swan
#

no

#

we tend to confuse a small amount of people by coming up with all sorts of problems they have with their code rather than helping with what they came for, which frustrates other people and they lose interest, and subsequently ask their questions in the discord.py server. Period.

stone beacon
glad coral
#

Why doesn't my bot reply when I run the "$test" command?

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix='$', intents=discord.Intents.default())

@bot.event
async def on_ready():
    print('Successfully logged into {0.user}'.format(bot))

@bot.command()
async def test(ctx):
    await ctx.send('hello')

bot.run(TOKEN)
#

Bot has administrator perms in server

light violet
#

how do i change guild vanity code

slate swan
glad coral
placid skiff
light violet
placid skiff
#

Because there isn't a method to do it D_D

light violet
#

duh if one could do it with api caller why not with dsicord py

placid skiff
#

They would've their reasons, btw if you want you will need to do it by APIs too

placid skiff
#

yup it gets the url code, but you can't edit it

#

it returns a string, it is not even a discord object

#

!d discord.Guild.vanity_invite

unkempt canyonBOT
#

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

Returns the guild’s special vanity invite.

The guild must have `VANITY_URL` in [`features`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.features "discord.Guild.features").

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to use
this as well.
placid skiff
#

this returns an Invite object

light violet
#

.....

placid skiff
#

try to change it with what this methods will return

light violet
#

i just want the vanity code from it

#

how to derive it

#

vanity_invite.code()?

#

vanity_url_code?

placid skiff
#

but it is an attribute, and it will just get you the vanity code

visual island
slate swan
light violet
#

,.

slate swan
placid skiff
#

It is something that you will get when your guild reaches the max level of boosting

slate swan
#

and just fyi, even the discord api restricts the editing of vanity urls

placid skiff
#

then you can have a personal invite link like discord.gg/myserver

slate swan
#

thanks though

#

and the discord api only allows the getting of the url

placid skiff
#

the string after the / is the vanity code LMAO

#

it seems that you can edit it

slate swan
#

referring to that as the code right?

placid skiff
#

Yup

slate swan
#

pfftt

placid skiff
#

btw it has some limitations

#

like the person who access the guild through that link will be redirect to the first visible channel in list for his role

mortal thistle
#

hey

#

I can't do this thing

#

says tasks isn't defined

placid skiff
#

Your imports?

mortal thistle
#

from discord.ext import commands
import aiohttp
import asyncio

placid skiff
#

loop is located in discord.ext.tasks.loop

robust fulcrum
placid skiff
#

you will need git

slate swan
#

^, pip install git+link

robust fulcrum
#

Ok

placid skiff
#

pip install git+https://github.com/Rapptz/discord.py

slate swan
#

Why does my python bot keeps sending messages when I sent message that isn't even contains in message.content.lower?

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

    if 'hello' in message.content.lower():
        await message.channel.send(random.choice(greetings))
        time.sleep(1)
        await message.channel.send(random.choice(cq))

mortal thistle
mortal thistle
#

how do I update server count on top.gg?

maiden fable
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\prefix.py", line 20, in change_prefix
    db.execute("UPDATE guilds SET Prefix = ? WHERE GuildID = ?",
AttributeError: module 'db.db' has no attribute 'execute'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\events.py", line 61, in on_command_error
    raise error
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'db.db' has no attribute 'execute'```
slate swan
visual island
regal pulsar
regal pulsar
#
#chat bot
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    elif 'hello' in message.content.lower():
        await message.channel.send(random.choice(greetings))
        time.sleep(1)
        await message.channel.send(random.choice(cq))

slate swan
#

why use elif?

regal pulsar
#

because you only want the trigger to work if the first statement is false

#

elif runs if the previous if/elif statement evals to false

#

if both are ifs then its gonna run either way

slate swan
#

no, nvm i fixed it in another way

#

conclusion, dont use an elif tree.

regal pulsar
#

^

slate swan
#

"if" works, no need "elif"

slate swan
slate swan
regal pulsar
#

its just that the bot replies to itself

slate swan
#

!e

from asyncio import get_event_loop
em = True
async def main():
  if not em:
    return
  elif em:
    print("uwu")

get_event_loop().run_until_complete(main())

like its gonna work ofc

regal pulsar
#

lmao

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | <string>:9: DeprecationWarning: There is no current event loop
002 | uwu
regal pulsar
#

hmm

slate swan
#

im wondering why....i never ran it using run

#

oof

regal pulsar
#

!e
name = 10
if name > 9:
print(1)
elif name > 8:
print(2)

unkempt canyonBOT
#

@regal pulsar :white_check_mark: Your eval job has completed with return code 0.

1
regal pulsar
#

its not going it print 2

#

since the first if already evaled to true

#

on the other hand

#

!e
name = 10
if name > 9:
print(1)
if name > 8:
print(2)

unkempt canyonBOT
#

@regal pulsar :white_check_mark: Your eval job has completed with return code 0.

001 | 1
002 | 2
regal pulsar
#

yeah he didnt have elif before

visual island
regal pulsar
#

hmm

#

oh oops

#

!e
name = 10
def main(name):
if name > 9:
return
elif name > 8:
print(2)
main(name)

unkempt canyonBOT
#

@regal pulsar :warning: Your eval job has completed with return code 0.

[No output]
regal pulsar
#

i see

#

weird

azure depot
#

how do i fix this

misty stream
#

hi im having a issue i have this piece of code

response = requests.get(f"https://valorant-api.com/v1/agents")
        json_data = json.loads(response.text)
        print(json_data)

this returns all agents but if i just want sova how would i do this ?

misty stream
#

i did that but i couldnt find it

slate swan
#

this will return the data for sova

placid skiff
#

You are so kind Ash you searched through the docs for him

misty stream
slate swan
slate swan
misty stream
#

oh okey thanks for helping !

slate swan
misty stream
#

i would never have come up with a dictionairy method

slate swan
#

dont want to imagine the conditional tree

placid skiff
slate swan
#

nvm

placid skiff
#

lol

#

I will act like i did not see anything

slate swan
#

thanks

loud junco
#

πŸ˜‚πŸ˜‚πŸ˜‚

slate swan
loud junco
#

Saw what

#

I din

#

Show me

placid skiff
loud junco
#

uwu

#

@slate swan

#

Show me

slate swan
#

uh?

loud junco
#

:D

slate swan
#

...show what? dont be so happy

loud junco
#

Huh

#

Whats that about

slate swan
loud junco
#

:/

placid skiff
#

Oh don't worry is nothing to be worried about

manic path
#

Does thread.owner_id refer to the person who created the thread or the owner of the server?

placid skiff
#

the owner of the thread D_D

loud junco
#

Misunderstood πŸ˜‚πŸ˜‚πŸ˜‚

loud junco
#

The person that open the thread

manic path
#

Right. Thanks

tidal hawk
#

Yo what ? - MessageContentPrefixWarning: Message Content intent is not enabled and a prefix is configured.

#

I've enabled message content from devs portal

loud junco
#

Go to discord dev portal

tidal hawk
loud junco
#

Enable all of them

#

And do the intent = intent thing

tidal hawk
#

mm do i have to enable the text thing seperately

loud junco
#

What about bot=

tidal hawk
placid skiff
#

you need to enable disnake.Intents.message_content

tidal hawk
slate swan
placid skiff
placid skiff
placid skiff
#

Just efficiency

tidal hawk
#

What was going on with rate limits yesterday?

#

Like a lot of people were experiencing it

supple thorn
tidal hawk
#

People from Discord Developers server

loud junco
#

Replit pepo

tidal hawk
#

NAA

loud junco
#

πŸ˜‚πŸ˜‚πŸ˜‚

tidal hawk
#

no replit

placid skiff
#

You know, people who don't read TOS

loud junco
#

Lol

tidal hawk
#

Dude, it was later on fixed xd

loud junco
#

It happens to everyone

placid skiff
#

It is never happened to me D_D

#

And i'm a freelancer too D_D

tidal hawk
#

Lucky you then

#

It didn't affect everybody for sure

slate swan
placid skiff
#

Well of course i don't read everything and i don't read every TOS

loud junco
#

Lol

tidal hawk
#

xD

loud junco
#

Me who NVR reads that boring essay

tidal hawk
#

Me who reads TOS only when something bad is happening to me

loud junco
#

Lol

placid skiff
#

I'm pretty confident D_D

cloud dawn
#

Morning

#

:3

vocal plover
#

Once you've read one terms of service you typically only need to skim new ones

#

The majority of a ToS is ass covering and "dont use our platform for malicious or illegal stuff"

placid skiff
#

yeah essentially that's what it is
Fortunally discord ToS is divided in section D_D

#

There is a section reserved to iOS user only

#

Cuz they had to specify everything that they've specified before in the ToS but with the word "Apple" before everything D_D

cloud dawn
#

Since ios users couldnt behave

loud junco
#

πŸ’€

jagged root
#

How can i make a bot that send private message to everyone?

vocal plover
#

let's talk about this clause in the AWS terms of service

#

However, this restriction will not apply in the event of the occurrence (certified by the United States Centers for Disease Control or successor body) of a widespread viral infection transmitted via bites or contact with bodily fluids that causes human corpses to reanimate and seek to consume living human flesh, blood, brain or nerve tissue and is likely to result in the fall of organized civilization.

placid skiff
vocal plover
#

basically "There restrictions don't apply in a zombie apocalypse"

placid skiff
unkempt canyonBOT
vocal plover
#

If you send DMs to everyone your bot will be quarantined from sending DMs, in general, do not mass DM users

jagged root
#

Ill just create another

placid skiff
#

||btw this is one of the classic question I read before reading "WHY MY BOT IS NOT WORKING IT WORKED YESTERDAY" (yes is the question before get rate limited)||

#

Uhm no

#

they rate limit your ip D_D

jagged root
#

Rip

#

K

vocal plover
#

You still shouldnt mass DM even if you can just use another bot when it gets banned because it's a scummy thing to do

abstract kindle
#

Heyo, how do I access the page attribute here?

        class PetPaginatorButtons(discord.ui.View):
            def __init__(self, page, *, timeout=180):
                super().__init__(timeout=timeout)
                self.page = page

in this decorator?

 @discord.ui.button(label=, emoji=self.page.emoji, style=discord.ButtonStyle.green,
                               disabled=not pages[0].can_buy, custom_id="purchase")
light violet
#
  raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object BanIterator can't be used in 'await' expression
@client.command(aliases=["unbanall"])
@commands.cooldown(1,5, commands.BucketType.user)
async def unbanalll(ctx):
    
    guild = ctx.guild
    banlist = await guild.bans()
    v = embed = disnake.Embed(title='Alpha. ', color=0x2f3136, description=f'**Unbanning {len(banlist)} Clients**')
    g = await ctx.send(embed = v)
    for users in banlist:
        await ctx.guild.unban(user=users.user)
    await g.delete()
    await ctx.send(embed = disnake.Embed(title='Alpha. ', color=0x2f3136, description=f'**Done!!**'))```

how to solve this error
#

huh

abstract kindle
#

I want the label in my error to be self.page.label and the emoji to be self.page.emoji but I don't know how to access the page that the view is currently on

placid skiff
#

!d discord.Guild.bans

unkempt canyonBOT
#

async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry "discord.BanEntry").

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

Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list...
placid skiff
#

the error is speaking too D_D

light violet
placid skiff
#

it is written in the docs D_D

abstract kindle
#

any shot you can check my question

cloud dawn
#

πŸ”«

light violet
placid skiff
#

bruh it it written Retrieves an async iterator you are trying to use it like an async method

light violet
#

stil not working and this was working some days ago

abstract kindle
#

it?

placid skiff
#

it is just bans = Guild.bans(**kwargs)

#

then bans is equals to an async iterator

#

so you will have to do an async for

jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\prefix.py", line 20, in change_prefix
    db.execute("UPDATE guilds SET Prefix = ? WHERE GuildID = ?",
AttributeError: module 'db.db' has no attribute 'execute'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\events.py", line 61, in on_command_error
    raise error
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'db.db' has no attribute 'execute'``` Am trying to change my prefix but it wont work
#

And like i have created a table on the sqlite browser table

light violet
#

@placid skiffthen how do i send len of banlist

alpine pewter
#
@bot.event
async def on_ready():
    print("--------------------------")
    print("[1] Nitrado Obelisk - Online")
    await bot.change_presence(activity=nextcord.Activity(type=nextcord.ActivityType.watching, name=f"Gameserver!"))
    players_online.start()
    status.start()


@tasks.loop(seconds=60)
async def status():
(...)

@tasks.loop(seconds=60)
async def players_online():
(...)
26.05 10:11:38 [Bot] File "/.local/lib/python3.9/site-packages/nextcord/client.py", line 417, in _run_event
26.05 10:11:38 [Bot] await coro(*args, **kwargs)
26.05 10:11:38 [Bot] File "/./Main Development (Nitrado)/Source (Nitrado)/main.py", line 25, in on_ready
26.05 10:11:38 [Bot] status.start()
26.05 10:11:38 [Bot] NameError: name 'status' is not defined

Can someone help with this? I'm unsure why my task loop will not start.

#

Would it be the inner part of the code, it's saying it's not defined

#

I'm unsure

heady sluice
#

change the activity in the Bot constructor 😭

alpine pewter
#

Oi, what's wrong with that

#

It's the only one I know of lolol

heady sluice
#

making a huge API call on_ready

#

anyways

sullen pewter
#

How to make it so the bot can understand lowercase letters and uppercase letters?

heady sluice
#

players_online.start() works?

loud junco
#

.lowercase

alpine pewter
#

I tried the code, it was working earlier on, now it's not for the status

heady sluice
#

hm

sullen pewter
heady sluice
#

well don't put the tasks' starts in on_ready

#

nothing that you put in on_ready should be in on_ready

sullen pewter
#

I want it to understand only letters and not care about the size

sullen pewter
# loud junco .lowercase
elif message.channel.type == discord.ChannelType.private and message.content == "None":
     await channel.send("Nickname wasn't changed.")```
alpine pewter
#

Been doing it since day one lol

heavy shard
heady sluice
#
bot = commands.Bot(..., activity=nextcord.Activity(type=nextcord.ActivityType.watching, name="Gameserver!"))

@bot.event
async def on_ready():
    print("--------------------------")
    print("[1] Nitrado Obelisk - Online")

@tasks.loop(seconds=60)
async def status():
(...)

@tasks.loop(seconds=60)
async def players_online():
(...)

players_online.start()
status.start()
bot.run(TOKEN)
sullen pewter
heady sluice
#

though your tasks might need await bot.wait_until_ready()

alpine pewter
sullen pewter
#

How can I make my bot understand lower and upper case letters?

if message.content.startswith('N') and message.channel.type == discord.ChannelType.private:
   await channel.send(f'Nickname set to **{message.content[1:]}**')
   await member.edit(nick=message.content[1:])
elif message.channel.type == discord.ChannelType.private and message.content == "None":
   await channel.send("Nickname wasn't changed.")```
heady sluice
#

if message.content.lower().startswith('n')

unkempt canyonBOT
#

str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to lowercase.

The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
tight mica
#

or upper tho

sullen pewter
#

!d str.upper

unkempt canyonBOT
#

str.upper()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3/library/stdtypes.html#id15) converted to uppercase. Note that `s.upper().isupper()` might be `False` if `s` contains uncased characters or if the Unicode category of the resulting character(s) is not β€œLu” (Letter, uppercase), but e.g. β€œLt” (Letter, titlecase).

The uppercasing algorithm used is described in section 3.13 of the Unicode Standard.
sullen pewter
#

I want my bot understand both

heady sluice
sullen pewter
#

not only lowercase

cloud dawn
#

!d str.capitalize

unkempt canyonBOT
#

str.capitalize()```
Return a copy of the string with its first character capitalized and the rest lowercased.

Changed in version 3.8: The first character is now put into titlecase rather than uppercase. This means that characters like digraphs will only have their first letter capitalized, instead of the full character.
tight mica
heady sluice
#

also, your bot will never enter this if statement
elif message.channel.type == discord.ChannelType.private and message.content == "None":

tight mica
#

when the full message is in lowercase, then it would obviously understand

sullen pewter
#

why not

sullen pewter
heady sluice
#

it's logical, if the person types None, the bot still enters the if statement before

heavy shard
#

and changes nick to "one"

tight mica
heady sluice
heady sluice
#

it's all lowercase

sullen pewter
#

huh?

tight mica
#

then you can just check if its none

sullen pewter
#

I don't understand

wet crystal
#

How do you kick someone from a voice channel?

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

001 | none
002 | True
003 | none
004 | True
005 | none
006 | True
tight mica
#

yep

heady sluice
#

yep

cloud dawn
#

yep

sullen pewter
sullen pewter
heady sluice
#

no cuz your logic is not flawless

tight mica
wet crystal
tight mica
tight mica
cloud dawn
tight mica
#

member.guild.voice_client.disconnect()

cloud dawn
unkempt canyonBOT
#

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

Moves a member to a new voice channel (they must be connected first).

You must have the [`move_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.move_members "discord.Permissions.move_members") permission to
use this...
cloud dawn
tight mica
#

wait

#

maybe

cloud dawn
# unkempt canyon

Changed in version 1.1: Can now pass None to kick a member from voice.

tight mica
#

thanks

jade tartan
heady sluice
#

can you give a string an attribute

tight mica
heady sluice
#

!e

e = "Hello"
e.randomattr = "Bello"
print(e, e.randomattr)
unkempt canyonBOT
#

@heady sluice :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | AttributeError: 'str' object has no attribute 'randomattr'
heady sluice
#

nah

jade tartan
# heavy shard can you show the code how you open the database?

Are you meaning this? ```from os.path import isfile
from sqlite3 import connect

from apscheduler.triggers.cron import CronTrigger

DB_PATH = "./data/db/database.db"
BUILD_PATH = "./data/db/build.sql"

cxn = connect(DB_PATH, check_same_thread=False)
cur = cxn.cursor()

def with_commit(func):
def inner(*args, **kwargs):
func(*args, **kwargs)
commit()

return inner

@with_commit
def build():
if isfile(BUILD_PATH):
scriptexec(BUILD_PATH)

def commit():
cxn.commit()

def autosave(sched):
sched.add_job(commit, CronTrigger(second=0))

def close():
cxn.close()

def field(command, *values):
cur.execute(command, tuple(values))

if (fetch := cur.fetchone()) is not None:
    return fetch[0]

def record(command, *values):
cur.execute(command, tuple(values))

return cur.fetchone()

def records(command, *values):
cur.execute(command, tuple(values))

return cur.fetchall()

def column(command, *values):
cur.execute(command, tuple(values))

return [item[0] for item in cur.fetchall()]

def execute(command, *values):
cur.execute(command, tuple(values))

def multiexec(command, valueset):
cur.executemany(command, valueset)

def scriptexec(path):
with open(path, "r", encoding="utf-8") as script:
cur.executescript(script.read())

heady sluice
#

this has 0 dpy in it

#

😭

heavy shard
tight mica
heavy shard
#

wait is it db.py file? hmm

tight mica
#

im not sure, thats why im asking

#

because if they are importing it then it should work iirc

jade tartan
tight mica
#

well try putting the stuff in db.py in a class and then call the class in the main file

jade tartan
cloud dawn
tight mica
#

if it works then it works

#

i wont bother touching it

robust fulcrum
upbeat gust
slate swan
upbeat gust
robust fulcrum
robust fulcrum
upbeat gust
#

just use 2.0, it's better

cloud dawn
#

Agreed

robust fulcrum
#

Cause me use replit and keeps changing to 1.7

slate swan
slate swan
#

Imagine getting hecked by a random 3rd party module

tight mica
#

imagine having to use multiple modules for the same service

upbeat gust
upbeat gust
slate swan
#

How do you make so that all the buttons are disabled when one button is clicked and at the same time send an embed?

upbeat gust
slate swan
upbeat gust
#
for b in self.children:
    b.disabled = True```
#

simple :)

slate swan
#

Oh okay

#

Like i have 5 buttons in each interaction function i run this?

vale wing
#

Guys, I am making discord bot tutorial, what do you think of this learning route? Should I add some other points into it or it is okay

upbeat gust
slate swan
upbeat gust
vale wing
#

Oh heck

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slate swan
#

breh

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
upbeat gust
#

that's a long command damn

slate swan
#

lol

slate swan
upbeat gust
#

It's ok you can still have a disabled function

slate swan
#

So what do I do?

upbeat gust
#

Make a function, call it in the button callbacks

slim crag
#

I use this server_name = client.get_guild(int(server_id)) to get the server_name and print None

upbeat gust
slate swan
upbeat gust
#

πŸ˜”

slate swan
#

:cri:

slate swan
upbeat gust
slim crag
#

@upbeat gust ```py
for server_id in servers:
server_name = client.get_guild(int(server_id))
print(server_name)

upbeat gust
#

take the view instance and interaction

upbeat gust
upbeat gust
upbeat gust
#

get the .name attr

slate swan
#

Phew, Ima rewrite

#

@upbeat gust I'm gonna rewrite but tell me this time how to setup this whole thing

upbeat gust
#

Eh you don't have to rewrite

robust fulcrum
robust fulcrum
slate swan
slim crag
upbeat gust
light violet
#

how do i add nightcore effect to my music bot

slate swan
#

@upbeat gust help me this time ima add a subclass pwease help :verysedcat:

slate swan
slim crag
#

and this server_name = client.get_guild(880403606619160646) print None and this id is a server I am sure the bot is in

upbeat gust
#

replace ... With the lib you want

#

Use git+ followed by the github link if you need that

light violet
#

how do i make a nightcore music bot

upbeat gust
upbeat gust
unreal spire
#

I receive the message but can't detect the message edit. what am i doing wrong

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

    @commands.Cog.listener()
    async def on_message(self, message):
        if message.author.id == userid and message.channel.id == channelid:
            print("ping")
            try:
                wait_edit = await self.bot.wait_for('on_raw_message_edit', check= lambda p: p.message_id == message.id, timeout=10)
                print("Message edited")
            except asyncio.TimeoutError:
                print("Timed out!")
slim crag
#

I print the intents and is 32767 and I think this is all intents

heavy shard
#

try print(list(intents))

light violet
vale wing
#

If he can get message he can get edit events too

#

Intents are not the issue

vale wing
glad cradle
vale wing
#

And yeah you don't need on_raw_message_edit use simple on_message_edit

slim crag
#

all the intents are true

vale wing
unreal spire
#

πŸ‘Œ thanks guys

terse coyote
#

how to get online members?

light violet
#

ok then tell me how to make a command to record in voice channels

vale wing
#

Is this even allowed by tos

light violet
#

there are verified bots doing this

upbeat gust
heady sluice
vale wing
#

Idk if the bots can receive incoming audios tho

heady sluice
#

APIly yes

#

discord allows that

#

dpy doesn't

light violet
#

mee6 can record bro

terse coyote
#

how to get online members?

vale wing
#

Presence intent enabled and this code

online_members = [m for m in guild.members if m.status != discord.Status.offline]```
robust fulcrum
#

Like aiohttp and many more

flint isle
#

ok im trying to run checks from a list. for example
permcheck = [administrator, view_audit_log]
how can i run for each item in the list and get them in a second variable

flint isle
#

ummm. idk lol.
im trying to run a check on a list of permissions using inter.me.guild_permissions i need to add the item in i to the end so it would be inter.me.guild_permissions.administrator

jade tartan
potent spear
jade tartan
#
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
    spec.loader.exec_module(lib)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\config.py", line 9, in <module>
    import utils.json_loader
ModuleNotFoundError: No module named 'utils.json_loader'

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

Traceback (most recent call last):
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\launcher.py", line 40, in <module>
    bot.load_extension(f"cogs.{file[:-3]}")
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.config' raised an error: ModuleNotFoundError: No module named 'utils.json_loader'```
#

So?

slate swan
#
@client.command(name='eval', pass_context=True)
@commands.is_owner()
async def eval_(ctx, *, command):
     res = eval(command)
     if inspect.isawaitable(res):
          await ctx.send(await res)
     else:
          await ctx.send(res)β€Š

How it is supposed to work

#

Its a command to eval a script

#

?

maiden fable
#

U can't just use that

#

U gotta use exec()

#

!d exec

unkempt canyonBOT
#

exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code that’s executed is expected to be valid as file input (see the section [File input](https://docs.python.org/3/reference/toplevel_components.html#file-input) in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") function. The return value is `None`.
slate swan
#

So instead of eval(command) do exec(command)?

slate swan
#

wouldnt exec be blocking?

jade tartan
#
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 606, in _load_from_module_spec
    spec.loader.exec_module(lib)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\config.py", line 9, in <module>
    import utils.json_loader
ModuleNotFoundError: No module named 'utils.json_loader'

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

Traceback (most recent call last):
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\launcher.py", line 40, in <module>
    bot.load_extension(f"cogs.{file[:-3]}")
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.config' raised an error: ModuleNotFoundError: No module named 'utils.json_loader'```
#

So?

robust fulcrum
#
@bot.command()
async def invite(ctx):
    v= Buttons()
    v.add_item(discord.ui.Button(label="Invite",style=discord.ButtonStyle.link,url="https://github.com/lykn"))
    await ctx.send("Invite link",view=v)

Pls anyone help me fix
I am getting an error in it

placid skiff
#

what's the error?

robust fulcrum
placid skiff
#

You haven't import the Button class

robust fulcrum
#

Hmm

dry urchin
#

Hey, I have an ongoing subscription email that I would like to be posted on my Discord server (i.e whenever the sender sends me an email, Python sends a webhook to a specific channel). How do I extract the title, content, and overall email?

placid skiff
#

and btw view attribute in send method takes a View object, not a Button

robust fulcrum
#

Oh from duscord import butto

maiden fable
placid skiff
slate swan
dry urchin
#

I've never extracted content from emails before

maiden fable
placid skiff
#

Neither i did
This channel is for discord bot, ask in some general help channel

slate swan
maiden fable
slate swan
#

but further questions should not go here

maiden fable
#

The console was spitting out logging errors

slate swan
#

imma try that with the python bot now

maiden fable
#

Lmao it won't work

slate swan
#

seriously?

maiden fable
#

Since snekbox is a different API

#

And its a protected environment

slate swan
#

pffttt

maiden fable
#

!e import time; time.sleep(100);print(1)

unkempt canyonBOT
#

@maiden fable :warning: Your eval job timed out or ran out of memory.

[No output]
maiden fable
#

See

slate swan
#

weird

potent spear
maiden fable
#

If the sleep period is too long

slate swan
#

welp

robust fulcrum
#

Guys can anyone help me how can we make url button in discord.py

maiden fable
#

!d discord.ButtonStyle.link

unkempt canyonBOT
robust fulcrum
#

Ok

#

Means how can I use it in comamnd

maiden fable
#

Set the button style to that

robust fulcrum
#

It's how's me error

#

That i cant add url to it

slate swan
robust fulcrum
#

@bot.command()
async def invite(ctx):
    v= Buttons()
    v.add_item(discord.ui.Button(label="Invite",style=discord.ButtonStyle.link,url="https://github.com/lykn"))
    await ctx.send("Invite link",view=v)

I got this from a git

maiden fable
#

What's Buttons()

robust fulcrum
#

I got in a git

maiden fable
#

Did u mean ui.View()?

slate swan
#

okay....this thing has been pricking me lately that....why does discord.py's event on_member_remove still returns a Member object even though the user isnt part of the guild anymore

placid skiff
jade tartan
#

So?

#

Hello

sick birch
#

Also it’s more of a question to ask why does discord’s API do that rather than discord.py

slate swan
#

hm weird

robust fulcrum
#

Guys can anyone give me example of a url button comamnd
Me not able to find a good tutorial

sick birch
#

More of a design choice than a logic choice because as mentioned already there’s no point in getting a user object

slate swan
#

hm yeah yeah

sick birch
#

There’s one in the GitHub

#

Under the views folder

flint isle
#

Yes. Sorry had got off the bus and had a final.

#

Anyone have any simple database code that is reccomended for a bot?

vale wing
#

Wut

vale wing
potent spear
jade tartan
#

I do and i did put them on the line that it needs to be put in but it still doesnt work

robust fulcrum
slate swan
slate swan
unkempt canyonBOT
#

discord/state.py lines 1006 to 1018

user = self.store_user(data['user'])
raw = RawMemberRemoveEvent(data, user)

guild = self._get_guild(raw.guild_id)
if guild is not None:
    if guild._member_count is not None:
        guild._member_count -= 1

    member = guild.get_member(user.id)
    if member is not None:
        raw.user = member
        guild._remove_member(member)
        self.dispatch('member_remove', member)```
slate swan
#

hence, allowing you to get that user's Member object.

#

still doesnt make sense, I literally asked, why?

#

since the User isn't a Member anymore

#

library users would like checking what was the Member state before they left, like their roles, permissions, etc. which is really used by bots widely, so that should make sense

#

hm

haughty nova
#
from discord.ext import commands

TOKEN = 'Token'

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

@bot.command()
async def vkc(ctx):
   allowed_mentions = discord.AllowedMentions(everyone = True)
   await ctx.send("@everyone Det er jump i C! Join VK C nu!", allowed_mentions=allowed_mentions)

bot.run(TOKEN)```

how do i get so that the bot reacts to the message its sends?
slate swan
#

weird

#

we are discussing about discord.py, so its forsho gonna be~

slate swan
slate swan
haughty nova
#

Thank you

slate swan
#

another reason why hikari is better :p

slate swan
# slate swan "[e

yeah thats the reason that question about the dpy event came into my mind lol

haughty nova
#

how do i get the emoji?

#

:goldhelmet:

slate swan
#

!d discord.ext.commands.Bot.get_emoji

unkempt canyonBOT
slate swan
#

or you can use the escaped name of the emoji
<:name:id> for static emojis
<a:name:id> for animated emojis

haughty nova
#

but when i do like this

await msg.add_reaction(": grining 😊

it's just shows ...

#

and in vsc

#

its says unknown emoji

slate swan
#

use the unicode

#

\πŸ˜€

#

and you can have only 1 emoji in 1 add_reaction

jolly basalt
#

how do i constantly check if a member's status

#

like

#

if they're online, offline, dnd or idle

slate swan
unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with
optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
#

!d discord.Guild.get_member

unkempt canyonBOT
#

get_member(user_id, /)```
Returns a member with the given ID.

Changed in version 2.0: `user_id` parameter is now positional-only.
jolly basalt
#

tysm

slate swan
#

!d discord.Member.status

unkempt canyonBOT
#

property status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
slate swan
#

welcome

robust fulcrum
#

Do anyone know how can we send a url button i saw the link example from the guy but i have no url button
Pls anyone anyone send me a example here

slate swan
#
view = discord.ui.View()
view.add_item(discord.ui.Button(style=discord.ButtonStyle.url, label="", url=""))
warped mirage
#

Damn

#

Lucky people xd

fierce light
#

Sheesh

flint isle
#

how can i remove the (' at the beginning. also how do i check if the end is true and remove the ', True) if true and ', False) if false

('external_stickers', True)
('send_messages_in_threads', True)
('start_embedded_activities', True)
('moderate_members', True)
warped mirage
flint isle
# warped mirage Simple xd remove it……

well heres the code lol


    @commands.slash_command(name='permissions')
    async def permissions(self, inter):
        permissions_list = inter.me.guild_permissions
        permslist = []
        perm = ['administrator','view_audit_log','attach_files']
        for perm in permissions_list:
            if perm in inter.me.guild_permissions:
                print(perm)```
fierce light
#

Bru

#

.replace("'", "")

visual island
flint isle
#

can you do a simple example and use the !e to show how it works?

visual island
#

!e

a_tuple = ('external_stickers', True)

print(a_tuple[0])  # The first element of the tuple
print(a_tuple[1])  # The second element of the tuple
unkempt canyonBOT
#

@visual island :white_check_mark: Your eval job has completed with return code 0.

001 | external_stickers
002 | True
flint isle
#

ahh

#

that makes more sense

#

thank you

visual island
#

Anytime!

minor totem
#

Tuples are like lists but they can't be changed, this makes them a bit more efficient!

flint isle
#

can i add to an embed so if i have
HEHEHEHE
in the embed
can i add
UwU
to it so its

HEHEHEHE
UWU```
Oh and im using disnake
minor totem
#

Do you want to edit the embed?

visual island
#

I don't really understand what you mean, but probably you want to edit the existing embed (assume it has the title "HEHEHEHE") and add "UwU" to it. Firstly get that embed (maybe using Message.embeds[0]), then, access the title attribute, and add "UwU" to it, finally, edit the message.

#

It would be something like this:

embed = disnake.Embed(title="HEHEHEHE")
message = await channel.send(embed=embed)

new_embed = message.embeds[0]  # Message.embeds returns a list, so just index the first element
new_embed.title += "UwU"
await message.edit(embed=new_embed)
flint isle
flint isle
glossy ruin
#
@client.command(name="command")
async def _command(ctx):
    await ctx.send(f"y or n")

    # This will make sure that the response will only be registered if the following
    # conditions are met:
    def check(msg):
        return msg.author == ctx.author and msg.channel == ctx.channel and \
        msg.content.lower() in ["y", "n"]

    msg = await client.wait_for("message", check=check)
    if msg.content.lower() == "y":
        await ctx.send("You said yes!")
    else:
        await ctx.send("You said no!")```
#

can i know how this work

#

def check(msg) i am having problem with this line

visual island
minor totem
glossy ruin
#

only that

#

left is easy

fierce light
#

Why is it indented

glossy ruin
#

he was learning about this, and this confused me

fierce light
#

Oh

minor totem
glossy ruin
#

hmm

visual island
#

The function you passed to the wait_for is called everytime an event is dispatched (received) by your bot, then discord.py calls that function and passed Message to that function (This is determined from what the event is).

glossy ruin
#

thanks

minor totem
#

msg.author == ctx.author and msg.channel == ctx.channel and msg.content.lower() in ["y", "n"] becomes True or False, because it is a condition

robust fulcrum
#

Guys how can we edit a message multiple times in discord.py

sullen pewter
#
number = int(button.label) if button.label else 0```
What does this mean
#

if button.labe else 0

paper sluice
#
number = int(button.label) if button.label else 0

this is equivalent to

if button.label:
    number = int(button.label)
else:
    number = 0
cloud dawn
warped mirage
#
        await ctx.send("Lets Start this giveaway, answer the questions I ask and we can proceed.")

        questionList =[
            ["What channel should it be in?", "Mention the channel"],
            ["How long should this giveaway last?", "d|h|m|s"],
            ["What are you giving away?", "E.G. Pizza"]
        ]
        answers = {}

        for i, question in enumerate(questionList):
            answer = await GetMessage(self.client, ctx, question[0], question[1])

            if not answer:
               await ctx.send("You failed to answer, please answer quicker next time!")
               return

            answers[1] = answer

        embed = discord.Embed(name="Giveaway Content")
        for key, value in answers.time():
            embed.add_field(name=f"Question: `{questionList[key][0]}`", value=f"Answer: `{value}`", inline=False) 

        m = await ctx.send("Are all these valid?", embed=embed)
        await m.add_reaction("βœ…")
        await m.add_reaction("β›”")                         ``` get message  is  not   defin ed
rocky hornet
#

need help with designing a command that combines 2 commands

slate swan
#

uh?

rocky hornet
#

lets say i have an ocr command that reads text from an image, and a translate command that translates text. i want to make ocrtranslate command which does both at once

warped mirage
#

ashley any ideas for my code

slate swan
warped mirage
#

like how to fix.

slate swan
#

lemme see

warped mirage
#

btw im using another file aswell ```import discord
import asyncio

async def GetMessage(
client, ctx, contentOne="Default Message", contentTwo="\uFeFF", timeout=100
):

embed = discord.Embed(
   title=f"{contentOne}",
   description=f"{contentTwo}",
)
sent = await ctx.send(embed=embed)
try:
    msg = await client.wait_for(
        "message",
        timeout=timeout,
        check=lambda message: message.author == ctx.author
        and message.channel == ctx.channel,
    )
    if msg:
       return msg.content
except asyncio.TimeoutError:
   return False
slate swan
#
@bot.command()
async def meow(ctx):
 ew = bot.get_cog("GenCommands")
 for commands in ew.commands:
    print(commands)``` whats wrong, no response, the cog name is right and loaded
rocky hornet
sullen pewter
rocky hornet
warped mirage
cloud dawn
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

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

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

sullen pewter
rocky hornet
#

wut

cloud dawn
#

Who's danny?

rocky hornet
#

i dont need to cry as im not a dpy user lmao

rocky hornet
sullen pewter
rocky hornet
sullen pewter
#

Danny

rocky hornet
#

who's danny

warped mirage
#

btw im using another file aswell ```py
import discord
import asyncio

async def GetMessage(
client, ctx, contentOne="Default Message", contentTwo="\uFeFF", timeout=100
):

embed = discord.Embed(
   title=f"{contentOne}",
   description=f"{contentTwo}",
)
sent = await ctx.send(embed=embed)
try:
    msg = await client.wait_for(
        "message",
        timeout=timeout,
        check=lambda message: message.author == ctx.author
        and message.channel == ctx.channel,
    )
    if msg:
       return msg.content
except asyncio.TimeoutError:
   return False
sullen pewter
rocky hornet
#

ok

warped mirage
#

Does that work ?

rocky hornet
cloud dawn
#

I use hikari

slate swan
#

whos danny

rocky hornet
cloud dawn
warped mirage
#

I’m on mobile so I can’t see if it works

slate swan
warped mirage
rocky hornet
slate swan
#

only persons i know is eq and epic😳

warped mirage
#

Ye

#

Does anyone know who owns discord.js by any chance ?

rocky hornet
sullen pewter
#

yes

cloud dawn
rocky hornet
#

yes danny wrote all discord api wrappers

slate swan
#

panda

cloud dawn
#

Yes?

rocky hornet
#

in all languages

slate swan
#

panda is the creator of this world

sullen pewter
rocky hornet
#

is it on github?

cloud dawn
#

I took a nap on the 7th day true story.

slate swan
#

❀️

sullen pewter
rocky hornet
slate swan
#

😳

#

check pandas repos he has a 1 to 1 scale of the world

cloud dawn
#

Bruh my repo's suck

sullen pewter
#

Does anyone know what MIT license is

#

Is it like license granted by MIT

slate swan
#

no no

cloud dawn
sullen pewter
slate swan
#

ew = bot.get_cog("GenCommands")
for y in ew.commands:
await ctx.send(y)
no response, the cog name is SURELY Valid i double checked and copied

#

Me Is Tired

sullen pewter
#

lol

rocky hornet
#

is there a premade embed paginator?

slate swan
#

theres allot of exts ive seen

rocky hornet
#

uh

#

why make an ext for something that could be a simple class

slate swan
#

beware theres allot of extensions with trash impl!

rocky hornet
#

im looking for the simplest solution

#

2 buttons/reactions that scroll backward/forward

flint isle
#

i just pushed a pull request to disnakes repo

slate swan
#

ew = bot.get_cog("GenCommands")
for y in ew.commands:
await ctx.send(y)
no response, the cog name is SURELY Valid i double checked and copied

slate swan
rocky hornet
#

disnake

slate swan
#

paginator?

rocky hornet
#

?

#

yes, paginator

#

πŸ™‚

slate swan
#

hm

rocky hornet
#

what are you asking

#

disnake is discord api wrapper

#

im looking for a simple embed paginator that has 2 buttons or reactions that make it able to scroll backward or forward

slate swan
slate swan
rocky hornet
#

idk why i refused to check examples

#

thanks

slate swan
#

no comments, disnake has the best examples out of all other forks imo

#

ashley is a W

rocky hornet
#

i even improved one

slate swan
#

which

warped mirage
#

but idk if i need to import from the other file or whatever

rocky hornet
slate swan
warped mirage
#

so from utils import GetMessage?

slate swan
warped mirage
#

ok

slate swan
#

if thats your file name

rocky hornet
#

lol that was a joke commit but they accepted it
well tbf im still correct so i dont mind

slate swan
rocky hornet
slate swan
#

😭