#discord-bots

1 messages · Page 934 of 1

slate swan
#

what's wrong with this

slate swan
#

if (.. -> if not

#

it working with this

#

but let me try

pliant gulch
#

!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.
slate swan
#

still doesn't work but here's the code

slate swan
final iron
slate swan
#

so what should I put

slate swan
wild oak
#

Does anyone know if its possible if you can make a python script that scans for a certain word on the screen? like with ocr or something like that?

slate swan
#

administrator yeah ty

wild oak
#

im so sorry im blind 😂 this was the first channel that popped up when i clicked the server my apologies

hybrid mural
#
        class View(discord.ui.View):
            def __init__(self):
                super().__init__(timeout=None)
                for i in range(3):
                    for j in range(3):
                        self.add_item(item=(discord.ui.Button(label="\u200b", row=i, custom_id=("button" + str(i) + "," + str(j)))

            @button(label= "\u200b", custom_id="button0,0", row=0)
            async (error: for expected) def counter(self, button: discord.Button, interaction: discord.Interaction):
                button.emoji = "❌"
                await interaction.edit_original_message(view=self)

Why does Python tell me there s a "for" expected in async def counter?

slate swan
#

for expected

hybrid mural
#

nah what i mean is that is where its telling me that "for" is expected

slate swan
manic wing
#

dont be rude please

hybrid mural
#

poorly described mb

manic wing
#

you tell me

hybrid mural
#

no worries

manic wing
#

im not doing anything, i was just making sure you were helping in a polite fashion

hybrid mural
#

sorry found the error forgot a ) at the for loop

#

but one more question

#

is my thought right that if i self.add_item in the class it makes multiple items in the View right?

#

so technically how would i be able to edit an item?

#

lets say i have 5 items which are buttons, how would i access that item and edit it?

slate swan
#

So I want two things. The first is I want to add a premium system in which when someone boosts the support server will get a role which will give him/her premium for the bot. Secondly I want to add the ability for the users to setup things for the bot in their servers. The problem is that I don't know how to create both of these things I told

#

If someone can help me it'll be very good

#

why does fetch_users give me <coroutine object Client.fetch_user at 0x00000261D72D8430>

slim ibex
#

show code

slate swan
#
                print(userid)
                useracc = client.fetch_user(int(userid))
                print(useracc)```
slim ibex
#

you have to await it

slate swan
#

ok one sec

#

thanks

#

worked

#

can you explain why that happens though? what does await mean

slim ibex
#

coroutines are async functions in Python'

#

when you use await, which can only be used in functions marked as async def, it suspends the execution of the function and passes it on to the event loop

slate swan
#

ok thanks

slim ibex
#

every async function returns a coroutine'

umbral condor
#

me ena kalo search to prwto to vriskeis kai egw to exw kanei alla den to thimame na s to pw

slim ibex
#

!rule 3

unkempt canyonBOT
#

3. Respect staff members and listen to their instructions.

slim ibex
#

opops wrong one

#

!rule 4

unkempt canyonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

slate swan
umbral condor
#

dm'

slate swan
river swift
#

Ñ

flint dome
#

whats happening here

velvet compass
#

Typo in mention_amount maybe?

flint dome
#

nope

manic wing
#

its because you set name to be the same as the command name.

flint dome
#

ive never had a problem with that

#

also purge command isnt wrong it this one

hoary cargo
#

Rename ur command

flint dome
pliant gulch
#

Slash command names cannot have a capital letter

flint dome
#

its lower

#

this one is upper and works fine

flint dome
pliant gulch
#

🤔

flint dome
#

yea im lost

#
@slash.slash(name="Delete",description="delete servers on your Safecloud-hosting panel.")
async def delete(ctx,serverID):
    pass
    r = api.servers.list_servers()
    oc = 0
    try:
        for i in range(100):
            server_name = r[i]['attributes']['name']
            SID = r[i]['attributes']['id']
            uuid = r[i]['attributes']['uuid']
            nc = oc + 1
            oc = nc
            if serverID == f"{uuid}":
                api.servers.delete_server(server_id=SID)
                await ctx.send(f"{server_name} has been deleted!")
    except IndexError:
        await ctx.send()
#

heres my code

pliant gulch
#

I guess discord must've changed the regex or something, because I remember uppercased names not being allowed

flint dome
pliant gulch
#

Show the full traceback

#

Your screenshot trunicates it a bit

flint dome
slate swan
#

how to make such a thing?

flint dome
#

link the text to the message url

slate swan
#

well and how can i make it to update the id of the message?

pliant gulch
# flint dome

This traceback barely gives any info, are you sure 100% that it's the delete command causing this error?

flint dome
#

if i take it out of my code theres no error

#

heres a copy of a good command and the bad

slate swan
#

why is my bot not saying anything?

The command -a does not exist in the code but it still says nothing please help fast I want to go to sleep

heavy folio
#

is there anything i need to get started on a music bot

slate swan
#

well on the other error handler it works

heavy folio
#

why the fuc

#

oh

#

!d discord.ext.commands.Bot.on_command_error

slate swan
#

not the function

slate swan
#

!d discord.discord.ext.commands.on_command_error

unkempt canyonBOT
#

discord.ext.commands.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
heavy folio
#

what the

slate swan
#

yep weird dir right

heavy folio
#

it's the same for other libs what

slate swan
hoary cargo
boreal ravine
heavy folio
#

arent on_command events under /ext/commands/

boreal ravine
#

well yeah

boreal ravine
#

discord.ext.commands.Bot.on_command_error works tomato_what

flint dome
#

can anyone helpp

slate swan
#

how do i get the id of all people i've dmed before

sick birch
#

Unless you're talking about all the users your bot has dmed before

slate swan
#

what is the difference

#

i am talking on behalf of my bot

sick birch
#

You're.. logged in as your bot?

slate swan
#

huh

sick birch
#

I'm not quite following

#

Are you trying to get the ID of everyone your bot has DMed or everyone you have DMed?

slate swan
#

how could i get the id of people i have dmed

#

my account is not a bot account

sick birch
#

You'd go through manually

#

Rick click and copy ID and paste it somewhere

slate swan
#

but you cant log in to a bot

sick birch
#

In a way that doesn't break TOS? No

#

There are ways to, at least there were but obviously against terms

slate swan
#

bruh how do i get the id of everyone my bot has dmed

sick birch
slate swan
#

that is what i meant all along

quick dust
#
    keep_alive()
NameError: name 'keep_alive' is not defined``` need help
sick birch
#

Keep in mind that includes both dms and group chats so you have to filter it

slate swan
#

since when could bots be in group chats

quick dust
sick birch
#

Best option would be to get off replit

quick dust
#

python

sick birch
slate swan
#

ok so how do i do it

sick birch
#

!d discord.Client.private_channels

unkempt canyonBOT
#

property private_channels```
The private channels that the connected client is participating on.

Note

This returns only up to 128 most recent private channels due to an internal working on how Discord deals with private channels.
slate swan
#

how do i get more than 128 most recent

pliant gulch
#

🤔 Bot's cannot be in group chats

sick birch
#

Alright then you don't have to filter it ¯_(ツ)_/¯

slate swan
#

yeah cuz u would have to add the bot as a friend to add it to a group chat

sick birch
#

You can safely assume they'll all be DMChannels then

#

(I don't know how well that's typehinted so your editor may or may not let you make that assumption)

sick birch
slate swan
#

ok

compact ruin
#

Quesiton does anyone know how i purge only a certain members messages

final iron
#

check kwarg

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

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

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

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

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

Examples

Deleting bot’s messages...
final iron
#

@compact ruin ^

compact ruin
vast gale
#

only the last 128 users who have been dmed

hazy oxide
#

Anyone know what is this error?

AttributeError: 'Bot' object has no attribute 'AppInfo'
slate swan
#

you should provide the sample that triggers that error, and maybe give some context as to what you're trying to do in the first place

hazy oxide
#

I'm trying to make the bot send me the console errors from dm

slate swan
#

okay that's a simple task, now what code do you have right now to do that?

flint dome
#

how can i set a delay to somthing without stoping the whole bot ?

hazy oxide
#

Oops

slate swan
#
import asyncio
await asyncio.sleep(1) # time.sleep(1)```
flint dome
#

yeep thats the module i was looking for thx i couldnt rember

hazy oxide
slate swan
#

AppInfo is a class from the nextcord package, not from a commands.Bot object

#

you need to use the application_info() coroutine to grab a nextcord.AppInfo object with information pertaining to your bot

#
info = await client.application_info()
await info.owner.send(embed=em)```
#

that should do, although i'm not entirely sure as i haven't had a need to use that method before

slate swan
#

could do that but uh, they wanna use AppInfo

#

so i'll direct them to what is relevant

#

yeh

green bluff
final iron
#

It's a coro

#

You have to await it

green bluff
#

i tried await client.load_extension

#

but it gave me another error

final iron
#

Which was...?

green bluff
final iron
#

mhm

green bluff
final iron
#

client.add_cog() is also a coro

green bluff
final iron
#

Actually it's not a coro

#

Not sure why the error is saying it is

#

You don't have to await it

vast gale
final iron
green bluff
final iron
#

How big is the file?

green bluff
#

its not that big

#

its not even close to being big

tropic flame
vast gale
#

hmm?

green bluff
#
import discord
from discord.ext import commands
import random


class Example(commands.Cog):
    def __init__(self, client):
        self.client=client

    @commands.command()
    async def ping(self, ctx):
        """ Pings the client """
       
        latency = round(self.client.latency * 1000)
        msg = await ctx.send("Pong!")
        e = discord.Embed(title="My ping")
        e.add_field(name=f":stopwatch: Latency", value=f"{latency}ms")
        await msg.edit("", embed=e)




def setup(client):
    client.add_cog(Example(client))```
vast gale
tropic flame
final iron
#

I'm going to sleep now

tropic flame
#

kk gn

#

Even I got a discord bot, made it a few weeks ago but now shifted my focus to other projects

#

its hosted 24/7 tho so ye

cerulean osprey
#

Is it possible to check for mass mentions?

slate swan
#

@green bluff show your on_ready functipn

slate swan
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

slate swan
#

you can use len to get number of all the mentions

cerulean osprey
#

D:

raven turtle
#

After a day and a half of writing and refactoring sub-packages, I finally have this to show for it verycool

tropic flame
green bluff
green bluff
slate swan
#

make setup an async function

green bluff
#

like?

slate swan
#

a coroutine instead of a normal function

green bluff
#

setup for what

#

where is the setup

slate swan
#

bruh you have a setup function in the cog dont you?

#
# before
def setup(bot):
    bot.add_cog(MyCog(bot))

# after
async def setup(bot):
    await bot.add_cog(MyCog(bot))
#

this is the new method.

green bluff
#

oh yea

green bluff
# slate swan ```py # before def setup(bot): bot.add_cog(MyCog(bot)) # after async def se...
class Example(commands.Cog):
    async def __init__(self, client):
        self.client=client

    @commands.command()
    async def ping(self, ctx):
        """ Pings the client """
       
        latency = round(self.client.latency * 1000)
        msg = await ctx.send("Pong!")
        e = discord.Embed(title="My ping")
        e.add_field(name=f":stopwatch: Latency", value=f"{latency}ms")
        e.add_field(name=" Heartbeat", value=f"{random.randint(100, 200)}ms")
        await msg.edit("", embed=e)

    @commands.has_role(886780809976107068)
    @commands.command(hidden=True)  
    async def fight(self, ctx, user: discord.Member):
        """ Fights a user """
        potatoes = random.randint(1, 1000)
        await ctx.send(f"{ctx.author.mention} fought {user.mention} with {potatoes} potatoes!")


async def setup(client):
    client.add_cog(Example(client))```
#

this ?

#

i tried it but i still got an error

slim ibex
#
  1. client doesn't have Cogs or commands.
  2. await with client.add_cog as I believe its a coroutine now
#

and __init__ should not be async

green bluff
#

oh

#
import discord
from discord.ext import commands
import random


class Example(commands.Cog):
    def __init__(self, client):
        self.client=client

    @commands.command()
    async def ping(self, ctx):
        """ Pings the client """
       
        latency = round(self.client.latency * 1000)
        msg = await ctx.send("Pong!")
        e = discord.Embed(title="My ping")
        e.add_field(name=f":stopwatch: Latency", value=f"{latency}ms")
        e.add_field(name=" Heartbeat", value=f"{random.randint(100, 200)}ms")
        await msg.edit("", embed=e)

    @commands.has_role(886780809976107068)
    @commands.command(hidden=True)  
    async def fight(self, ctx, user: discord.Member):
        """ Fights a user """
        potatoes = random.randint(1, 1000)
        await ctx.send(f"{ctx.author.mention} fought {user.mention} with {potatoes} potatoes!")


async def setup(client):
    await client.add_cog(Example(client))``` so this?
slim ibex
#

looks good

#

also, do you instantiate discord.Client or discord.ext.commands.Bot

green bluff
#

but i did from discord.ext import commands

#

so ye same thing ..

green bluff
slate swan
#

you need to await the load_extension too

green bluff
#

ooh i await client.load_ext

slim ibex
#

please name the variable bot if you are instantiating Bot

green bluff
#

works ye

slim ibex
#

it is confusing to people helping you since discord.Client exists and client is used for initializing discord.Client

slate swan
#
# bad 
client = commands.Bot(...

# good
bot = commands.Bot(...```
green bluff
#

oh okay sure

#

thanks

pliant gulch
#

Both are bad cause you forgot to close the parenthesis

slate swan
#

😔 that was just an example andy

slate swan
#

i didnt import commands as well

#

andy bro😭

cerulean osprey
#

Anyway to add a role for a specific amount of time?

sick birch
#

Add role, wait X seconds, remove role

slate swan
#
  await msg.edit(content="UR GAME WILL START IN 5 seconds")
  time.sleep(1)
  await msg.edit(content="UR GAME WILL START IN 4 seconds")
  time.sleep(1)
  await msg.edit(content="UR GAME WILL START IN 3 seconds")
  time.sleep(1)

can anyone give me the example of the loop so i can do this

cerulean osprey
# unkempt canyon

For this, if I wanted to check if the message mentioned more than 5 people would it be

if len(message.mentions) <= 5:
    #<...>
```?
slate swan
spring flax
#

no

#

put the > instead of <

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
#

you can mention seconds = 1, and do your stuff

spring flax
#

a task loop for editing an embed from 5 seconds to 1?

#

why not just a while loop

slate swan
#

idk how they want to do it, they'll get ratelimited prolly

#

i'd just use an animated emoji which counts from 5 to 1 😂

spring flax
#

oh if that can be found it'd be helpful just edit out the emoji after the five seconds

spring flax
unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
spring flax
#

use this, it's async

hearty dust
#
import nextcord 
from nextcord import Interaction, SlashOption, ChannelType
from nextcord.abc import GuildChannel
from nextcord.ext import commands
import config

client = commands.Bot(command_prefix=config.prefix)

tsid = 957233126818578462

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


@client.slash_command(guild_ids=[tsid])
async def youtubeslashcommand(interaction: Interaction):
    await interaction.response.send_message("Hi I m a youtuber")

@client.slash_command(name="repeat", description="repeat the message", guild_ids=[tsid])
async def repeat(interaction: Interaction, message:str):
    await interaction.response.send_message(f"you send this `{message}`")


client.run(config.toke)
#

my bot is not showing the slash option :/

tropic flame
#

btw do you guys know any developer groups for python on discord

maiden fable
#

Wym

spring flax
#

for commands.has_any_role, what do I do to a list to make it valid? It's just *list right?
Actually, if I have the list of strings, i need to make it all to integers and then pass it as a list to commands.has_any_role

slate swan
maiden fable
hearty dust
#

why my vs code cant access discord

spring flax
# maiden fable Yes, the * is used to unpack the list

yeah so first i needed to convert the list of strings to integers then unpack them, now i have this can you review it please

async def has_log_role():
    async def predicate(ctx):
        async with bot.db.execute("SELECT role_id FROM permissions WHERE guild_id = ? AND command = ?", (ctx.guild.id, str(ctx.command.name))) as cursor:
            data = await cursor.fetchall()
            role_ids = map(int, data)

        role_predicate = commands.has_any_role(role_ids).predicate
        return await role_predicate(ctx)

    return commands.check(predicate)
    
@bot.command()
@commands.check_any(has_log_role(), commands.has_permissions(manage_guild=True))
slate swan
hearty dust
#

now what to do

slate swan
hearty dust
slate swan
slate swan
hearty dust
hearty dust
#

even i restarted my pc

slate swan
#

damn

slate swan
hearty dust
#

ya

maiden fable
#

@hearty dust u have two Python versions installed?

slate swan
#

rip

spring flax
#

wait...what am i missing

@commands.check_any(has_log_role(), commands.has_permissions(manage_guild=True))
#

this is invalid syntax

maiden fable
hearty dust
#

let me check

slate swan
hearty dust
slate swan
maiden fable
#

Go to control panel and list of programs and see the Python installations

spring flax
hearty dust
maiden fable
#

An env?

hearty dust
spring flax
#

okay yeah restarting vs fixed it

#

or actually it did not

slate swan
#

welp

slate swan
zinc phoenix
#

Hello guys, Im having some problem with my discord bot codes, its returning key errors about the weatherapi, can anyone help

zinc phoenix
#

Heres the code

#import thư viện
from datetime import datetime
import pytz
from datetime import date
from discord.ext import commands
import requests
import os
#chỉnh prefix
prefix="?"

#khởi tạo bot
bot = commands.Bot(command_prefix = prefix)

#khai báo biến ngày tháng năm và dùng múi giờ việt nam
my_time =datetime.now(pytz.timezone('Asia/Ho_Chi_Minh')).time()
my_time = datetime.now(pytz.timezone('Asia/Ho_Chi_Minh')).time()
my_date = date.today()
date_rn = my_date.strftime("%d")
month_rn = my_date.strftime("%m")
year_rn = my_date.strftime("%Y")
#event của bot
@bot.event
async def on_ready():
    print('We have logged in as {0.user}'.format(bot))
  
  
#command của bot
@bot.command()
async def khoidong(ctx):
  await ctx.send("Bot đã sẵn sàng!")
@bot.command()
async def dayrn(ctx):
  await ctx.send(date_rn)
@bot.command()
async def timern(ctx):
  await ctx.send(my_time)
@bot.command()
async def monthrn(ctx):
  await ctx.send(month_rn)
@bot.command()
async def yearrn(ctx):
  await ctx.send(year_rn)
@bot.command()
async def xemtt(ctx, arg):
  cityName = arg
  api_key = os.getenv('weather_api')
  api_add = requests.get("https://api.weatherapi.com/v1/current.json?key="+api_key+"&q="+cityName+"&aqi=no&lang=vi").json()
  temp_city = api_add[0]['current']['temp_c']
  weather_desc = api_add['current']['condition']['text']
  hmdt = api_add['current']['humidity']
  wind_spd = round(api_add['current']['wind_kph']/3.6)
  city_name =  api_add['location']['name']
  time = api_add['current']['last_updated']
  report = "Tình hình thời tiết tại {0} được cập nhật lần cuối vào lúc {1}: {2}\n Nhiệt độ: {3} độ C\n Tốc độ gió: {4}m/s\n Độ ẩm: {5}%".format(city_name, time, weather_desc, temp_city, wind_spd, hmdt)
  await ctx.send(report)

#chạy bot
bot.run(os.getenv('secret_token'))```
#

Heres the code

hearty dust
slate swan
spring flax
#

okay so

#
@bot.command()
@commands.check_any(has_log_role(), commands.has_permissions(manage_guild = True))

this raises invalid syntax, but this doesn't

@bot.command()
@commands.check_any(has_log_role(), commands.has_permissions(manage_guild = True))
async def test():
    pass
slate swan
spring flax
#

but why

maiden fable
#

Cz a decorator always needs either a class or a function

slate swan
maiden fable
#

The decos are made only for those

zinc phoenix
#

But in the bot file it throws errors

#

If I change the assign the var cityName to a name of a city in string, it still runs

tropic flame
tropic flame
slate swan
#
@bot.command()
@has_permissions(administrator = True)
async def kick(ctx, member : discord.Member,*,reason = None):
    await member.kick(reason=reason)
    await ctx.send(f'{member} has been kicked')


@kick.error
async def kick_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send('No permissions btw')
#

i did something wrong?

#

it never works

supple thorn
slate swan
#

no errors nothing

#

@supple thorn bruh we literally got same about me that's a W 🤝

supple thorn
#

Mines more cursed

slate swan
#

yep i can't find the wheelchair in my emojis 😢

supple thorn
slate swan
#

! is my bot prefix

supple thorn
slate swan
#
bot = commands.Bot(command_prefix='!', intents = intent)
supple thorn
#

Yeah but

slate swan
supple thorn
#

Okay thought you weren't tagging them

slate swan
#

nah ,i am tagging

supple thorn
#

Yourself?

slate swan
supple thorn
slate swan
#

let me use this?

supple thorn
#

Yeah but do you have one

slate swan
#

no

#

i mean no errors coming up

#

in the kick.error

supple thorn
slate swan
supple thorn
#

Because your code looks right

slate swan
#

aight i'll do it rn

supple thorn
#

What do you mean probably

slate swan
#

it works for my friend

supple thorn
#

Oh so you copied the code and just pasted it in

slate swan
#

i just copied the kick.error part

#

i used print statement nothing on the console

supple thorn
#

So the kick command doesn't work

slate swan
#

yea...

supple thorn
slate swan
#

idk man there are no errors at all.... and everything else with my bot working fine only kick command is not working

supple thorn
hearty dust
#

btw how to solve this error

supple thorn
#

Project big bull

#

\👀

hearty dust
supple thorn
hearty dust
supple thorn
hearty dust
supple thorn
#

Oh you need intents

hearty dust
supple thorn
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 the Members and Presences intents, which are needed for events such as on_member 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.

hearty dust
#

okk

slate swan
#

which module do i need to import for button?

dusky jackal
#

How to make a disboard bump reminder?

hearty dust
#

@supple thornthank you bro virtual hug to you

slate swan
dusky jackal
#

yes

#

nvm ill do it myself

tropic flame
tropic flame
slate swan
# tropic flame from discord.ui import buttons
  File "C:\Users\GUDDU\Desktop\Program\Projects with my friends\Discord_bot.py", line 3, in <module>
    from discord.ui import Button, View
ModuleNotFoundError: No module named 'discord.ui'```
slate swan
#

oh

slate swan
tropic flame
slate swan
#

no?

quick gust
#

@slate swan install dpy 2.0+ from the gitbub repo

tropic flame
slate swan
#

ok

tropic flame
#

Copy and paste it

#

It will work

slate swan
# tropic flame Do this <@456226577798135808>
  Cloning https://github.com/Rapptz/discord.py to c:\users\guddu\appdata\local\temp\pip-req-build-kwt8zcla
  ERROR: Error [WinError 2] The system cannot find the file specified while executing command git version
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the 'C:\Users\GUDDU\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.```
quick gust
#

and make sure git is installed

slate swan
#

how to install it?

tropic flame
slate swan
#

oh git

tropic flame
slate swan
#

yeah yeah doing it

tropic flame
#

any of you know places where they hire discord bot devs ?

quick gust
#

No

slate swan
#

no

#

should i choose all the options ?

quick gust
#

whatever you want

slate swan
#

So I’m Making / commands but I don’t wanna make it certain guilds how would I do it

#

^ what I mean is I don’t use guilds = “guild id”

tropic flame
#

u want to send the reply to which ever server's text channel the command is used in

slate swan
#

And not just ones with the id In code

#

dont use default guild parameters then

#

it will take 1hr for new commands to get added though

tropic flame
#

sigh why arent their discord servers where you can post adds as a discord bot dev

iron dragon
#

I think the search I was doing was just python jobs or something basic like that. Hope it helps 🤷‍♂️

tropic flame
#

i see ty

brisk zodiac
#
@client.command()
async def clear(ctx, limit:int):
        await ctx.channel.purge(limit=limit)
        await ctx.send(f'{limit} messages have been cleared.')
``` Why this worked but when I typed `!clear 1` it didn't say anything
slate swan
#

AGAIN

#

I just wrote a message and everyone stopped

azure depot
#

how do i fix this

supple thorn
hearty dust
#

help help how to fix this error

ripe harness
#

Does @bot.event stop all @bot.command() 's from executing?

slate swan
#

Perms

#

N9t

#

No i mean

hearty dust
#
import discord
from discord.ext import commands
from discord import guild
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_choice, create_option
import config

client = commands.Bot(command_prefix="?")
slash = SlashCommand(client, sync_commands=True)


@slash.slash(name="slashtest", description="hmmmmm", guild_ids=[957233126818578462])
async def _test(ctx:SlashContext):
  await ctx.send("ok") 

client.run(config.toke)
slate swan
#

Give bot perms ig

#

Idk

slate swan
ripe harness
slate swan
#

I tried reading docs but couldn’t find it

supple thorn
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

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

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

Example...
tough lance
hearty dust
#

how fix this error

tawdry bobcat
#

how to make

#

slash command

#

@tropic flame

hearty dust
#

@tawdry bobcathi

brisk zodiac
#
@client.command()
async def clear(ctx, amount=5):
    await ctx.channel.purge(limit = amount)``` Why this worked but when I typed `!clear 3` it didn't say anything
acoustic sleet
# hearty dust

ur bot prob doesnt have the perms to execute that in the server

#

change the perms

brisk zodiac
slate swan
#

Did u copy paste the code?

#

how can i check if a folder exists in a given path?

supple thorn
slate swan
#

is there any way to find APIs that used in a mobile app?

supple thorn
#

You didn't add any message

slate swan
#

Yes

brisk zodiac
#

Oh sorry i meant it didn't delete anything

slate swan
#

uh

supple thorn
slate swan
#

Any error?

#

..

brisk zodiac
#

no

supple thorn
brisk zodiac
slate swan
#

Prob u have done any silly mistake

slate swan
slate swan
brisk zodiac
#
client = commands.Bot(command_prefix="!", activity=activity, status=discord.Status.online)
slate swan
#

Show ur full code

brisk zodiac
#

wait

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.

slate swan
#

Yes!!!

#

U got it right

#

Intents issue dont give any error

#

Ok

brisk zodiac
slate swan
#

Ok

#

Bruh

#

U can paste here?

brisk zodiac
#

sorry

slate swan
#

Idk about osenv

#

Sorry

slate swan
#

message intents will be enforced from april 30
they are not to be enabled as of now

#

Oh

#

..

#

Why ppl use os?

#

What is the use of os.getenv('TOKEN')

unkempt canyonBOT
#

os.getenv(key, default=None)```
Return the value of the environment variable *key* if it exists, or *default* if it doesn’t. *key*, *default* and the result are str.

On Unix, keys and values are decoded with [`sys.getfilesystemencoding()`](https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding "sys.getfilesystemencoding") and `'surrogateescape'` error handler. Use [`os.getenvb()`](https://docs.python.org/3/library/os.html#os.getenvb "os.getenvb") if you would like to use a different encoding.

[Availability](https://docs.python.org/3/library/intro.html#availability): most flavors of Unix, Windows.
slate swan
brisk zodiac
#

I'm not sure but I turn on all the perms but still not work

tough lance
#

Wait unix has flavours?

slate swan
#

..

#

Lol

brisk zodiac
#

yes

slate swan
#

Show

brisk zodiac
#

wait

slate swan
#

Ok

#

😕

brisk zodiac
#

there

slate swan
#

Other commands work right?

supple thorn
slate swan
#

No

#

See the activity var they have more code

brisk zodiac
slate swan
#

Which command?

brisk zodiac
#

all of it except clear

slate swan
#

Name any one

brisk zodiac
#

suggest command and welcome message

slate swan
#

Ok

#

Try this

supple thorn
slate swan
#

intents

supple thorn
#

Can the bot see the channel?

brisk zodiac
tough lance
slate swan
#

As i said

#

They have more code

#

+they are saying they have other commands

brisk zodiac
#

I have more code

slate swan
#

^

supple thorn
#

Then show

tough lance
#

Do you have on_message listener?

brisk zodiac
#

okay wait

slate swan
#

intents = discord.Intents.all()
Put this above ur client variable

supple thorn
tough lance
#

Hm

brisk zodiac
slate swan
#

And send ss

brisk zodiac
slate swan
#

And ur client var will be

client = commands.Bot(command_prefix="!", activity=activity, intents = intents, status=discord.Status.online)
#

@brisk zodiac

#

Do this and show ur code

brisk zodiac
#

Traceback (most recent call last):
File "main.py", line 59, in <module>
client.run(token)
File "/home/runner/Welcoming-Bot/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/Welcoming-Bot/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/Welcoming-Bot/venv/lib/python3.8/site-packages/discord/client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "/home/runner/Welcoming-Bot/venv/lib/python3.8/site-packages/discord/client.py", line 601, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

slate swan
#

Show code

tough lance
#

Meh

brisk zodiac
#

okay wait

tough lance
#

Just go to that link and tick the member, presence and message intents

slate swan
#

Yes lol

spring flax
brisk zodiac
#

ah i fogot

swift quiver
#

how do i make a command that that command can be used in a channel?

slate swan
#

They already have client as var

slate swan
#

Huh?

swift quiver
#

like how do i make my command be used in the channel only and not any other

brisk zodiac
slate swan
#

Whole code changed tf

swift quiver
#

like how do i make my command be used in the channel only and not any other anyone?

slate swan
#

U already have intents!!

#

Cant u tell

tough lance
brisk zodiac
tropic flame
#

change the command prefix to /

slate swan
#

Its the only command i can see

tropic flame
#

client = commands.Bot(command_prefix = '/')

slate swan
#

Omfg name

tropic flame
slate swan
tough lance
tropic flame
tough lance
slate swan
tropic flame
slate swan
#

My account is older than him!!!

#

Nvmd ot

slate swan
#

Its not a slash command??

tropic flame
#

it is

slate swan
#

Huh?

#

How?

slate swan
tropic flame
#

oh nvm nvm

slate swan
#

^

tropic flame
#

u mean as in /dino so it will show dino bot commands

slate swan
#

U know what are slash commands

tropic flame
#

this ?

slate swan
#

Yes

tropic flame
#

mhm k

slate swan
#

Does that work for some reason

#

Ye

brisk zodiac
#

????

slate swan
brisk zodiac
#

oH

slate swan
#

Just ctrl + a there and ctrl + v @brisk zodiac

#

Make sure to hide token lol

brisk zodiac
#

Can I just give him the hastebin link?

slate swan
#

Ye

brisk zodiac
brisk zodiac
#

yes

slate swan
#
  • theyvsay there all commands work
    But they only have thst command
#

Ye

#

Nvmd

polar plinth
#

Someone have ban and unban code?

brisk zodiac
#

Done fixing

#

Anything else?

tough lance
unkempt canyonBOT
#

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

Bans a user from the guild.

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

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
tough lance
#

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

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

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

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

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

This all?

polar plinth
supple thorn
sullen pewter
#

Does anyone have Danny#0007 discord server invite?

#

Ty

slate swan
#
TypeError: Cannot read properties of null (reading 'click')
    at click_date (C:\Users\Admin\Desktop\norg\utilities\other\TG\gen.js:74:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async fill_discord (C:\Users\Admin\Desktop\norg\utilities\other\TG\gen.js:88:5)
    at async create_accinfos (C:\Users\Admin\Desktop\norg\utilities\other\TG\gen.js:197:5)
    at async C:\Users\Admin\Desktop\norg\utilities\other\TG\gen.js:240:21

Anyone?

sullen pewter
radiant wing
#

Can some1 show me an example of xp system in bots?

hoary cargo
radiant wing
#

Dump it to some file?

wooden vale
#

ctx.send(message.embeds[0].description)
I have this where i get the description of the replied embed. But i only want to get the mention User in the description. Someone knows how i do

radiant wing
#

Should I dump the xp number to some file?

hoary cargo
#

I think he meant 2 separate commands, quite useless to make this kind of "soft ban"

#

Also don't spoonfeed

slate swan
#
@client.command()
async def hello(ctx, args):
    await ctx.send("Hello" , components = [Button(label=args, style=1)])``` 
is something wrong in here? because i when i am typing the command in discord it is neither showing an error nor showing the output
toxic gate
#

ctx.send() doesn't have component kwarg

#

you have to subclass discord.ui.View to use buttons

slate swan
#

oh

slate swan
toxic gate
polar plinth
#

Thx

hybrid mural
#

how do i pass self as arg in cogs when i dont have self in my main method?

heavy folio
#

wdym... you dont

#

self represents the instance of the class so you dont actually pass self

slate swan
#

and the slash commands operations

hybrid mural
#

wait is it because im trying to access a command from a cog through main?

wide burrow
#

when i execute a function imported it just print in the console and not in discord

#

how can i fix

slate swan
# slate swan U know what are slash commands

What Are Slash Commands?

Slash Commands are the exciting way to build and interact with bots on Discord. With Slash Commands, all you have to do is type / and you're ready to use your favourite bot. You can easily see all the commands a bot has, and validation and error handling help you get the command right the first time.

Note: Setting the application's prefix as / will not activate the Slash Commands User Interface and Server Operations. You will have to register the Slash Commands to the Discord API to use the desired features.

What is the Ideal way of creating Slash Commands for my Bot Application (python)?

Use A Discord API wrapper.

What Wrapper Do I Use?

You can Choose From:

Discord.py
Disnake
Nextcord
Py-Cord
Hikari

How Do I create Slash Commands?

Your Desired API Wrapper Provides you with DOCUMENTATION and EXAMPLES on GITHUB.
A simple search on the web will make it possible to access those.

I am Stuck Creating Slash Commands, What do I do?

Raise an issue on Stack Overflow/Github.
Seek Help in your desired wrapper's Support Server.
Seek Help in Other Suitable Servers.

slate swan
#

HELLO

slate swan
#

How do you do options

slate swan
#

ik about disnake and nextcord

#

I heard dpy's slashes are insanely complicated pepe_exit

slate swan
#

It’s same as ext

#

oh well well

#

idk, havent used

#

It’s similar to your basic ext command

wide burrow
#

how can i make the bot to catch text from console and print it in channel

slate swan
#
import discord

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'ping':
            await message.channel.send('pong')

client = MyClient()
client.run('hidden')```
why bot not launching ?
#

Bot is launching but

#

logged on as not showing up

pure sparrow
#

why did you creat a class ?

slim ibex
#

subclassing

#

and subclass commands.Bot not Client

#

commands.Bot is a subclass of Client with commands

pure sparrow
#

oh I forgot all the "self"

slate swan
#

indent is not correct no?

pure sparrow
#

is it important to keep the class ?

proud rain
#
await ctx.send(embed = discord.Embed(description = f'"text here', color=0x2ecc71, delete_after=7))

how to set a footer on this?

pure sparrow
#

a footer ? like a description under a title ?

slate swan
pure sparrow
#
await ctx.send(embed = discord.Embed(title = "your title", description = f'"text here', color=0x2ecc71, delete_after=7))```
#

@proud rain

proud rain
#

thanks man

pure sparrow
slate swan
#

how?
def client

regal cove
#

That’s wrong u didn’t define client

cold sonnet
#

HUH

regal cove
#

What is wrong with this?

cold sonnet
#

this is not it

slate swan
#

IndentationError: expected an indented block

cold sonnet
#

this is wrong in every simple way

pure sparrow
#

why not ?

regal cove
#

Why are u sending your code here if its working?

cold sonnet
#

indentation of on_message, on_message not registered as event, client overwritten with non-existing Class

pure sparrow
#

on_message not registered as event ?

#

oh

cold sonnet
#

@bot.event / @bot.listen()

regal cove
pure sparrow
#

yeah you can do @client.event or @bot.event you choose

cold sonnet
exotic kite
#

Hello guys im making a command in my bot of customwheel

What i need in this is to make the bot choose between all the options a user gives. a random one. not by me but the user using the bot

regal cove
exotic kite
slate swan
#
import discord

client = commands.Bot(command_prefix='your prefix', intents=intents)
@client.event
async def on_ready():
      print('Logged on as', self.user)



      async def on_message(self, message):
        
        # don't respond to ourselves
        if message.author == self.user:
          
          return

        if message.content == 'ping':
          
          await message.channel.send('pong')

client = MyClient()
client.run(token)```
NameError: name 'commands' is not defined
cold sonnet
unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
exotic kite
regal cove
cold sonnet
#

yeah it doesn't

pure sparrow
#

it should be good

cold sonnet
#

no

pure sparrow
#

bruh

slate swan
cold sonnet
#

it shouldn't

pure sparrow
exotic kite
pure sparrow
#

i dont understand

regal cove
#

Test it out and see yourself if it works or not

#

And then look at the error

slate swan
#

NameError: name 'intents' is not defined

slate swan
pure sparrow
#

intents = intents

slate swan
#

NameError: name 'MyClient' is not defined

pure sparrow
#

it's your class

regal cove
slate swan
pure sparrow
#

you want to log your bot right ?

pure sparrow
slate swan
cold sonnet
regal cove
#

There is a lot wrong with that command

#

We are just correcting small things right now

slate swan
#

What is my.client for lol

#

@pure sparrow

pure sparrow
# cold sonnet ikr

bruh help us if you are smarter than us but don't say it's wrong without help us bruh

slate swan
#

ya'll not helping i'll just google up will be better except chyron but chyron

cold sonnet
#

won't spoonfeed

pure sparrow
#

yea

regal cove
slate swan
#

The syntax, random variables,….. 😤

slim ibex
#

this is NOT good

pure sparrow
#

he forgot a lot of things too

cold sonnet
#

actually I'm starting to think I should

regal cove
#

U cant use my.client of That’s not What u defined in the beggining when setting up the bot

slate swan
slim ibex
#
  1. name the variable bot when instantiating commands.Bot
  2. you are overriding client at the end, so now MyClient() will be what client holds
regal cove
#

Ur using variables u never defined

cold sonnet
#

oh 6 spaces indents

slate swan
#

Bottom line there’s nearly every error possible in that code

regal cove
#

I feel like u watched many different tutorials and they all used different variables for the same thing

slate swan
#
import discord
from discord.ext import commands

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

@bot.listen("on_ready")
async def on_ready():
  print('online')

@bot.listen("on_message")
async def on_message(message: discord.Message):
  if message.author.bot:
    return
 

bot.run('token')

stop arguing ya'll

cold sonnet
#

thanks Ashley

slate swan
#

my pleasure

#

I know my syntax is bad but that is another level

regal cove
#

Good

regal cove
#

Discord bots is the only thing im not shit at coding

slate swan
regal cove
#

So this was fun lol

pure sparrow
slate swan
slim ibex
#

he was trying to subclass so:

class Bot(commands.Bot):
  def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    
  ...

bot = Bot()
regal cove
#

Everyone in here should develop games using pygame

slim ibex
slate swan
cold sonnet
#

well innit

pure sparrow
#

is it possible to add role to someone when we start by "async def on_message(message) ?

slate swan
cold sonnet
#

Chyron were you really trying to spoonfeed like that

regal cove
#

What person

slim ibex
#
if any(message.author.id) == some_id_here:
  # code here
cold sonnet
#

the pep8 typehint aswell

pure sparrow
slim ibex
cold sonnet
#

I'm not

hybrid mural
#

is there a way to run the setup(bot) for cogs without putting it in on_ready?

slim ibex
#

override setup method

hybrid mural
#

wdym?

cold sonnet
#

setup for cogs is called automatically at load_extension

slate swan
hybrid mural
pure sparrow
#

yeah im new btw

slate swan
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.

pure sparrow
#

I just wanted to help

slim ibex
#

oh wait he meant that setup

cold sonnet
#

loading extensions is not async, you don't need to import anything and it calls setups for you

hybrid mural
#

ahh thats nice

cold sonnet
#

isn't only setup async?

#

wait

pure sparrow
cold sonnet
#

!d discord.ext.commands.Bot.load_extension

unkempt canyonBOT
#

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

Loads an extension.

An extension is a python module that contains commands, cogs, or listeners.

An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.

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

nvm yeah load_extension is async

cold sonnet
#

where you wanna call it then

hybrid mural
#

the problem is because i cant start a background task (tasks.loop) in another cog without waiting for on_ready i have to somehow load the cogs before on_ready

pure sparrow
#

burh

cold sonnet
#
async def load_extensions():
    #stuff

#run it with bot.loop?
slate swan
#

See name input aka interaction how do you do this on discord.py slash commands

#

Bottom line I’m using ctx rn but I wanna switch to / commands

cold sonnet
#

use commands

#

now I'm idiotic

pure sparrow
#

Is there a way to add a role when I started by "async def on_message" please ?

slate swan
#

Bro pls fix the syntax I beg

pure sparrow
cold sonnet
slate swan
pure sparrow
#

just want to get a command to add role

cold sonnet
#

if not message.content.startswith("!"): ?

slate swan
cold sonnet
#

if you want commands, use commands

pure sparrow
#

to hide it

#

ok thanks for the help...

cold sonnet
#

you don't have to

#

we can't do anything with the id

#
@bot.command()
async def hello(ctx):
    await ctx.send("Hello!")
#

this is.... basically what a command is built like

pure sparrow
#

I don't want ctx

slate swan
cold sonnet
#

you have to get ctx

hybrid mural
#

tbh its the easiest wayy

pure sparrow
#

to add a role ?

slate swan
hybrid mural
#

and you mostly need it

slate swan
cold sonnet
#

no

slate swan
#

Or something I forgot the method

pure sparrow
cold sonnet
#

await ctx.author.add_roles()

slate swan
cold sonnet
hybrid mural
#

yo boys

slate swan
#

Yo

hybrid mural
#

how would i start a tasks loop from a cog

#

im baffled i cant pass self from main since i dont have self

cold sonnet
#

in __init__

hybrid mural
#
class gif_cog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.every_10_min.start(self)

like this right?

#

the loop is every_10_min

cold sonnet
#

don't think you gotta pass self

#

your task is in the cog?

slim ibex
#

yes you do lol

cold sonnet
#

yeah cuz you call it from self

cold sonnet
slim ibex
#

__init__ is an instance initializing method

#

why would you make it a class or static method

cold sonnet
#

what

#

not not pass self to init

#

not pass self when calling the start of the task

slim ibex
#

oh the task

#

LOL

#

my fault

cold sonnet
#

yeah I was missunderstandable there

#

nah

#

when I'm thinking of something, I don't think that other people can't read my mind

hybrid mural
#

ah ok

slim ibex
#

well what you can do @hybrid mural is:

class MyCog(commands.Cog):
  def __init__(self, bot):
    self.bot = bot
    self.my_task.start()
  
  @tasks.loop(seconds=5.0)
  async def my_task(self):
    ...
hybrid mural
#

works now, the problem was that i did a task.before_loop and waited untul bot was ready, while he already was ready

#

thanks for the help boys

wanton cipher
#

How can I raise my own MissingRequiredArgument?

slim ibex
#

or you could use on_command_error and send a custom message when that error occurs

wanton cipher
slate swan
#
class CustomMissingArgument(MissingRequiredArgument):
  super().__init__(do your stuff)
slim ibex
#

^

cold sonnet
#

never used Greedy before

#

what's the docs to it

slate swan
#

idek when it is even used

slim ibex
#

!d discord.ext.commands.Greedy

unkempt canyonBOT
#

class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
slate swan
#

ew

slim ibex
#

* better

cold sonnet
#

most input errors are silently discarded

slate swan
cold sonnet
wanton cipher
#

for context: async def command_kick(self, ctx: commands.Context, users: commands.Greedy[disnake.Member], reason: Optional[str]):

cold sonnet
#

it eats up the error

wanton cipher
#

exactly

slim ibex
#

yeah its greedy

vale wing
#

You typically use greedy to make a list of args but in the middle

slate swan
#

greedy is too dumb

cold sonnet
wanton cipher
#

oh

cold sonnet
#

in your case for sure

vale wing
#

If the list of args is last, you just use *args: Type

slate swan
cold sonnet
wanton cipher
slim ibex
#

greedy?

cold sonnet
#

oh well

#

I thought it's for one member

wanton cipher
#

this is my issue xD

cold sonnet
#

I'm out there

#

why don't you set it to None by default

#

and check in the command if it's None

dull terrace
#
c.execute("INSERT INTO olie(caffiene) VALUES(?)", (10000mg,))```
narrow grail
#

how to test if the ctx message was send on a certain guild to send a message?

cold sonnet
#

this ain't activities

#

Setting 'Playing' status

await client.change_presence(activity=discord.Game(name="a game"))

Setting 'Streaming' status

await client.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))

Setting 'Listening' status

await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))

Setting 'Watching' status

await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

narrow grail
#
client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching,name="test"))```
dull terrace
cold sonnet
#

just do the same arg in the constructor

cold sonnet
#

discord.Client(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

#

there should be a better way

narrow grail
narrow grail
#

if not, he says for example "test didn't worked, wrong guild"

slate swan
#

hi i want help

narrow grail
dull terrace
#

yeah

narrow grail
#

ok nice thanks

toxic thicket
#

@bot.command()
async def преды(ctx, member: discord.Member = None):
cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR)""")
base.commit()
print(1)
global warnings
warnings = cursor.execute("SELECT * FROM warning WHERE userid = ?", (ctx.author.id,)).fetchone()
print("работает")

if member is None:
       await ctx.send(f"Проверка по базе данных...\nПроверка прошла.\n{ctx.author.name} У вас {warnings[2]} предупреждений")
else:
        await ctx.send(f"Проверка по базе данных...\nПроверка прошла.\n{member.name} У вас {warnings[2]} предупреждений!")
why when a member is mentioned, their warn are shown??
dull terrace
cold sonnet
#

it's what you wrote

toxic thicket
#

What?

cold sonnet
#

what

#

also what's base

slate swan
#

nvmd

cold sonnet
#

uh

#

you can have slash commands with client?

dull terrace
#

wtf how many slash commands do you have

#

they take up like 1 line

#

oh you mean literally everything that the commands do

narrow grail
toxic thicket
#
@bot.command()
async def преды(ctx, member: discord.Member = None):
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR)""")
    base.commit()
    print(1)
    global warnings
    warnings = cursor.execute("SELECT * FROM warning WHERE userid = ?", (ctx.author.id,)).fetchone()
    print("работает")
 
         
    if member is None:
           await ctx.send(f"Проверка по базе данных...\nПроверка прошла.\n{ctx.author.name} У вас {warnings[2]} предупреждений")
    else:
            await ctx.send(f"Проверка по базе данных...\nПроверка прошла.\n{member.name} У вас {warnings[2]} предупреждений!")
dull terrace
toxic thicket
#

why when a member is mentioned, their warn are shown??

slate swan
#

ValueError: components must be a WrappedComponent, a list of ActionRow or a list of WrappedComponent

#

help?

cold sonnet
#

but why does rzwo have 7/8 spaces indents

dull terrace
narrow grail
#

is it possible that the bot can use server emojis without having nitro?

azure tulip
#

what is it how to fix it?

slim ibex
#

install it..

#

you don't need bot in a view iirc

slate swan
#

self.bot.get_channel(logsid)

#

..