#discord-bots

1 messages Β· Page 1026 of 1

visual brook
#

ah

slate swan
#

And specifically {0.domething} when using it only once, which loses the usage of actually using 0

keen mural
#

ok so it would be an option that would work?

loud junco
#

u need to modify it with ur brain instead of control c v blindly

slate swan
#

In my opinion it just straight up shows how not to make a bot.

sly hamlet
#
    async def start_loop(self):
        await self.api.start_loop()
        print("Post Count")


async def setup(bot):
    cog = DiscordListsPost(bot)
    await bot.add_cog(cog)
    await cog.start_loop()``` ```py
Extension 'cogs.api' raised an error: AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook``` I seem to still be having an issue with my API can someone help me please
loud junco
#

huh

visual brook
#

wait but what does 0 or whatever that symbol is mean

loud junco
#

0 means the number 0
and what symbol are u referring to

visual brook
#

here

#

the 0.user

loud junco
#

tf is this
print('We have logged in as {0.user}'.format(client))
formatting string without formatter

slate swan
#

use f strings, easier

hearty glacier
#

To be fair

loud junco
hearty glacier
#

.format is old habit for me

visual brook
#

yeah ik but ig they wrote it back when 3.6 hasn't been released

slate swan
#

!d format

loud junco
#

instead of ' ' + ' ' + ' ' + ' ' + ' ' + ' '

slate swan
#

!f-strings

unkempt canyonBOT
#

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

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

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

slate swan
#

str.format ? ig

hearty glacier
#

Just regex it kapp

visual brook
#

so what does 0.user mean

slate swan
#

It takes the 0th argument from what's in .format(x)

slate swan
visual brook
#

oh ok

loud junco
#

and u count from 0 instead of 1

slate swan
#

Useful if you want to use the element multiple times but with a different attribute

#

..

hearty glacier
#

And to be fair, there are use cases for "{x.foo} something something {x.bar}".format(x)

loud junco
slate swan
loud junco
#

going valorant byebye

slate swan
#

..

#

Just clearly not needed for

print("We have.... {0.user}".format(client))
keen mural
#

yo i think i should clean up my code.. how do i use cogs for cmds or whatever

slate swan
#

..

keen mural
#

like if i want mute cmd in mute file how make that work

loud junco
slate swan
slate swan
keen mural
#

i saw an odin ace today

keen mural
#

i need to do at least smth

slate swan
#

Nice

loud junco
slate swan
#

That's not cog

#

divide commands into categories, a cog for each

slate swan
keen mural
#

well im mostly asking how i can organize my cmds into diff files

slate swan
#

20 files for 20 commands...?

#

I use 1 file for my giv cmd

#

Cuz it's 300+ lines

keen mural
#

i just want like a file for moderation cmds, then giveaway cmds, then fun cmds, etc

#

and if im doing a list too

slate swan
keen mural
#

would i do from (file name) import (whatever i need to import)?

slate swan
#

Ash every msg bl curv line

slate swan
slate swan
#

Private

#

nvm

#

I'll send u

paper sluice
slate swan
#

If u want

slate swan
#

I code but I code bad sometimes

#

understandable and relatable

#

Waif I'll open my pc real quick

slate swan
slate swan
# keen mural would i do ``from (file name) import (whatever i need to import)?``
# cog_file.py 
from discord.ext import commands

class MyCog(commands.Cog):
    
     @commands.command()
     async def command (self, context):
          ... #this is command
      
     @commands.Cog.listener()
     async def on_ready(self):
          ... # this is an event


def setup(bot):
    bot.add_cog(MyCog())
``` this is an example for a very basic cog
you can add it in your bot using `bot.load_extension("cog_file")` ( v1.7.3)
torn sail
#

This is called extensions

keen mural
#

thx

slate swan
#

Lol

keen mural
torn sail
#

Then load the extension with bot.load_extension(β€œfile”)

keen mural
torn sail
#

Yes

slate swan
keen mural
#

ok i was just quizzing you guys to make sure you know
you passed good job

slate swan
#

lmaoooo

sly hamlet
keen mural
#

i definitely knew that

slate swan
#

@slate swan my giv cmd is not completed yet

#

funny

slate swan
keen mural
#

and i definitely know how to spell definitely

slate swan
#

xd

keen mural
slate swan
#

no.

paper sluice
slate swan
#

you can, but why would you call a "bot" a "client"

torn sail
#

Just commands.Bot

keen mural
slate swan
#

Sometimes happens to me too

#

i can't understand the code i just wrote yesterday

paper sluice
#

i write shit like this

        table_data = [
            data for i, j in zip(soup.find_all('th')[1:15], soup.find_all('td')[1:15])
            if '...' not in (data := {
                        'inline': False,
                        'name': i.text if i.text else '...',
                        'value': '...' if valid_chars.match(j.text) else j.text if j.text else '...'
                    }
                ).values()
        ]

ofc i wont understand

slate swan
slate swan
#

imagine making raw payloads for embeds

keen mural
paper sluice
slate swan
#

just embed.to_dict()

keen mural
paper sluice
#

welcome

#

else j.text if j.text else '...' i can replace this with else j.text or '...' πŸ‘€

slate swan
keen mural
slate swan
#

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

keen mural
#

would i put error handler codes in that cog file

torn sail
#

async def cog_command_error(ctx,error):

paper sluice
sly hamlet
#
    async def start_loop(self):
        await self.api.start_loop()
        print("Post Count")


async def setup(bot):
    cog = DiscordListsPost(bot)
    await bot.add_cog(cog)
    await cog.start_loop()``` ```py
Extension 'cogs.api' raised an error: AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook``` I seem to still be having an issue with my code can someone help me please
slate swan
#

back

slate swan
sly hamlet
#

It goes with an API library

vale wing
#

Afaik you start loop non asynchronously even in dpy 2.0

keen mural
#

idk what im doing

vale wing
#

If it is not dpy 2.0 loop, then overwrite setup_hook method of your bot subclass

sly hamlet
#

How?

vale wing
#
class MyBot(commands.Bot):
    async def setup_hook(self):
        # here```
sly hamlet
#

What do I put in set up hook?

vale wing
#

You should bring your api out of the cog into the bot if it's possible

sly hamlet
#

It's not

vale wing
#

What makes it be?

keen mural
#

im kinda dum, how would i add the top cmd into the bottom code

vale wing
#

I can't imagine a situation that would make it impossible to access

vale wing
keen mural
vale wing
#

Ok

keen mural
#

idk i just feel like this is a basic thing that i just dont know how to do

vale wing
slate swan
#

Got to make a task loop every 12 hours

#

Something like

from discord.ext import tasks

@tasks.loop(hours=12.0)
async def my_task():
    print("Do stuff here")

my_task.start()
#

@slate swan how do i add a check decorator to a command for guild permissions πŸ˜”

torn sail
#

!d discord.ext.commands.has_guild_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_guild_permissions(**perms)```
Similar to [`has_permissions()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_permissions "discord.ext.commands.has_permissions"), but operates on guild wide
permissions instead of the current channel permissions.

If this check is called in a DM context, it will raise an
exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage").

New in version 1.3.
loud junco
paper sluice
#

wrong channel?

jade tartan
#

For your guys bot @unkempt canyon do you guys have a help command in cogs form?

slate swan
#

why does this command mute but replies to the message after 10 seconds?

#
# mute
    @commands.command()
    @commands.has_permissions(manage_messages=True)
    async def mute(self, ctx, member: discord.Member, *, reason = "No reason provided"):
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="muted")
        emb = discord.Embed(description=f":white_check_mark:Member **{member.name}** has been muted!", colour = discord.Color.gold())
        emb.add_field(name="Moderator:", value=f"{ctx.author.mention}")
        embed = discord.Embed(title=f"You were muted on the server {ctx.guild.name}", colour=discord.Color.gold())
        if not mutedRole:
            mutedRole = await guild.create_role(name="muted")
        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
            await member.add_roles(mutedRole, reason=reason)
        await ctx.reply(embed=emb)
        await member.send(embed=embed)```
unkempt canyonBOT
#
Help Command

An interactive instance for the bot help command.

Source Code
tawdry perch
#

you can see it there

jade tartan
warped mirage
#

guys can someone help me

#
  File "C:\Users\Dom\Desktop\python bot\main.py", line 29, in on_ready
    bot.load_extension('cogs.leveling')
AttributeError: 'Command' object has no attribute 'load_extension'```
#

should i show code?

tawdry perch
#

!src paste

unkempt canyonBOT
#

Sorry, an unexpected error occurred. Please let us know!

AttributeError: 'TagIdentifier' object has no attribute 'qualified_name'

tawdry perch
#

ah it's a tag

warped mirage
#

guys so any errors

#

ideas , for my bot

jade tartan
#

On the code

warped mirage
#

await coro(*args, **kwargs)
File "C:\Users\Dom\Desktop\python bot\main.py", line 29, in on_ready
bot.load_extension('cogs.leveling')
AttributeError: 'Command' object has no attribute 'load_extension'

#

this is my error\

tawdry perch
slate swan
#

Not command

#

Show ur bot var

warped mirage
slate swan
#

Ok

warped mirage
#

ugh

#

my discord is undefined i think maybe thats why

#

idk

#
from discord.ext import commands
import json


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

    @commands.Cog.listener()
    async def on_ready(self):
        print('leveling.py has been loaded')

    @commands.Cog.listener()
    async def on_message(self,message):
        with open('users.json', 'r', encoding='utf8') as f:
            user = json.load(f)
            try:
                with open('users.json', 'w', encoding='utf8') as f:
                    user[str(message.author.id)]['xp'] = user[str(message.author.id)]['xp']+1
                    lvl_start = user[str(message.author.id)]['level']
                    lvl_end = user[str(message.author.id)]['xp'] ** (1.5/4)
                    if lvl_start < lvl_end:
                        user[str(message.author.id)]['level'] = user[str(message.author.id)]['level']+1 
                        lvl = user[str(message.author.id)]['level']
                        await message.channel.send(f"GG, {user.mention} you have leveled up , you are now level {lvl}")
                        json.dump(user, f, sort_keys=True, indent = 4, ensure_ascii=False)
                        return
                    json.dump(user, f, sort_keys=True, indent = 4, ensure_ascii=False)                    
            except:
                with open('users.json', 'w', encoding='utf8') as f:
                    user = {}
                    user[str(message.author.id)] = {}
                    user[str(message.author.id)]['level'] = 0
                    user[str(message.author.id)]['xp'] = 0
                    json.dump(user, f, sort_keys=True, indent = 4, ensure_ascii=False)


def setup(bot):
    bot.add_cog(leveling(bot))```
tawdry perch
#

paste is a tag, read the .md file

paper sluice
#

i just sent that -_-

slate swan
#

Lightbulb has guild perms lol

slate swan
maiden fable
#

The permissions....?

warped mirage
paper sluice
warped mirage
slate swan
#
# mute
    @commands.command()
    @commands.has_permissions(manage_messages=True)
    async def mute(self, ctx, member: discord.Member):
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="muted")
        emb = discord.Embed(description=f":white_check_mark:Member **{member.name}** has been muted!", colour = discord.Color.gold())
        emb.add_field(name="Moderator:", value=f"{ctx.author.mention}")
        embed = discord.Embed(title=f"You were muted on the server {ctx.guild.name}", colour=discord.Color.gold())
        em = discord.Embed(title=f"Member already muted!", colour=discord.Color.gold())
        if not mutedRole:
            mutedRole = await guild.create_role(name="muted")
        elif mutedRole in member.roles:
            await ctx.reply(embed=em)
        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
            await member.add_roles(mutedRole)
        await ctx.reply(embed=emb)
        await member.send(embed=embed)```
warped mirage
#

so lemme explain

#
async def on_ready():
    change_status.start()
    print('bot is ready')
    bot.load_extension('cogs.leveling')``` this is in my main.py
slate swan
#

who can help me?

warped mirage
paper sluice
#

can u show the error?

warped mirage
#

ok

slate swan
paper sluice
slate swan
#

😩

warped mirage
#
    bot.load_extension('cogs.leveling')
AttributeError: 'Command' object has no attribute 'load_extension'```
paper sluice
#

show where u defined bot

warped mirage
#

i have 2 cog files a cog file for reward.py but i have that setup and it works , i use it as a client , and the second one as bot

paper sluice
#

just use one...

warped mirage
#

can i have them all as client?

slate swan
#
# mute
    @commands.command()
    @commands.has_permissions(manage_messages=True)
    async def mute(self, ctx, member: discord.Member):
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="muted")
        emb = discord.Embed(description=f":white_check_mark:Member **{member.name}** has been muted!", colour = discord.Color.gold())
        emb.add_field(name="Moderator:", value=f"{ctx.author.mention}")
        embed = discord.Embed(title=f"You were muted on the server {ctx.guild.name}", colour=discord.Color.gold())
        em = discord.Embed(title=f"Member already muted!", colour=discord.Color.gold())
        if not mutedRole:
            mutedRole = await guild.create_role(name="muted")
        elif mutedRole in member.roles:
            await ctx.reply(embed=em)
        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
            await member.add_roles(mutedRole)
        await ctx.reply(embed=emb)
        await member.send(embed=embed)```
warped mirage
#

wait so i can have them all as client

paper sluice
warped mirage
maiden fable
warped mirage
#

so what should i do

paper sluice
#

rename it ..

slate swan
#

😭

slate swan
warped mirage
#

im so confused , can someone edit my code

paper sluice
#

we can't see the part of ur code which is causing problems, but anyways u have a @client.command() named bot which is causing problems

slate swan
warped mirage
#

all i could find

maiden fable
warped mirage
#

ye that

maiden fable
#

async def bot(ctx)

warped mirage
#

huh

maiden fable
#

Change the name of that function

warped mirage
#

so bot.add_cog - async def bot(ctx)

maiden fable
#

.....?

warped mirage
#
    bot.add_cog(leveling(bot)```
#

i have this

paper sluice
warped mirage
#

thats for my command

#

it works fine

#

when i change the async def it says bot is not defined

loud junco
warped mirage
#

yep i see

loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = str(bot.get_user(user) or await bot.fetch_user(user))
    db[f'{hehehe.id}cooked_pogchop'] += 42
    db[f'{hehehe.id}voteCount'] += 1
slate swan
warped mirage
#

the bot i used for my command defineded all my code

#

so i need help defining

paper sluice
slate swan
#

HEHEHE

warped mirage
#

so now my error is bot is not defined

loud junco
warped mirage
#

oh nice my cog file is working ,

#

the bot.load_extension part

#

so someone.

slate swan
#

whats the issue huh?

loud junco
#

can someone vote for this? im fixing vote rewards

warped mirage
#

bot is not defined

loud junco
#

help awhile i need error sample

#

dont ban not promotion

vale wing
warped mirage
loud junco
vale wing
#

You don't need someone to actually vote, it sends similar request

vale wing
#

Just press that button and it will send request just like you voted

loud junco
#

okok

slate swan
#

where "member is not muted"?

dull terrace
loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = bot.get_user(user) or await bot.fetch_user(user)
    hehehe = str(hehehe.id)
    db[f'{hehehe}cooked_pogchop'] += 42
    db[f'{hehehe}voteCount'] += 1
vale wing
stone beacon
#

Well the error explains itself , you can't add_role() to a discord User, you need to get a Member object

vale wing
#

If everything is inside your channel condition that's almost impossible to occur

#

Ig you have something outside

loud junco
stone beacon
#

!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.
stone beacon
#

Do uk how to get the guild object right?

maiden fable
#

Lmao

stone beacon
#

bot.get_guild()

vale wing
#

If your bot isn't intended to process messages from DMs just add this to the beginning of the event handler

if message.channel.type == discord.ChannelType.private:
    return```
maiden fable
#

isinstance is better, isn't it?

stone beacon
maiden fable
#

Indeed

loud junco
#

my brain rn: πŸ’₯

vale wing
#

Comparison of enums is more obvious imho

maiden fable
#

How are you doing

maiden fable
vale wing
#

Yes

loud junco
#

so what do i do now

loud junco
#

huh

#
if message.channel.type == discord.ChannelType.private:
    return
elif message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = bot.get_user(user) or await bot.fetch_user(user)
    hehehe = str(hehehe.id)
    db[f'{hehehe}cooked_pogchop'] += 42
    db[f'{hehehe}voteCount'] += 1
```like this?
vale wing
#

Yes but elif is unnecessary in this case

loud junco
#

if also?

vale wing
#

Just put 2 ifs

loud junco
#

okok

stone beacon
loud junco
#

but it doesnt fix the problem =.=

vale wing
#

What problem did you have

vale wing
#

This thing will basically ignore all DM messages

#

So you won't get User objects as authors

loud junco
paper sluice
vale wing
unkempt canyonBOT
#

ext/automod.py lines 36 to 42

if (
    message.author.bot
    or message.channel.type == disnake.ChannelType.private
    or len(message.content) == 0
    or message.author.guild_permissions.manage_guild
    or not message.channel.permissions_for(message.guild.me).send_messages
):```
paper sluice
#

!e

print(f'{10}, {10.1}, {"hello"}')
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

10, 10.1, hello
paper sluice
#

u dont need to convert to str

loud junco
#

ok

#

why doesnt it has the attribute

vale wing
#

Could you show your new code?

loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = bot.get_user(user) or await bot.fetch_user(user)
    hehehe = hehehe.id
    db[f'{hehehe}cooked_pogchop'] += 42
    db[f'{hehehe}voteCount'] += 1
vale wing
#

And do you have members intent enabled

#

!d discord.Member.add_roles

loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = bot.get_user(user) or await bot.fetch_user(user)
    hehehe = hehehe.id
    db[f'{hehehe}cooked_pogchop'] += 42
    db[f'{hehehe}voteCount'] += 1

    voteCount = db[f'{hehehe}voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    await message.author.add_roles(role)
  await bot.process_commands(message) 
vale wing
#

Do you have members intent or not

stone beacon
vale wing
#

!d discord.Intents.members

maiden fable
# stone beacon How's game dev working for ya

It's fine haha. Didn't really had much motivation to continue that game since there were many clones, so working on a machine learning ebook API for a month now, with a friend of mine

stone beacon
#

discord.User does not have an add_role() method you'd want discord.Member for that

vale wing
loud junco
#

so i change await message.author.add_roles(role)?

vale wing
#

Or if lib smokes grass (it sometimes does)

stone beacon
vale wing
stone beacon
loud junco
#

bot = commands.Bot(command_prefix = prefixxx, case_insensitive=True, activity=discord.Game(name="RPM", type=3))
u mean this?

maiden fable
vale wing
#

Oh you have no intents

loud junco
#

:/

vale wing
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

loud junco
#

i copy this?

intents = Intents.default()
intents.members = True
#

and import the intents thing

vale wing
#

Yes

#

And add the intents kwarg

#

And enable it on developer portal

loud junco
#

huh

vale wing
#

You'd better read everything

loud junco
loud junco
#

gg

vale wing
#
bot = commands.Bot(..., intents=intents)```
loud junco
#

oo okok

loud junco
#

which one

vale wing
loud junco
#

i enabled all

vale wing
#

Logic πŸ€”

loud junco
#

and still got the same error

vale wing
#

Tbh it shouldn't really matter, you don't need presence for example

jade tartan
#

How do i make it have a new line?

vast gale
#

i hate merge conflicts

jade tartan
#

How do i make it have a new line?

placid skiff
#

wdym?

tawdry perch
vale wing
vast gale
#

lol

#

this was master having changes that the pr wasn't up to date with

#

had to merge master into the pr

slate swan
vale wing
#

Ah

#

Then resolve them?

vast gale
#

i did

#

just annoying and time consuming

placid skiff
vale wing
#

Always pull when you are going to edit code πŸ˜‰

slate swan
vast gale
#

btw disnake master now has perms v2 support

slate swan
#

..

#

Lol

vast gale
#

:(

vale wing
#

When you got no cpu

stone beacon
#

Lowkey gonna add that feature tmr

#

Why did I not think of that

slate swan
stone beacon
#

lmao

#

How much ram do you even got?

vale wing
#

3gb

stone beacon
#

Mine uses dead 69 mb of ram

placid skiff
stone beacon
#

cpu doesn't cross that 5% even when doing multiple img processing

vast gale
stone beacon
#

Gotta stress test that though

vale wing
#

I host bots on samovar no cap

stone beacon
#

Loving that wood floor

vale wing
#

I made it open source

placid skiff
#

Cool

vale wing
#

And it's in 27 guilds

vast gale
#

my dev bot uses 86 mb of ram in one guild

#

and my public bot uses around 95mb

#

which is in 100 guilds

vale wing
#

My public bot that I can't run because of stupid slash commands consumes like 300 mb

stone beacon
#

I rmr my conversion to slash commands

stone beacon
#

Oh boy

#

Those were some memories

vale wing
#

And I am too lazy to rewrite it rn because it was literally based on messages

#

Also it has many constructions that I have found a better approach to so I am feeling cringe when working with it

stone beacon
#

Thankfully I only had to remake my decorator to convert most of my commands to slash

#

So that saved me alot of pain

vale wing
#

Understandable

placid skiff
#

If i'm gonna open one of my school project now probably i'd punch me so hard

vale wing
#

Aias has perfect stuff tho I haven't found anything to improve except I might have to bring the database version control stuff out somewhere

stone beacon
#

Rn I'm tryna make a way to internally test all my commands by using a fake discord connect of sort that's gonna supply fake user info etc

#

It seems really pointless, but I'm bored

vale wing
#

Ah yes that's a cool idea

junior orbit
#
Traceback (most recent call last):
  File "bot.py", line 266, in <module>
    client.run(TOKEN, bot=True, reconnect=True)
  File "/home/runner/NugSec/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/runner/NugSec/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/runner/NugSec/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/runner/NugSec/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/home/runner/NugSec/venv/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/runner/NugSec/venv/lib/python3.8/site-packages/discord/http.py", line 216, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): <!DOCTYPE html>

Just got hit with this out of the blue. Been running fine for ages. No changes done.
Any thoughts on what happened? Tried resetting the token, but same result. Sadge

slate swan
slate swan
#

πŸ˜” I'm just too dumb

slate swan
vast gale
#

!d disnake.ext.commands.default_member_permissions

unkempt canyonBOT
#

@disnake.ext.commands.default_member_permissions(value=0, **permissions)```
A decorator that sets default required member permissions for the command.
Unlike [`has_permissions()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.has_permissions "disnake.ext.commands.has_permissions"), this decorator does not add any checks.
Instead, it prevents the command from being run by members without *all* required permissions,
if not overridden by moderators on a guild-specific basis.

See also the `default_member_permissions` parameter for application command decorators...
slate swan
#

nice

slate swan
vast gale
#

πŸ‘€

slate swan
#

and, is there a way to get the total number of messages of a member in a server?

vast gale
#

which lib

slate swan
vast gale
#

its not

slate swan
#

hm ic

visual island
slate swan
visual island
#

It can actually get ~5000 messages per second, without getting global ratelimited cause discord.py handles the endpoint's ratelimit (I'm sure hikari handles that too).

#

but yeah, not ideal

vale wing
#

Fetching is expensive procedure yk

placid skiff
maiden fable
maiden fable
slate swan
slate swan
placid skiff
#

lil Ash fell for ya

slate swan
#

I- ||can't deny nor accept||

jade tartan
slate swan
#

@slate swan another issue πŸ˜”

#

why does

@lightbulb.option(name="member", required=True, type=hikari.Member)

return a UserImpl object instead of a Member object

jade tartan
#

Can someone help

#

?

slate swan
placid skiff
jade tartan
#

nvm i got it

supple thorn
#

We just point out names that should be uwu in ashley's code at this point

dull terrace
#

Someone needs to put their code through owofier and see if it still works

slate swan
placid skiff
#

Oh
Hostility

supple thorn
dull terrace
#
@cwient.swash_command(name=swash_command_wob, descwiption="rob someone's coin.")
async def wob_coin(message, victim: disnake.Membew):
    if victim is none ow await coowdown_check(message) ow shuwtdown:
        wetuwwn
    pwayew = await uwsew.fetch(message)

    if pwayew.id == victim.id:
        content = "https://c.tenow.com/rhotix9uj30aaaac/pwayed-uwsewf-dj-khawed.gif"
        await message.send(content=content, ephemewaw=twuwe)
        wetuwwn

    ewif pwayew.stowen is not none and pwayew.stowen < time_stamp:
        content = f"youw've awweady stowen fwom someone today {message.auwthow.name}"
        await message.send(content=content, ephemewaw=twuwe)
        wetuwwn
    pwayew.stowen = time_stamp + (24 * 60 * 60)
#

wetuwwn

#

what's the code you're using

jade tartan
#

Do you guys have buttons in cogs form?

dull terrace
#

time_stamp = datetime.now().timestamp()

slate swan
dull terrace
#
from datetime import datetime 
future_time = datetime.now().timestamp() + (60 * 60 * 24)

if future_time <= datetime.now().timestamp():
    print("future time is now")
#

if you want one day in the future

slate swan
#

also, the member.joined_at returns a datetime.datetime object, how can I subtract it from datetime.datetime.now?

dull terrace
#

i think you could use the delta thing

placid skiff
#
@command()
async def countdown(ctx):
start = 60
while t>0:
  mins, secs = divmod(start, 60)
  timer = "f{mins}:{secs}"
  await ctx.send(timer)
  await asyncio.sleep(1)
  start-=1
slate swan
#

you will get a timedelta object

slate swan
#

datetime.utcnow() - member.joined_at and this is what im doing

slow fog
slate swan
#

ah I see

#

thanks a lot

#

oops my typos

paper sluice
#

.topic

lament depotBOT
#
**What commands/features are you proud of making?**

Suggest more topics here!

jade tartan
#

Extension 'cogs.ticket' raised an error: ModuleNotFoundError: No module named 'discord.ui' I have installed this module and have imported it

#

And it shows this

slate swan
dull terrace
potent spear
dull terrace
#

That thing is an absolute mess in terms of code, my first python project, I'm shocked it's ran without any errors on an Amazon server for months

potent spear
#

you just surpressed the errors, that's a different story

loud junco
slate swan
#

πŸ˜‚

loud junco
#
intents = discord.Intents.all()
intents.members = True
prefixxx = ['rpm ', 'Rpm ', 'RPM ', 'RPm ']
bot = commands.Bot(command_prefix = prefixxx, case_insensitive=True, activity=discord.Game(name="RPM", type=3), intents=intents)
potent spear
slate swan
loud junco
#
@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = bot.get_user(user) or await bot.fetch_user(user)
    hehehe = hehehe.id
    db[f'{hehehe}cooked_pogchop'] += 42
    db[f'{hehehe}voteCount'] += 1

    voteCount = db[f'{hehehe}voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    await message.author.add_roles(role)
  await bot.process_commands(message) 
loud junco
#

...

slate swan
#

the comamnd was used in dms

loud junco
potent spear
#

aight, it's just get_member

#

guild.get_member

loud junco
#

huh

jade tartan
#

?

potent spear
jade tartan
#

pip install discord.py

loud junco
slate swan
#

only if you're hosting something good on it πŸ˜”

loud junco
#

huh

potent spear
loud junco
#

i just need to take the userid why do i need to add so many thing ;-;

loud junco
potent spear
potent spear
loud junco
loud junco
potent spear
dull terrace
loud junco
#

i like this froggy

potent spear
#
@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    user_id = message.author.id
    db[f'{user_id}cooked_pogchop'] += 42
    db[f'{user_id}voteCount'] += 1

    voteCount = db[f'{user_id}voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    member = message.guild.get_member(message.author.id)
    await member.add_roles(role)
  await bot.process_commands(message)```
loud junco
#

ok thanks

#

and one more hehehe lol

potent spear
#

also, a json isn't a db

loud junco
#

i change it myself thanksss

loud junco
potent spear
potent spear
loud junco
#

but replit doesnt have other choice

potent spear
supple thorn
#

You can use sqlite3 for your database

#

Rather than json

supple thorn
paper sluice
#

self host is the best 😳

placid skiff
#

pretend that you are a bot and execute users command is the best

paper sluice
#

thats self bot, thats against tos 😳

loud junco
potent spear
loud junco
#

erm

loud junco
#

not even error

#

its a vote reward webhook btw

#

not a command

scarlet aurora
#

is it possible to run my bot commands from the terminal it's hosted on so no one can know who ran the command??

potent spear
loud junco
#

u code u gave me

potent spear
#

show me

loud junco
#

and i keep thinking ur pfp is a panda

loud junco
#
@bot.event
async def on_ready():
  print('We have logged in as {0.user}'.format(bot))
bot.remove_command('help')

@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    user_id = message.author.id
    db[f'{user_id}cooked_pogchop'] += 42
    db[f'{user_id}voteCount'] += 1

    voteCount = db[f'{user_id}voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    member = message.guild.get_member(message.author.id)
    await member.add_roles(role)
  await bot.process_commands(message)
loud junco
potent spear
#

@devout summit his is

loud junco
scarlet aurora
paper sluice
#

it is

scarlet aurora
#

how

paper sluice
#

!d input 😳

unkempt canyonBOT
#

input([prompt])```
If the *prompt* argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "EOFError") is raised. Example:

```py
>>> s = input('--> ')  
--> Monty Python's Flying Circus
>>> s  
"Monty Python's Flying Circus"
```  If the [`readline`](https://docs.python.org/3/library/readline.html#module-readline "readline: GNU readline support for Python. (Unix)") module was loaded, then [`input()`](https://docs.python.org/3/library/functions.html#input "input") will use it to provide elaborate line editing and history features.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `builtins.input` with argument `prompt` before reading input...
slate swan
#

how is that going to help

scarlet aurora
#

i know input, but how do i make it so that it will run the bot commands

slate swan
paper sluice
#
@command.command
async def run(...):
    code = input('enter: ...')
    # code to run
scarlet aurora
slate swan
#

you'd have to do !run

#

then use the terminal

scarlet aurora
#

i'm asking how to run commands from terminal, not chat

slate swan
#

yes, and doing it all straight from the terminal is not possible

scarlet aurora
#

r u sure about that

slate swan
#

how would discord.py know which channel to send commands in

potent spear
#

this will block your code

scarlet aurora
#

u would input the channel id

slate swan
potent spear
#

if you want to run user input, use the wait_for method

slate swan
slate swan
scarlet aurora
#

of the said bot

slate swan
#

that's not how it works

scarlet aurora
#

oh

slate swan
#

discord.py isn't built with this kind of functionality

#

you're gonna have to hack away at the entire library

scarlet aurora
#

well i will do so

#

it's not like its against tos

slate swan
#

it's not but, i sure hope you know how to do that

#

jesus why can't you just

#

run an eval command and delete it

scarlet aurora
#

code was meant to be degraded and rebuilt

#

and forget ctx, that wont work because it would require text on a channel

#

i just want to be able to run a command from terminal

slate swan
scarlet aurora
slate swan
#

you're gonna have to send the payloads to the discord api manually

scarlet aurora
slate swan
#

do you not understand what that means

scarlet aurora
#

i do understand what it means

#

and i am willing to if it will acquire my sucsess in what i intend to do

#

from when i entered this channel

slate swan
#

you're gonna have to learn the entire structure of this library which you know basically nothing about

scarlet aurora
#

ok

#

i can learn

slate swan
#

then you're gonna have to find a way, god knows how, to entirely disable stdout blocking, basically getting rid of your ability to ever print anything on the terminal again

#

and then send requests to the discord api manually, which you're gonna have to learn how to structure

scarlet aurora
#

thanks for your help, i do not require further assistance

#

πŸ‘

slate swan
#

funny way of saying, "i don't know what im doing" but okay

scarlet aurora
#

would u look at what i just found

#

πŸ™‚

cobalt jacinth
#

whats the best way to add button interactions in discord.py

scarlet aurora
slate swan
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
cobalt jacinth
slate swan
#

yes

cobalt jacinth
#

whats the process to update ? i cant find pip command

supple thorn
slate swan
#

^ git must be installed

supple thorn
#

^

cobalt jacinth
#

ok thanks

loud junco
#

help?

#
@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    user_id = message.author.id
    db[f'{user_id}cooked_pogchop'] += 42
    db[f'{user_id}voteCount'] += 1

    voteCount = db[f'{user_id}voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    member = message.guild.get_member(message.author.id)
    await member.add_roles(role)
  await bot.process_commands(message)
```not working at all ;-; not even error
sullen pewter
#

Should I learn first class functions?

loud junco
#

no error

supple thorn
loud junco
#

gg

#

its a webhook vote reward btw

sullen pewter
supple thorn
#

What's that

#

There's a economy class functions?

sullen pewter
#

It's a record storing a function together with an environment

loud junco
#

alright

loud junco
# slate swan whats the issue now?

imma change back to

@bot.event
async def on_message(message) :
  if message.channel.type == discord.ChannelType.private:
    return
  if message.channel.id == 970895283250675813 :
    data = message.content.split(" ")
    user = re.sub("\D", "", data[4])
    hehehe = bot.get_user(user) or await bot.fetch_user(user)
    hehehe = hehehe.id
    db[f'{hehehe}cooked_pogchop'] += 42
    db[f'{hehehe}voteCount'] += 1

    voteCount = db[f'{hehehe}voteCount']
    if voteCount < 10:
      role = message.guild.get_role(971310924478705695)
    elif voteCount < 18:
      role = message.guild.get_role(971310601668288512)
    elif voteCount < 69:
      role = message.guild.get_role(971311031555072020)
    elif voteCount < 100:
      role = message.guild.get_role(971311323658977281)
    elif voteCount < 420:
      role = message.guild.get_role(971311024051486742)
    elif voteCount >= 420:
      role = message.guild.get_role(971311028694577162)
    else:
      role = message.guild.get_role(905626727005454457)
    await message.author.add_roles(role)
  await bot.process_commands(message) 
sullen pewter
#

wikipidea

loud junco
#

now its worse

sullen pewter
# supple thorn What

A closure is an inner function that remembers and has access to variables in the local scope in which it was created even after the outer function has finished executing

potent spear
loud junco
potent spear
loud junco
potent spear
#

that's your hosting service or whatever, not your actual bot

loud junco
#

its a webhook so i use the send test thing

potent spear
placid skiff
#

Bruh you are talkin about programming terms here where 70% of people doesn't even know the difference between a method and a parameter lol

potent spear
#

just test it like a normal dev

loud junco
#

huh?

#

its a webhook

potent spear
#

no experience with that, I'd just send a msg in the channel to test ig

loud junco
#

argument and parameter is still ok

loud junco
#

its not a command ;-;

slate swan
#

why is it named on_message.

supple thorn
loud junco
#

what is csrf token

loud junco
placid skiff
slate swan
supple thorn
#

Just say decorator

slate swan
unkempt canyonBOT
supple thorn
#

Why make it harder for people to understand

slate swan
#

just use this.

loud junco
#

ok

slate swan
#

it will add an on_dbl_vote event

loud junco
placid skiff
#

I don't think so

supple thorn
#

I hope you're right

loud junco
#

what is csrf token

placid skiff
paper sluice
# loud junco what is csrf token

Cross-Site Request Forgery (CSRF) is an attack that forces authenticated users to submit a request to a Web application against which they are currently authenticated. CSRF attacks exploit the trust a Web application has in an authenticated user.

loud junco
#

ok

#

thanks

slate swan
#

basically the token you get from that site

slate swan
paper sluice
#

i have given so much data to google, the search optimization is ok_handbutflipped

potent spear
loud junco
jade tartan
# potent spear `pip install -U git+https://github.com/Rapptz/discord.py` thank me later
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 8, in <module>
    from discord_components import DiscordComponents 
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\__init__.py", line 1, in <module>
    from .client import *
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\client.py", line 12, in <module>
    from .component import Component
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\component.py", line 3, in <module>
    from discord import PartialEmoji, Emoji, InvalidArgument
ImportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py)``` Whats next?
slate swan
#

lmouse

supple thorn
slate swan
slate swan
jade tartan
#

So?

#

Hello i think i got misplaced

stiff gorge
#

my bot is online but its not responding to any cmnd and there is no error in console how can i fix this ??

jade tartan
#

Try and print it and see what happens

stiff gorge
#

after installing dpy 2.0 all this problems started

slate swan
stiff gorge
#

it does print think

slate swan
#

Think..? I recommend u to confirm rather than assuming

jade tartan
slate swan
#

Lmfao

stiff gorge
#

ik

stiff gorge
slate swan
stiff gorge
#
@bot.event
async def on_ready():
  await bot.change_presence(activity=discord.Streaming(name='Sea of Thieves', 
  url='https://www.twitch.tv/'))
  #print('Connected to bot: {}'.format(bot.user.name))
  #print('Bot ID: {}'.format(bot.user.id))
  print("Bot is Online")
cobalt jacinth
#

in dpy 2.0 intents must be turn on ?

slate swan
#

As per code above ^^^

jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 8, in <module>
    from discord_components import DiscordComponents 
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\__init__.py", line 1, in <module>
    from .client import *
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\client.py", line 12, in <module>
    from .component import Component
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\component.py", line 3, in <module>
    from discord import PartialEmoji, Emoji, InvalidArgument
ImportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py)```
What's next?
#

So

slate swan
#

Assuming what sarth said..

#

Did u enable intent?

jade tartan
stiff gorge
#

it still dosent wrk

stiff gorge
#

it just says bots online but dosent respond

#

and the status of the bot is shown

jade tartan
#

DId you close the code and reopened?

stiff gorge
#

i restarted

jade tartan
#

did you import the right module?

slate swan
stiff gorge
#

wht all r required ?

slate swan
slate swan
jade tartan
slate swan
#

....

jade tartan
#

What should i do for my code error?

slate swan
#

Sarth suggested to enable message intent

#

Did u try to enable and try? @jade tartan

jade tartan
# slate swan Did u try to enable and try? <@506940530333057025>
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 8, in <module>
    from discord_components import DiscordComponents 
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\__init__.py", line 1, in <module>
    from .client import *
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\client.py", line 12, in <module>
    from .component import Component
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\component.py", line 3, in <module>
    from discord import PartialEmoji, Emoji, InvalidArgument
ImportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py)```
slate swan
#

I asked did u enable the intent

#

Not asking the error

#

Answer my question lmfao

jade tartan
#

i know

#

but it has nothing to do with intent but yes i have enabled in developer and in code

slate swan
#

Owo I see πŸ€”

#

Did u Google about your error?

stiff gorge
#

where can i paste my code to show ?

slate swan
#

!paste @stiff gorge

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.

stiff gorge
#

@slate swan is the code seen ?

jade tartan
#

Well i think it means that from discord import PartialEmoji, Emoji, InvalidArgument~i need to import this modules =but it still wont work

jade tartan
#

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

stiff gorge
# jade tartan ``client = commands.Bot(command_prefix = '!', intents = intents) ``

after doing this i get a error

Traceback (most recent call last):
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 924, in _load_from_module_spec
    await setup(self)
  File "/home/runner/mv/cogs/help.py", line 76, in setup
    await bot.add_cog(Help(bot))
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 760, in add_cog
    cog = await cog._inject(self, override=override, guild=guild, guilds=guilds)
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/cog.py", line 563, in _inject
    raise e
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/cog.py", line 557, in _inject
    bot.add_command(command)
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 226, in add_command
    super().add_command(command)
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1262, in add_command
    raise CommandRegistrationError(command.name)
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.

The above exception was the direct cause of the following exception:
#
Traceback (most recent call last):
  File "main.py", line 133, in <module>
    asyncio.run(main())
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "main.py", line 121, in main
    await bot.load_extension('cogs.help')
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 990, in load_extension
    await self._load_from_module_spec(spec, name)
  File "/home/runner/mv/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 929, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.help' raised an error: CommandRegistrationError: The command help is already an existing command or alias.
cobalt jacinth
#

i just upgraded to dpy 2.0 and the bot doesnt respond to any command now. i went through the breaking changes and i dont see anything that should cause that.

jade tartan
#

Well it says it right there dude The command help is already an existing command or alias.

stiff gorge
#

there is no 2 cmnd

#

i checked the cogs name is help and the cmnd name is help

#

is this the reason ?

jade tartan
jade tartan
cobalt jacinth
#

what does this mean ?

jade tartan
#

and then restart the code

stiff gorge
#

ok

slate swan
#

its a kwarg used while selfbotting in 1.7.3...

stiff gorge
cobalt jacinth
#

hmmm i am not sure why the bot will not respond to commands now although its running with any error

sage otter
slate swan
#

message_content intents.

jade tartan
stiff gorge
stiff gorge
spring flax
loud junco
stiff gorge
#

is this the problem ?

    @commands.group(name='help',invoke_without_command=True)
    @commands.cooldown(1, 5, commands.BucketType.user)
    async def help(self, ctx):
      embed0 = discord.Embed(title='__HELP COMMAND__',
                          description=f'Type `{prefix}help <page>` To get help about specific  command',color=0xFFDF00)
      embed0.add_field(name='Page  1',
                        value='```Fun Commands```\n')
      embed0.add_field(name='Page  2',
                        value='```Image Commands```\n')
      embed0.add_field(name='Page  3',
                        value='```Information Commands```\n')
      embed0.add_field(name='Page  4',
                        value='```Rank Commands```\n')
      embed0.add_field(name='Page  5',
                        value='```Economy Commands```\n')
      embed0.add_field(name='Page  6',
                        value='```Bot Infrmation```\n')
      embed0.set_footer(text='Page (0/1)')
      await ctx.send(embed=embed0)

this is the first help cmnd

    @help.command(name='1',aliases=['Information','information','info'])
    async def pg_one(self, ctx):
        embed = discord.Embed(color=0x2f3136)
        embed.add_field(name=f'**:Information:・Information Commands ** ',value= "\n **` 1 ` Fact** - Its just a fact bro.""\n" 
"**` 2 ` Joke** -  See some funny jokes.""\n"                                         "**` 3 ` Weather** - To confine someone to a coffin.""\n"
"**` 4 ` Insult** -  Delivers a insulting message.",inline=False)
        embed.set_footer(text='Page (1/8)') 
        await ctx.send(embed=embed)

this is the last one

spring flax
# loud junco its sleeping

so ```py
Traceback (most recent call last):
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1343, in on_application_command_autocomplete
await self.process_app_command_autocompletion(interaction)
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1261, in process_app_command_autocompletion
await slash_command._call_relevant_autocompleter(inter)
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/ext/commands/slash_core.py", line 549, in call_relevant_autocompleter
await inter.response.autocomplete(choices=choices)
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/interactions/base.py", line 1051, in autocomplete
await adapter.create_interaction_response(
File "/pufferpanel/.local/lib/python3.10/site-packages/disnake/webhook/async
.py", line 216, in request
raise HTTPException(response, data)
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.choices.6.name: This field is required

This is error and code is ```py
        
    @build.autocomplete("gun")
    async def build_autocomplete(self, inter, option) -> typing.List[str]:
        _all = await get_weapons(inter)
        if option in _all:
            return [option]
        matches = fuzzy_match(option, _all, n=10)
        return [match for match in matches if match]
jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 8, in <module>
    from discord_components import DiscordComponents 
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\__init__.py", line 1, in <module>
    from .client import *
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\client.py", line 12, in <module>
    from .component import Component
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_components\component.py", line 3, in <module>
    from discord import PartialEmoji, Emoji, InvalidArgument
ImportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py)``` How do i fix this?
jade tartan
#

ReInstall what?

maiden fable
#

Dpy

spring flax
maiden fable
#

Prolly the option isn't in the list?

#

Idrk...

#

Sorry, never used autocomplete

spring flax
#

the annoying part is that it's not ignoring the error with ```py

@commands.Cog.listener()
async def on_slash_command_error(self, inter, error):
    if isinstance(error, disnake.HTTPException):
        return
    else:
        print(error)
jade tartan
#

Whats the installation module for discord ui?

cobalt jacinth
spring flax
#

maybe it's coming from here? ```py
_all = await get_weapons(inter)
if option in _all:
return [opti

stiff gorge
#

now again my bot has cm online but not responding

loud junco
#

what is dbl in full

vocal plover
#

hm?

jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\ticket.py", line 3, in <module>
    from discord.ui import Button, View
ModuleNotFoundError: No module named 'discord.ui'```
jade tartan
cobalt jacinth
#

whats this warning about ?

vale wing
#

Probably because of no proper typehints

loud junco
vale wing
#

You can try typehinting channel: discord.TextChannel = ... also you don't need description kwarg in your embed as it's empty

cobalt jacinth
#

didnt used to get warning in dpy 1.7....after ugrading to 2.0 getting it.

vale wing
#

And yeah get the channel by its id for god's sake this is not the case for utils.get

slate swan
slate swan
loud junco
vale wing
loud junco
#
class TopGG(commands.Cog):
  def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token'  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
    
  @commands.Cog.listener()
  async def on_dbl_vote(self, data):
    if message.channel.type == discord.ChannelType.private:
      return
    if message.channel.id == 970895283250675813:
      data = message.content.split(" ")
      user = re.sub("\D", "", data[4])
      hehehe = bot.get_user(user) or await bot.fetch_user(user)
      hehehe = hehehe.id
      db[f'{hehehe}cooked_pogchop'] += 42
      db[f'{hehehe}voteCount'] += 1
  
      voteCount = db[f'{hehehe}voteCount']
      if voteCount < 10:
        role = message.guild.get_role(971310924478705695)
      elif voteCount < 18:
        role = message.guild.get_role(971310601668288512)
      elif voteCount < 69:
        role = message.guild.get_role(971311031555072020)
      elif voteCount < 100:
        role = message.guild.get_role(971311323658977281)
      elif voteCount < 420:
        role = message.guild.get_role(971311024051486742)
      elif voteCount >= 420:
        role = message.guild.get_role(971311028694577162)
      else:
        role = message.guild.get_role(905626727005454457)
      await message.author.add_roles(role)
    await bot.process_commands(message)
```am i doing this correctly?
slate swan
#

tias

loud junco
#

?

slate swan
#

use the on_dbl_test event

loud junco
#

huh

slate swan
stiff gorge
vale wing
#

I'd just do raw requests πŸ˜€

spring flax
vale wing
#

Who needs those libs

spring flax
#

isn't that mostly for commandinvoke errors?

loud junco
slate swan
loud junco
#

cuz message is undefined

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

cobalt jacinth
#

doing ctx.channel.send() solved it

vale wing
slate swan
loud junco
loud junco
spring flax
slate swan
#

how is a voting event related to a message??

loud junco
slate swan
#

use get_user to get your user and use User.send to send the message to urself

loud junco
vale wing
loud junco
#

its here already

jade tartan
#

Hello any one

vale wing
#

Hi

spring flax
#

terminal

stiff gorge
slate swan
vale wing
#

@spring flax try to print the type of received exception and see what it says

vale wing
#
print(type(error))```
spring flax
#

where do you want me to do that?

vale wing
#

In your handler

slate swan
#

i dont think HTTPExceptions like missing permissions can be traced using error handler

vale wing
#

Depends where they occur

#

Any exception from the command gets wrapped into CommandInvokeError (or whatever it's named idr) and goes to the error handler

stiff gorge
# slate swan show where you enabled it
import os
import json
import asyncio
import discord
import platform
import keep_alive
from discord import Intents
from datetime import datetime
from discord.ext import commands
print("Discord Version:",discord.__version__)
print("Python Version:", platform.python_version())
from discord.ext import tasks ,commands
intents = discord.Intents.default() 
intents.members = True
vale wing
#

Totally enabled

supple thorn
#

Lmfao

stiff gorge
#

bot = commands.Bot(command_prefix = 'm!', intents=intents)
vale wing
#

Still totally enabled

supple thorn
vale wing
#

You need messages content intent as well

supple thorn
#

Not message_content and messages

slate swan
#

where image?

slate swan
slate swan
# slate swan
#coin
    @commands.command()
    async def coin(self, ctx):
        responses=["Heads", "Tails"]
        responses=random.choice(responses)
        emb=discord.Embed(title="Coin Toss", description=":coinnn:flipping a coin...", colour=discord.Color.gold())
        emb.set_thumbnail(url="https://cdn.discordapp.com/attachments/960489755114622988/971313164681609266/1651647646817.png")
        emb.add_field(name="Answer:", value=f"`{responses}`")
        await ctx.reply(embed=emb)```
slate swan
supple thorn
vale wing
vale wing
#

Currently there are almost 12k samples, 4,5k validated and only 150 of them are spam

supple thorn
vale wing
#

Well how do you label a message as spam

supple thorn
#

When there's multiple messages of the same thing

#

In a short period of time

#

But how are you labeling each message as spam

unkempt canyonBOT
#

utils/processors/messages.py lines 59 to 64

queue = self.add(message)
if queue == False:
    return False

full_content = " ".join([m.content for m in queue])
if is_spam(full_content):```
vale wing
#

I just join their content

#

If you meant that

hushed galleon
supple thorn
hushed galleon
#

afaik no, which seems kind of weird

spring flax
#

no I mean not with an error handler, just anything to stop the error

hushed galleon
#

well try what i said, print the list and look for strings that discord wouldnt accept

spring flax
#

so I'm trying to repro the error on my test bot and it's not coming up, not sure why it's coming in the first place

boreal ravine
#

Read the select menu examples on the repository

slate swan
#

!d discord.ext.tasks.loop

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/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
#

autosend as in sending the message every once in a while, right?

#

you'd need something like

from discord.ext import tasks

@tasks.loop(hours=...)
async def auto_send():
  channel = Bot.get_channel(...)
  await channel.send(...)
rare saddle
#

How to display a list of servers on which a people is an administrator, as in JuniperBot or MEE6

slate swan
#

.........

vale wing
#

No copypasting πŸ˜€ πŸ‘

slate swan
#

yes

#

yes its the same, since its a fork

vale wing
#

Just figure it out

#

You decorate a function and turn it into the Loop and then you start the loop

slate swan
#

sure, you could use git and github

#

replit?

vale wing
#

VSC live share

slate swan
#

nvm

vale wing
#

Best thing

#

Pycharm also has stuff like that

#

Github has their "shared workspaces" but they are not free afaik

slate swan
#

Idk I forgot

#

Live share or smthing

vale wing
#

Open visual studio code and search "live share" in extensions

slate swan
#

And download it

#

Than restart vscode

vale wing
#

Its interface is intuitively figureable

#

He needs that extension too

#

Or he can join from browser but it's cringe imo

cobalt jacinth
#
@bot.command(name='ac',  help='commands prefix')
async def asdasdsd(ctx):
    button = Button(label="click me!",style=discord.ButtonStyle.success)
    view = View()
    view.add_item(button)
    await ctx.send("hi",view=view)
#

i am getting this

vale wing
#

It has no callback

#

Look at the components examples in the library repo

#

You should subclass views or create some classes for easier management

#

There should be its tab and a button "start collaboration session" or smth

#

Did you restart the vsc

cobalt jacinth
boreal ravine
slate swan
vale wing
#

Strings conversion?

slate swan
# vale wing Strings conversion?

calculation of time period, like I wanna get the time when the user joined the guild and was removed, But there's just a lot of errors trying to get that timespan

vale wing
#

Just datetime.now() - user.joined_at?

slate swan
#

just a min

#

did you use .joined_at.astimezone()?

vale wing
#

No

slate swan
slate swan
slate swan
# slate swan same error?

idk, it should be returning just hours, its returning days and stuff, i'll get the code and ouput in a sec

#

alright

slate swan
# slate swan show code
_join_date = member.joined_at
delta = timedelta(hours=0)
Timezone = timezone(delta, "UTC")
join = _join_date.astimezone(Timezone)
join_span =  (datetime.utcnow().astimezone(Timezone) - join)

output - 70 days, 0:39:03.046215

#

..

#

idk if I'm using astimezone the wrong way

#

the days is correct right?

slate swan
#

i see

#

brb, i need to test it

slate swan
#

i think i figured it out

#

thanks uwu

#

πŸšΆβ€β™‚οΈ me who uses timestamps

#

100 iq

slate swan
#

Lol

slate swan
slate swan
slate swan
supple thorn
slate swan
#

why R

slate swan
#

Are there more?

#

!e py print(f"<t:{int(__import__('datetime').datetime.now().timestamp())}:R>

supple thorn
slate swan
#

What does R stands for

stray carbon
#
    async def afkcheck(ctx) -> bool:
        async with ctx.bot.afkdb.cursor() as cursor:
            await cursor.execute('SELECT role FROM afkrole WHERE guild = ?', (ctx.guild.id,))
            data = await cursor.fetchone()
            if data:
                if data[0] in ctx.author.roles:
                    return True
                else:
                    return False
            else:
                return True
        await ctx.bot.afkdb.commit()

returned false even when i took the required role

slate swan
slate swan
#

oh

supple thorn
slate swan
#

Thanks

slate swan
stray carbon
#

oh gotcha

slate swan
stray carbon
#

thanks

#

yup yup ty

slate swan
#

it updates automatically

#

Nvmd I got it

slate swan
#

sparky never fails to make me feel like im talking to myself

#

.lol