#discord-bots

1 messages · Page 44 of 1

silk fulcrum
#

lshw or lshw -short for a short version

#

there should be memory

#

also you can use htop to see memory

glad cradle
#

isn't there also top?

glad cradle
junior verge
#

what would the command be though

hard hinge
silk fulcrum
hard hinge
#

Ah 🙂

silk fulcrum
#

btw there is also lsblk -a but there is usually no ram param

pliant gulch
pliant gulch
#

nvtop

silk fulcrum
#

oh nvtop

pliant gulch
#

For Nvidia and AMD

silk fulcrum
#

well you still have to install it

#

and htop is built-in

pliant gulch
#

Not for arch

#

I had to install htop

silk fulcrum
#

his vps is using ubuntu

slate swan
#

gotop 🐈

silk fulcrum
pliant gulch
#

For VPS's I would've probably done something like open suse

#

Actually ubuntu is a good choice too

silk fulcrum
#

isnt it the best

slate swan
silk fulcrum
#

hm, no debian is probably better ig

slate swan
#

ubuntu is debian based

silk fulcrum
#

ik

primal token
#

alpineducky_beer

silk fulcrum
#

i wanted to react with a duck

pliant gulch
#

If you need something robust, and something for a team of people fedora would probably be the optimum

#

Etc, etc with different parameters

#

Their all good, as long as it's not windows 💀

#

And counted, proper securing of the server takes place

silk fulcrum
primal token
pliant gulch
slate swan
#

i prefer debian bases distros, seems easier to use than arch and redhat

sick birch
pliant gulch
#

The only popular games I cannot play are ones that use EAC

silk fulcrum
slate swan
#

*#ot3-discord-bots

pliant gulch
#

I don't do much maintenance on it cause It's all setup to be automatic when I installed

#

So it's kind of like, set it and forget it

#

Although I do need to clean my packages

slate swan
#

the installation process tho 💀

pliant gulch
#

I installed it in like 2-3 minutes not including compiling time

#

The wiki is very easy to understand

silk fulcrum
#

@pliant gulch imagine playing only online games and minesweeper (my situation)

pliant gulch
#

If you can't setup wine just install steam and use compatability mode

#

You can also just install lutris as well

silk fulcrum
silk fulcrum
primal token
#

:kekw:

pliant gulch
#

But doesn't lutris automatically set it up for you?

#

Also there is a lot of free steam games

silk fulcrum
pliant gulch
#

Are you on ubuntu bare metal?

silk fulcrum
silk fulcrum
#

oh... no

pliant gulch
#

Are you on a VM

#

Or are you on "bare" metal

silk fulcrum
#

no

#

what

pliant gulch
#

Okay nevermind

#

Anyways if you really that desperate you can try to setup a KVM and then use GPU passthrough

#

Basically a VM but not that slow cause of GPU passthrough

#

Enough to allow you to play games

silk fulcrum
#

wth 😳 all that to play games

pliant gulch
#

Blame the game developers

silk fulcrum
#

I'll just continue playing fly or die and minesweeper

pliant gulch
#

In unity all you do is press a setting IIRC to allow linux compatibility when building 💀

silk fulcrum
#

🔪

#

unforgivable

robust fulcrum
#

Guys like i use a command called ?test so i want that when i use it the bot deletes the message
How can I do that?

slate swan
#

ctx.message.delete

#

can someone explain the pros of using cogs

primal token
#

modular extensions

#

they can also be disconnected and edited and connected again uppon run time

shrewd apex
#

cleaner and organised code

primal token
#

depends😳

shrewd apex
#

also ur help command can be made categorical using cogs

#

just don't make mixed bag commands for cogs

slate swan
#

if you are learning python just to make.bots, you get to learn more about OOP

#

imagine learnig python for just bots

shrewd apex
pliant gulch
#

The modularity of cogs are great

#

Means people can upload standalone cogs to GitHub, PYPI etc

#

And have it work when people install and load it

#

Granted, unless some extra setup is required like setting variables

sage otter
#

as seen with redbot

slate swan
#

make them use environment variables 🐈

slate swan
frigid python
#

jishaku is a great cog too

slate swan
#

agreed

slate swan
#

damn

#

can someone link me to a good cogs tutorial

#

what library are you using rn?

#

most recent

frigid python
#

thsi is the one on their docs, try it

shrewd apex
frigid python
#

yeah i dont think you can find any dpy yt tutorial

#

most of them are out of date

shrewd apex
#

^^ no 2.0

frigid python
silk fulcrum
frigid python
ionic edge
#
 discord.http We are being rate limited. PUT https://discord.com/api/v10/applications/1010174873236156446/guilds/1008758498789695508/commands responded with 429. Retrying in 16.05 seconds.
shrewd apex
#

sed

slate swan
#

replit?

slate swan
#

so how can u load and unload a cog

#

it shows how to load but not unload

#

bot.unload_extension("path")

shrewd apex
#

!d discord.ext.commands.Bot.unload_extension

unkempt canyonBOT
#

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

Unloads an extension.

When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported.

The extension can provide an optional global function, `teardown`, to do miscellaneous clean-up if necessary. This function takes a single parameter, the `bot`, similar to `setup` from [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension").

Changed in version 2.0: This method is now a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.10)").
silk fulcrum
#

lmao

slate swan
frigid python
shrewd apex
#

is reload a thing ?

#

should be right?

frigid python
#

yes

slate swan
slate swan
#

!pip discord its a mirror

unkempt canyonBOT
shrewd apex
#

no need to unload and load just reload

frigid python
#

lol

silk fulcrum
#

lets just all do pip install discord.py==1.7.3

brazen raft
brazen raft
#

!d discord.ext.commands.Bot.reload_extension

unkempt canyonBOT
#

await reload_extension(name, *, package=None)```
Atomically reloads an extension.

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

🐈lets not use pip but poetry

slate swan
shrewd apex
slate swan
#

is it okay for a bot to send messages to a person as to why they were banned

#

that wont get the bot banned will it

#

its fine if you do that

junior verge
#

What would you guys say is the easiest way of getting slash commands (not dpy 2.0)

#

Like with the least amount of time needed to change up commands to slash

silk fulcrum
#

in dpy you could do hybrid commands but ok...

frigid python
#

yeah that's probably the easiest

ionic edge
#

discord

#
    await channel.send(member)
AttributeError: 'NoneType' object has no attribute 'send'

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

    @commands.hybrid_command(name='formaccept' , description = 'Accepts the form')
    @app_commands.guilds(1008758498789695508)
    async def formaccept(self,ctx, * , member : discord.Member):
        channel = self.client.get_channel(723990989841003520)  
        await channel.send(member)
#

code

brazen raft
#

That channel doesn't exist

silk fulcrum
#

channel with id 723990989841003520 was not found

brazen raft
#

That might happen when the bot has no viewing access to it, I think?

silk fulcrum
#

might

slate swan
#
import discord

from discord.ext import commands
from itertools import cycle
from main import client

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

    @commands.Cog.listener()
    async def on_ready(self):
        print("Bot status cog loaded")

    @commands.event
    async def on_ready(self):
        change_status.start()

    @commands.loop(seconds=3)
    async def change_status(self):
        status = cycle(["I Love Luna", "❤️", ".help"])
        await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=(next(status))))

async def setup(bot):
    await bot.add_cog(Bot_Status(bot))```

error: change_status is not defined
#

can someone help me with this

silk fulcrum
#

because the error says change_status

slate swan
#

oh ye smh

#

wait no

#

it auto saves

silk fulcrum
#

full exception please

brazen raft
#

You're calling it weirdly

silk fulcrum
#

also you should not do class Bot_Status

#

BotStatus is nice

slate swan
#

oh ok

brazen raft
#

And you are defining two on_ready functions

slate swan
#

that would be whyu

#

i just realised

brazen raft
#

I have a question

#

From where have you taken this code

silk fulcrum
#

btw @commands.event is not a thing i guess

slate swan
#

i made it

brazen raft
#

I came up with something similar while helping someone

slate swan
#

lmao

brazen raft
#

The first line in change_status's body needs to be outside of the function

silk fulcrum
#

oh wait it's just problem with self.change_status

#

i didnt realise

brazen raft
#

And you are using client instead of self.bot for some reason

#

What even is main.client

#

Why are you importing it?

maiden fable
#

whenever someone says self.bot, self bots come to my mind welp

slate swan
#

im new to cogs lmao be nice

silk fulcrum
#

dont worry, be happy

brazen raft
#

The setup function in extension files gets called with a bot as a parameter (when the extension is loaded). The cog's __init__ function which you define takes it and assigns self.bot the value of that parameter in the end, which lets you use the bot instance thru self.bot

slate swan
#

so theres no need to use client

maiden fable
silk fulcrum
#

even more, you mustn't use it

silk fulcrum
slate swan
#

what so not even in the main.py at all

silk fulcrum
slate swan
#

ah ok lol

silk fulcrum
#

oh wait i just realised

#

client = commands.Bot 😭

maiden fable
#

LMAO

brazen raft
#

You never need/ought to import a client instance

slate swan
#

im so confused rn

brazen raft
brazen raft
slate swan
#

ok noted

maiden fable
silk fulcrum
maiden fable
#

That too

slate swan
#

what do cogs use instead of @commands.event

silk fulcrum
primal token
#

@commands.Cog.listener()

slate swan
#

which

maiden fable
#

noid is right

primal token
#

dont be so paranoid lol

silk fulcrum
#

*paramaniac

maiden fable
#

Why does noid gives away andy's vibes 😔

silk fulcrum
#

who is andy vibes

maiden fable
#

andy is a name lol

#

Was a regular here before

slate swan
#

bruh

#

now my bot is sending 4 of each command

#

i do .help and it sends 4 embeds

brazen raft
#

Make sure you're not accidentally running your bot four times

slate swan
#

hows that even possible

brazen raft
#

It is possible when you forget to close a terminal window in which you've run the bot

#

And you open another

#

Might also be because you have from main import client in 3 files

slate swan
#

i took that out

brazen raft
#

Importing runs the module

slate swan
#

its definitley not open more than once

#

i havnt imported client from main anywhere

brazen raft
#

Well then you're importing main or client from main in 3 files

slate swan
#

i deleted that

#

the only thigns imported are ```py
import discord

from discord import Embed
from discord.ui import Button, View
from discord.ext import commands```

brazen raft
#

Actually this won't make it so you have 4 running instances of the bot

#

So I don't know what's causing it to happen other than you have 4 bot processes running

slate swan
#

i closed vsc from task manager and now it only does it 3 times which is improvement lmao

silk fulcrum
#

do you have an on message somewhere?

jovial pebble
#

can someone invite me to discord js server

silk fulcrum
slate swan
#

i do*

silk fulcrum
#

show it

slate swan
#

um

#

i dont think i can its a function that blocks slurs

vale wing
#

So what

ionic edge
#

    @commands.hybrid_command(name='response' , description = 'Gives The Response')
    @app_commands.guilds(1008758498789695508)
    @app_commands.checks.has_role(1010100433538273300)
    async def response(self,ctx, * , member : discord.Member , response : Literal['accept', 'reject']):
        channel = self.client.get_channel(1010106207865933934)  
        if (response == 'accept'):
            await channel.send(f'{member.mention} has been accepted')
            await ctx.send(f" {member}'s Form ||Accepted|| By {ctx.author.mention}")
        if (response == 'reject'):
            await channel.send(f'{member.mention} has been declined')
            await ctx.send(f" {member}'s Form ||Rejected|| By {ctx.author.mention}")```
silk fulcrum
#

it could be @commands.Cog.listener() with bot.proccess_commands at the end
and btw reset the token as exenfix said

ionic edge
#

this command not working

slate swan
#
@commands.Cog.listener()
    async def on_message(self, message):
        slurs = ["i took them out"]
        msg = message.content or message.content.upper()
        for word in slurs:
            if word in msg:
                await message.delete()
                await message.channel.send(f"<@{message.author.id}> said a racial slur smh")
        await self.bot.process_commands(message)
        return```
#

thats the code

brazen raft
#

This looks functional enough to me

slate swan
#

reseting the token didnt do it

brazen raft
#

Maybe you have multiple on_message listeners/events that call and await process_commands

#

If I'm not mistaken, you can have multiple cog listeners for one event

vale wing
slate swan
#

ohhh

#

i have two on_message

#

does anyone know how to make your bot create a new channel with just you and the owner of the server when you click on a button below bascially a ticket tool function?

#

someone let me know if you can help

robust fulcrum
#

Guys how can we mute and unmute in dpy?

silk fulcrum
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

silk fulcrum
#

bruh

#

!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...
silk fulcrum
#

mute=True to mute

#

mute=False to unmute

robust fulcrum
#

Like this?
await ctx.author.edit()

silk fulcrum
slate swan
#

or you can add_roles and give them a muted role

robust fulcrum
#

Thanks

slate swan
#

if that makes sense

silk fulcrum
#

oh wait, you meant mute in chat? @robust fulcrum

#

not in voice?

silk fulcrum
silk fulcrum
slate swan
#

yep

slate swan
#

idk how to do that

silk fulcrum
#

guild.create_channel returns a TextChannel obj so you can just put it in a var and send what you want

silk fulcrum
#

oh

#

well, you can do on_guild_update event iirc and check if that's a channel creation and if that's a ticket channel creation, and then send your embed there

slate swan
#

wot

slate swan
cerulean shale
#

what to do? if i await it, it is giving error, if not, it is giving error ;-; endless loop bruh pls help

silk fulcrum
cerulean shale
silk fulcrum
#

you must load your extensions in an async function in dpy 2.0

cerulean shale
#
for filename in os.listdir('./cogs'):
  if filename.endswith('.py'):
    await bot.load_extension(f'cogs.{filename[:-3]}')
    print (f'Successfully loaded {filename[:-3]}')
  else:
    print(f'Unable to load {filename[:-3]}')```
silk fulcrum
#

for example setup_hook of your Bot

silk fulcrum
cerulean shale
slate swan
#

does anyone know how i can make my bot send embeds as soon as tickets are made by ticket tool let me know

lone lichen
silk fulcrum
cerulean shale
#
async def load(): 
  for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
      await bot.load_extension(f'cogs.{filename[:-3]}')
      print (f'Successfully loaded {filename[:-3]}')
    else:
      print(f'Unable to load {filename[:-3]}')

async def main():
  await load()
  await bot.run('i took my token out')

asyncio.run(main())```
#

help 💀

brazen raft
silk fulcrum
#

1: why not setup_hook
2: aight, whatever, bot.run is not async method, use await bot.start(token) then
3: are you importing load from somewhere, or is there anything else named load in this file?

silk fulcrum
#

how

#

oh bruh im stupid

brazen raft
#

I'm pretty sure there are

vale wing
#

!d discord.on_guild_channel_create or smth

unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
lone lichen
# unkempt canyon

On guild update would work too but It’ s like shooting urself in the foot 😂

silk fulcrum
#

i thought there is no on_channel_create

cerulean shale
#

listening it for the first time

primal token
cerulean shale
#

ayo what does it want me to do ffs ;-;

torn sail
unkempt canyonBOT
#

discord.on_guild_channel_delete(channel)``````py

discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.

Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
primal token
#

wouldnt

torn sail
#

Oh didn’t see

vale wing
#

Are masters multiplying or smth

torn sail
#

No I was here first

lone lichen
#

😂

vale wing
#

In a week there are gonna be 4 of them ig

torn sail
vale wing
#

Geometric masters progression

cerulean shale
#

imagine getting totally ignored

vale wing
#

Relatable

kindred kernel
cerulean shale
vale wing
#

What the hell

kindred kernel
# cerulean shale i have 0 idea on setup_hook

In 2.0, Bot.load_extension is now a coroutine.
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension
All you have to change is to:

  1. await load_extension(), e.g. await bot.load_extension('jishaku').
    If you have cogs:
  2. Change setup functions to be async
    And, if you have a Cog.cog_load function:
  3. make sure to make it async as well!
    Read more here: https://discordpy.readthedocs.io/en/latest/migrating.html#migrating-2-0-commands-extension-cog-async
kindred kernel
primal token
#

!pypi jishaku

unkempt canyonBOT
kindred kernel
primal token
#

debugging and development extension

kindred kernel
#

never looked at it, i think i should

torn sail
#

Cool cog

vale wing
#

Imagine not making one from scratch

brazen raft
#

Making what

torn sail
#

Imagine not being lazy

vale wing
#

Eval command with async support

#

😩

brazen raft
#

A bot in a team I'm a member of has async eval support

#

Although I don't like how it's implemented

vale wing
#

I made that thing once and I use it everywhere

brazen raft
vale wing
#

The only thing I don't like about my implementation is the actual code gets put to the string and then that string is executed

brazen raft
#

Yeah, it should also use a sandboxed environment

#

I wonder if there are any free ones

vale wing
#

It's owner-only so idrc

brazen raft
#

Right but exec is not asynchronous

#

So it would be fun sending an asynchronous request to a sandboxed environment to run the code and await results

vale wing
brazen raft
#

I mean I guess you can start a new process

#

You pass an environment which includes the context

vale wing
#

Yes

brazen raft
#

And maybe other modules

vale wing
#

Because it's for my purposes

brazen raft
#

You'd have to use asyncio.run and call it on a coroutine which you have to define

kind wind
#

Code:

@bot.command(aliases = ["lb"]) #LEADERBOARD COMMAND
async def leaderboard(ctx, x = 10):
    users = await get_bank_data()
    leader_board = {}
    total = []
    for user in users:
      name = int(user)
      total_amount=users[user]["souls"]
      leader_board[total_amount] = name
      total.append(total_amount)

    total = sorted(total, reverse=True)
    
    em = discord.Embed(title = f"Top {x} Most Soul Collectors!",description = "These are the (current) top soul collectors",color = discord.Color.random())
    index = 1
    for amt in index:
      id_ = leader_board[amt]
      member = bot.get_user(id_)
      name = member.name
      em.add_field(name = f"{index}. {name}" , value = f"{amt}", inline=False)
      if index == x:
        break
      else:
        index += 1

    await ctx.reply(embed = em)
lone lichen
#

U cant iterate through int

kind wind
#

i saw it from a tut

lone lichen
#

Bad tutorial

glad cradle
#

maybe in the tutorial was for amt in range(index)?

kind wind
#

oh i did a mistake oops-

#

Error:

Ignoring exception in command leaderboard:
Traceback (most recent call last):
  File "C:\Users\user\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\user\Desktop\Vaggelis\Coding\Bots\Ghost Bot\main.py", line 91, in leaderboard
    name = member.name
AttributeError: 'NoneType' object has no attribute 'name'

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

Traceback (most recent call last):
  File "C:\Users\user\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\user\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\user\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: 'NoneType' object has no attribute 'name'

I changed the for amt in index: to for amt in total:

glad cradle
#

bot.get_user(id_) returned None

kind wind
#

how can i fix that

sharp geode
#

Why do I get this error?

async def config(self, option: app_commands.Choice[str], get_or_edit: Optional[app_commands.Choice[str]], role: discord.role):

TypeError: unsupported type annotation <module 'discord.role' from 'C:\\Users\\yonii\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\discord\\role.py'>

slate swan
#

need help

lone lichen
#

!d discord.ClientUser

unkempt canyonBOT
#

class discord.ClientUser```
Represents your Discord user.

x == y Checks if two users are equal.

x != y Checks if two users are not equal.

hash(x) Return the user’s hash.

str(x) Returns the user’s name with discriminator.
slate swan
#

can anyone help me please?

slate swan
lone lichen
#

!d discord.ClientUser.avatar

unkempt canyonBOT
#

property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset "discord.Asset") for the avatar the user has.

If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.ClientUser.display_avatar "discord.ClientUser.display_avatar").
vale wing
unkempt canyonBOT
#

asyncio.run_coroutine_threadsafe(coro, loop)```
Submit a coroutine to the given event loop. Thread-safe.

Return a [`concurrent.futures.Future`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future "concurrent.futures.Future") to wait for the result from another OS thread.

This function is meant to be called from a different OS thread than the one where the event loop is running. Example...
lone lichen
sharp geode
slate swan
vale wing
#

Why property_

slate swan
#

display_avatar

#

I tried like this but it won't work

vale wing
#

Property is like a function you can get the result of without calling it

slate swan
#

Logs_embed.set_footer(text=f"{bot.user.name}", icon_url=f"{display_avatar}")

#

it shows

#

undefined name 'display_avatar'

lone lichen
#

!resources python

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

kind wind
lone lichen
kind wind
#

click the reply and there is the error and stuff i changed

lone lichen
#

Print out leaderboard

kind wind
#

print what-

lone lichen
#

leader_board

kind wind
#

where do i print that

lone lichen
kind wind
#

this? id_ = leader_board[amt]

lone lichen
#

Yes

#

There

kind wind
#

print(leader_board)?

lone lichen
#

Yesss

kind wind
#
Traceback (most recent call last):
  File "C:\Users\user\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\user\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\user\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: 'NoneType' object has no attribute 'name'
glad cradle
#

what's your code

brazen raft
#

Making programs for others is against the rules of this server

slate swan
#

oh

#

ooops

#

sorry

junior verge
sick birch
#

dpy 2.0

#

Or any of the other forks

#

But if you’re already on d.py I don’t see why you can’t just update and migrate to slash commands quickly

slate swan
#

ModuleNotFoundError: No module named 'discord.utils'

sick birch
supple ridge
#

why am i getting 'str' object has no attribute 'name' when trying to do client.user.name or client.user

#

Im trying to print into console whenever the bot is online that is its username along with its discriminator, however it doesnt seem to work. It always give me 'str object' has no attribute 'name when i use client.user or client.user.name.

Adding on, it seems to work fine in the rest of programs but its having issues in this one.

Any help would be greatly appreciated.

junior verge
sick birch
junior verge
#

With disnake you gotta change up a lot of the commands right?

sick birch
#

Yes

#

More effort than to just use discord.py 2.0 if you ask me

sick birch
supple ridge
#

yea just gimme a moment

sharp geode
#

how can I get a structure like this with slash commands from discord.py v2?

supple ridge
#

@sick birchhere

#

it changes from nonetype to str and then back bruh

#

idek whats happening

#

altermnatively if i use client.user then this happens:-

#

that means its not able to read username?

#

or what

sick birch
#

You need an on_ready in which you can print

supple ridge
#

oml

supple ridge
sick birch
sharp geode
sharp geode
#

thx

silk fulcrum
#

np

supple ridge
sick birch
#

Depends on the class or def

#

If the class is a cog and it’s been loaded properly yes

#

If the def is an event then yes

silk fulcrum
slate swan
#

can anyone tell me why i cant send a message to a user after ive banned them

sick birch
supple ridge
#

nvm im dumb its done ty robin

sick birch
#

Or if the user has DMs disabled

silk fulcrum
sick birch
#

Or a few other reasons I can’t think off the top of my head

tiny cave
#

I think I'm just being dumb rn but for some reason my bot refuses to get input from servers. It works perfectly fine for DMs, I've added the bot to the server with text permissions and am using "async def on_message(message):" to get an event

supple ridge
silk fulcrum
#

melate:(

silk fulcrum
supple ridge
tiny cave
slate swan
silk fulcrum
#

ohwellok

slate swan
#

bosh

limber bison
#

Is javascript bots faster then python ?

slate swan
#

ModuleNotFoundError: No module named 'discord.utils' could someone help me fix this?

silk fulcrum
slate swan
#

its easier

primal token
limber bison
slate swan
silk fulcrum
primal token
#

it depends on allot of things

tiny cave
tiny cave
supple ridge
#

@sick birchand wat about this error?

silk fulcrum
final walrus
#

If I wanted to give my users the ability to claim free daily rewards.. Would it be a decent solution to keep track in a database of when the last time my user claimed a reward was? Then when they try to claim check against that time and so on..?

#

Feels kinda gimicky, but also the only idea I got

#

like claiming a daily balance or something

primal token
#

if were talking about hassle lets talk about JS syntax

final walrus
#

"anything other than python"

tiny cave
primal token
#

why compare languages that arent the same? that just shows you dont know what youre talking about

supple ridge
primal token
tiny cave
supple ridge
primal token
#

this is a discord bots channel its not about jokes.

final walrus
tiny cave
supple ridge
supple ridge
final walrus
#

check where you defined client

#

and what you defined it as

tiny cave
primal token
tiny cave
supple ridge
final walrus
#

it wasn't thaaat controversial

supple ridge
junior verge
#
@client.command(aliases=["sr", "addrole"])
@commands.has_permissions(manage_messages=True)
async def setrole(ctx, level: int, *, role: discord.Role):
    async with client.db.cursor() as cursor:
        await cursor.execute("SELECT role FROM levelSettings WHERE role = ?", (role.id, ctx.guild.id,))
        roleTF = await cursor.fetchone()
        if roleTF:
            return await ctx.send("A role or level setting for that value already exists")
        await cursor.execute("INSERT into levelSettings VALUES(?, ?, ?, ?,)", (True, role.id, level, ctx.guild.id,))
        await client.db.commit()
    await ctx.send("Updated that level role")
``` Any idea anyone? Not too sure about this
primal token
primal token
slate swan
junior verge
tiny cave
silk fulcrum
#

dpy 2.0?

primal token
final walrus
#

discord py

slate swan
#

version

final walrus
#

versión

#

(version in spanish)

silk fulcrum
#

ver

final walrus
#

v

slate swan
#

v supremacy

tiny cave
#

So yes, 2.0

final walrus
slate swan
#

you dont

final walrus
#

oh

primal token
slate swan
#

2.0 is on pypi

final walrus
#

seriously?

#

since when

primal token
#

yes

silk fulcrum
#

yesterday

final walrus
#

ooooh

tiny cave
final walrus
#

well

#

oroight mb

tiny cave
primal token
#

!d discord.Intents.message_content

unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:

• The message was sent by the client

• The message was sent in direct messages

• The message mentions the client

This applies to the following events...

slate swan
silk fulcrum
primal token
unkempt canyonBOT
#

Hey @limber bison!

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

slate swan
unkempt canyonBOT
#

Hey @limber bison!

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

#

Hey @limber bison!

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

silk fulcrum
#

@limber bison use hastebin bruh

slate swan
#

same thing different names

silk fulcrum
#

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

can someone help me

#

replit is saying syntax error

silk fulcrum
limber bison
silk fulcrum
#

seems valid without seeing more code

silk fulcrum
final walrus
#

shy >.<

silk fulcrum
#

what's the problem 👉 👈

limber bison
slate swan
final walrus
#

having ur code exposed to thousands of people 🥺

silk fulcrum
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
#

oh wait

final walrus
#

import asyncio @slate swan

slate swan
silk fulcrum
final walrus
slate swan
#

ok

final walrus
silk fulcrum
#

oof

leaden cosmos
final walrus
slate swan
#

still clapped guys

leaden cosmos
#

show all of your event on ready

final walrus
#

so demanding

silk fulcrum
final walrus
#

o yeah

silk fulcrum
#

command_prefix = ( "

slate swan
#

wdym extra

final walrus
#

good eyes

slate swan
#

im baffled

#

ok lemme change

leaden cosmos
leaden cosmos
slate swan
#

i fixed what u said

#

and got this

leaden cosmos
slate swan
#

how can i access server roles in order to give someone a muted role

leaden cosmos
#

now we use intents

slate swan
#

!intents

leaden cosmos
#

command_prefix = "", intents=discord.Intents.all()

final walrus
leaden cosmos
#

boomb cat

slate swan
#

i got a error to big to put into a ss

leaden cosmos
slate swan
leaden cosmos
#

i can't see anything

brazen raft
#

Never in my entire life have I seen a traceback this long

leaden cosmos
#

capture the bigger image and capture the client.run for me

slate swan
#

my code had a stroke 💀

brazen raft
#

Actually it looks like logging

leaden cosmos
brazen raft
#

You logged HTML

slate swan
#

ik

#

lemme fix it

leaden cosmos
primal token
slate swan
#

new ish

leaden cosmos
#

if that so wait some minutes or some hours

#

it'll unlock again

slate swan
#

im not

#

being limited

leaden cosmos
primal token
junior verge
#
role = await cursor.fetchone()
            await cursor.execute("UPDATE levels SET level = ? WHERE user = ? AND guild = ?", (level, author.id, guild.id,))
            await cursor.execute("UPDATE levels SET xp = ? WHERE user = ? AND guild = ?", (0, author.id, guild.id,))
            if role:
                role = role[0]
                role = guild.get_role(role)
                try:
                    await author.add_roles()
                    await message.channel.send(f"**{author.mention}** has just leveled up to **{level}** and got the **{role.name}** role!")
                except discord.HTTPException:
                    await message.channel.send(f"{author.mention} has leveled up to level **{level}**!")
            await message.channel.send(f"{author.mention} has leveled up to level **{level}**!")
``` Why does this not give the role to the user?
silk fulcrum
# limber bison https://paste.pythondiscord.com/azotupukip
  • line 18, naming commands.Bot instance client is just... not good, just name it bot...
  • remove unnecessary commentaries (commented code like #@commands.check(check_channel))
  • line 35-37, on_ready is triggered when the bot is ready, not cog, you can print that cog is loaded in your setup function
  • line 47, you don't have to use brackets in ifs, it's not js
  • line 43, it's better to put this variable in __init__ by defining it like self.message_cooldown = ..., but if you really want to, you can leave it as a class var
  • line 54-58, if condition: pass, else: can be replased with if not condition:
  • line 81, I don't think there is a reason to typehint user as a converter, you can just typehint it as discord.Member
    that's not all advices, just sent a couple of them so you can work on it
junior verge
#

Yeah?

#

Everything works just got a issue with giving the role as its not erroring and just not giving the role

#

Got any idea what the error could be?

leaden cosmos
#

this leveling is hard
i can't fix this

junior verge
#

It ain't that hard?

leaden cosmos
#

i use on my bot capcha add role only

#

i don't use leveling

junior verge
#

Then don't say it's hard

leaden cosmos
#

it's hardddd

pallid marsh
primal token
#

what type of question is that

#

if it were a User it would return an attr error no?

pallid marsh
# junior verge guild

Idk then I remember role giving being kinda finicky before when I used dpy. Can’t remember how I fixed it.

primal token
#

seems like an issue of permissions or higherarchy possibly

junior verge
#

OOOH

pallid marsh
junior verge
#

I see the issue

#
await author.add_roles(role)
``` it should be this
pallid marsh
junior verge
#

LOLll

#

How would it know what role to add xd

primal token
#

isnt the argument required in the coroutine?

pallid marsh
#

It should be

tiny cave
primal token
#

how did that slip lol

primal token
tiny cave
#

I think it's mistaking the variable "intents" for the actual "discord.Intents"

primal token
#

no?

#

Intents object has no attribute 'message_content'

#

no?

weary flume
#

are we allowed to ask for help in this channel?

leaden cosmos
primal token
#

why would you activate privileged intents you arent using? its a waste of resources and a waste of dispatching events that wont even be handle by the client?

weary flume
#

im trying to make a command on my bot require a certain role in a private server i have but that isnt working

#

so basically people would join the server i give them the role then the command should work for them

pallid marsh
#

Is there an error?

weary flume
#

no

leaden cosmos
weary flume
#

ok ill explain better

leaden cosmos
#

maybe my english still too bad

primal token
#

More like show your code

weary flume
#

ok ill send

pallid marsh
#

He wants to give a role to someone when they join the server
And have a command that only works if you have said role

silk fulcrum
# silk fulcrum - line 18, naming `commands.Bot` instance `client` is just... not good, just nam...

@limber bison

  • line 63, you do if condition: return, so you just don't need that else
  • line 83-84, this can be replaced with user = user or ctx.author
  • line 108, this f string is just weirdness f"{ctx.author.display_avatar}", just do icon_url=ctx.author.display_avatar.url and feel good
  • line 118, error.retry_after will always be float, so there is no need to do math.ceil, int(...) + 1 would be easier
  • line 131, ...display_avatar**.url**
  • line 132, why not define user before line 131, to use it also in set_author thing
  • line 149, user can withdraw 0, if you want to prevent that, do < 1 or <= 0 (btw in line 185 you do that correctly)
    aight, im tired already, i think you got that you need to do ctx.author.display_avatar.url, because there is a lot of it as I see
    hope this was not useless...
primal token
#

:kek:

weary flume
#

i tried using a tutorial

#

that shit didnt work

primal token
leaden cosmos
#

try to get the new video
in 2022

weary flume
#

the top part is from tutorial

primal token
leaden cosmos
#

that's old

primal token
#

:kek:

weary flume
#

there are no videos Skull

tiny cave
pallid marsh
#

Stackoverflow is a great resource

leaden cosmos
pallid marsh
#

Instead of a video

pulsar solstice
#

I want to build a bot to message in every 120 mins and I don't have much idea how to do it with which module.

weary flume
#

but its not working so im here now

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").
pulsar solstice
pulsar solstice
primal token
#

documentation has examples.

#

if you were wondering :))

pulsar solstice
pallid marsh
#

Docs are great resources…

silk fulcrum
#

@leaden cosmos are you trying to put yourself into that trash can you are clicking?

tiny cave
primal token
# pulsar solstice lol nerds read documentation

you mean people who actually want to learn a libraries abstractions over watching garbage videos that are old and arent up to date as the documentation made by the people who made or contributed to the library?

pulsar solstice
primal token
#

As you can see i hate jokes.

silk fulcrum
sick birch
pulsar solstice
leaden cosmos
sick birch
leaden cosmos
#

oh i understand

tiny cave
limber bison
primal token
#

you can read a libraries documentation completely and still not understand, its the understanding and learning how to read documentation that matters

limber bison
#

thanks master opppp

#

💙

primal token
#

the name of the emoji is blue heart?

leaden cosmos
#

but the real color of it is cyan

#

blue is darker

primal token
#

what

silk fulcrum
primal token
#

a colorblind test doesnt cost allot yk

leaden cosmos
limber bison
primal token
#

:kek:

leaden cosmos
#

cyan heart is real name

silk fulcrum
primal token
#

also use the black formatter

#

!pypi black

unkempt canyonBOT
primal token
novel prairie
#

how can i fix this?

silk fulcrum
#

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

silk fulcrum
#

2nd paragraph

novel prairie
#

i already have

silk fulcrum
#

in dev portal bruh

pale turtle
#
    async def setup_hook(self) -> None:
        self.pool = await self.loop.run_until_complete(asyncpg.create_pool(dsn=self.get_env("URL"), min_size=1, max_size=5))``` I am trying to do this but it says "This event loop is already running
silk fulcrum
silk fulcrum
slate swan
#

is moderate_user=True a valid arg for @commands.has_permissions

silk fulcrum
slate swan
#

i meant that

silk fulcrum
#

!d discord.Permissions.moderate_members

unkempt canyonBOT
slate swan
#

but it works cool

silk fulcrum
#

what is your self.loop?

#

and full traceback pls

pale turtle
#

It's the bot.loop

#

self represents the commands.Bot, it's a subclass

silk fulcrum
#

I mean, what do you put inside bot.loop

#

oh wait there is a default value of it

#

me stupid

#

so what's the full traceback @pale turtle

pliant gulch
#

Just await the connection normally

pale turtle
pliant gulch
#

You have a running loop so no need to do run_until_compelte

silk fulcrum
#

oh btw yes that's also a thing

#

in async you can do await

#

wait, you do await loop.run_until_complete 💀

pale turtle
#

so just await self.loop(something)?

silk fulcrum
#

no

pliant gulch
#

No just await the create_pool coroutine

silk fulcrum
#

self.pool = await asyncpg.create_pool(dsn=self.get_env("URL"), min_size=1, max_size=5) it would be iinm

#

is there iinm btw?

#

if i'm not mistaking

pliant gulch
#

await

silk fulcrum
#

bruh

junior verge
#

I got this command to add a role in my role for a level in my database, now I'm trying to make a command that removes it:

@client.command(aliases=["sr", "addrole"])
@commands.has_permissions(manage_messages=True)
async def setrole(ctx, level: int, *, role: discord.Role):
    async with client.db.cursor() as cursor:
        await cursor.execute("SELECT role FROM levelSettings WHERE role = ? AND guild = ?", (role.id, ctx.guild.id,))
        roleTF = await cursor.fetchone()
        if roleTF:
            return await ctx.send("A role or level setting for that value already exists")
        await cursor.execute("INSERT INTO levelSettings VALUES (?, ?, ?, ?)", (True, role.id, level, ctx.guild.id))
        await client.db.commit()
    await ctx.send("Updated that level role")

This is what I am trying to do but it's probably wrong

@client.command(aliases=["dr", "deleterole"])
@commands.has_permissions(manage_messages=True)
async def delrole(ctx, level: int):
    async with client.db.cursor() as cursor:
        await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, level))
        await client.db.commit()
    await ctx.send("Removed the role")

winged coral
#

Is there a question there?

junior verge
#

Yes, am I doing it right, as it's not working for the delete command. It sends the Removed the role but does nothing in the database and no error either

silk fulcrum
#

think about it WHERE role = ?2 ?2 = level

novel prairie
#

how can i add a user pfp in a image like this one?

limber bison
#

whats poll in mysql ?

silk fulcrum
#

now combine and get WHERE role = level

silk fulcrum
limber bison
#

where can i read about it

#

pool

silk fulcrum
#

there is no pool

glad cradle
silk fulcrum
#

its not postgres

glad cradle
silk fulcrum
pliant gulch
#

In asyncpg a pool is just a connection manager

junior verge
#

the add one works fine

pliant gulch
#

It saves resources by handling when to give out connections, etc

silk fulcrum
#

where's logic?

junior verge
#

Where does it say that?

glad cradle
#

you should at least have role too as a parameter

junior verge
#

Sure

silk fulcrum
# junior verge Where does it say that?
("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, level))
# lets convert into f string (dont do that in code)
(f"DELETE FROM levelSettings WHERE guild = {ctx.guild.id} and role = {level}")
junior verge
#

But idk what the execute in the database gotta be

#

Use the f string in the code or not?

heavy swift
silk fulcrum
silk fulcrum
#

# lets convert into f string (dont do that in code)

sick birch
#

Don’t use f strings in SQL queries

junior verge
#

yeah I am not using it

sick birch
#

SQL injection attacks

pliant gulch
#

Since level is a user input you def wanna sanatise that

#

But it's using an int converter so it'll probably error before someone could attempt an injection

silk fulcrum
#

3; DROP TABLE levelSettings;

junior verge
#

I just wanna do like .delrole 5 (5 means the level and it would just delete that)

silk fulcrum
junior verge
#

No need for role: discord.Role then?

heavy swift
silk fulcrum
#

some 7216592831532 base int and you are dead (idk what did i say)

novel prairie
#
@bot.event
async def on_member_join(member):

    em = discord.Embed(color=0x12d600, description=f"Thank you {member.mention}, you're the member number {len(list(member.guild.members))}!")
    em.set_footer(text=f"{member.guild}", icon_url=f"{member.guild.icon_url}")
    em.set_image(url=f"{member.avatar_url}")
    em.timestamp = datetime.datetime.utcnow()
    
    channel = client.get_channel(962043355645247508)
    await channel.send(embed=em)``` i want my bot to send welcome images/messages ive tried this but it didnt work how can i make this command work?
silk fulcrum
#

!e print(type(('yes')))

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

<class 'str'>
silk fulcrum
#

or not

heavy swift
#

💀

junior verge
#

But what would the execute be in to the database?

junior verge
#

as I think that's the issue

sick birch
#

We really need a !doesnt-work tag

#

I hear it at least 5 times a day

silk fulcrum
#

!e py print(type(('yes', 'no')))

unkempt canyonBOT
#

@silk fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

<class 'tuple'>
silk fulcrum
#

at least here im not dumbass

hazy needle
#

any1 know how make a pokemon bot

heavy swift
#

!e print(type(('yes',)))

unkempt canyonBOT
#

@heavy swift :white_check_mark: Your 3.11 eval job has completed with return code 0.

<class 'tuple'>
#
Missing required argument

code

silk fulcrum
novel prairie
junior verge
#
@client.command(aliases=["dr", "deleterole"])
@commands.has_permissions(manage_messages=True)
async def delrole(ctx, level: int):
    async with client.db.cursor() as cursor:
        await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, level,))
        await client.db.commit()
    await ctx.send("Removed the role")
``` Still just got this now but unsure on what the execute into the database needs to be
sick birch
novel prairie
sick birch
silk fulcrum
novel prairie
#

it doesnt have an error message

junior verge
#

add some prints

sick birch
#

If you don't have error message, it means one of 2 things:

  1. It's working as you have coded it (not necessarily how you intended)
  2. You have a bad error handler
novel prairie
#

im using replit

heavy swift
heavy swift
#

yeah

sick birch
#

Check for any on_command_error or on_error

junior verge
#

Probably a bad error handler

heavy swift
#

how are ur intents setup

junior verge
novel prairie
#
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)```
heavy swift
#

valid

novel prairie
#
client = discord.Client(intents=discord.Intents.default())```
#

thats all

heavy swift
#

w

silk fulcrum
#

what?

#

client and bot both?

novel prairie
#

i need to replace client with bot?

glad cradle
silk fulcrum
#

you need to not use them both

junior verge
sick birch
#

Are you storing everyone's roles in your database?

junior verge
#

Nonono

novel prairie
#
bot = discord.bot(intents=discord.Intents.default())```
#

like that?

junior verge
novel prairie
#

ok

junior verge
#

discord.Bot

sick birch
silk fulcrum
#

discord.Bot is not a thing

cerulean shale
junior verge
novel prairie
sick birch
cerulean shale
#

Idk it works for me so I suggested 😶‍🌫️

limber bison
sick birch
limber bison
#

any site link ?

heavy swift
#

@novel prairie do you have from discord.ext import commands as an import

limber bison
cerulean shale
heavy swift
#

commands.Bot then

junior verge
glad cradle
slate swift
#

does anyone know how I can make a Bot like this?

junior verge
#

Pretty sure that's tos

slate swift
#

it is?

final walrus
sick birch
novel prairie
#
ile "main.py", line 16, in <module>
    bot = commands.Bot(intents=discord.Intents.default())
TypeError: __init__() missing 1 required positional argument: 'command_prefix'```
sick birch
silk fulcrum
unkempt canyonBOT
#
Not likely.

Package could not be found.

glad cradle
silk fulcrum
#

bruh( there must've been(

sick birch
unkempt canyonBOT
#

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

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

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

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

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

New in version 2.0.
junior verge
silk fulcrum
#

!pypi TikTokApi

unkempt canyonBOT
silk fulcrum
#

finale

sick birch
final walrus
#
@bot.command()
async def add(ctx, userID)

if I do "add @<sampleuser>" will my bot recieve a user object? Or the user id?

heavy swift
sick birch
junior verge
junior verge
junior verge
#

So now it shows as None

sick birch
#

So put them back

heavy swift
final walrus
#

alright thanks

junior verge
final walrus
#

and to get the id i'd do member.id right? @heavy swift

heavy swift
#

yeah

final walrus
#

ty

sick birch
junior verge
sick birch
#

Well yeah, so what's the problem? If you deleted them obviously it's going to be none

junior verge
#

Yeah I just want those that say none removed

sick birch
#

So you want to change None to Removed?

#

Can you send the code for the command that displays all the roles?

junior verge
#

No just removed from the database so it doesn't show

junior verge
#
@client.command()
async def rewards(ctx):
    async with client.db.cursor() as cursor:
        await cursor.execute("SELECT * FROM levelSettings WHERE guild = ?", (ctx.guild.id,))
        roleLevels = await cursor.fetchall()
        if not roleLevels:
            return await ctx.send("No role levels have been setup for this guild!")
        em = discord.Embed(title="Role Levels", description="Role Levels for this server")
        for role in roleLevels:
            em.add_field(name=f"Level {role[2]}", value=f"{ctx.guild.get_role(role[1])}", inline=False)
        await ctx.send(embed=em)    
#

@client.command(aliases=["dr", "deleterole"])
@commands.has_permissions(manage_messages=True)
async def delrole(ctx, role: discord.Role):
    async with client.db.cursor() as cursor:
        await cursor.execute("DELETE FROM levelSettings WHERE guild = ? and role = ?", (ctx.guild.id, role.id,))
        await client.db.commit()
    await ctx.send("Removed the role")
#

This works fine

#

I just want the None gone on that list

#

And I can't set a role for those where it says None as its already in use for that level

#

Yeah but then when adding it will also show that it already has something on that level

junior verge
#

As that were old roles that are deleted now

hushed galleon
#

what code did you write for the command that displayed that embed? if you deleted the corresponding role from your db, how are you querying None values?

#

oh your rewards command is doing that

slate swift
#
from discord.ext import commands

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

@bot.event
async def on_ready():
    print("Bot is online")```
pliant gulch
#

roleLevels = [first, second for _, first, second in roleLevels if first is not None]

slate swift
#

does anyone know what this error means ^

pliant gulch
#

If this happens after you send SIGINT you can ignore it

#

It's just a windows related error

junior verge
#

I'll try

glad cradle
slate swift
glad cradle
#

how are you running your Bot

#

delete the token and send the line

slate swift
junior verge
#

no difference

slate swift
hushed galleon