#discord-bots

1 messages Β· Page 757 of 1

red sundial
#

what fork do you use?

slate swan
#

disnake

red sundial
#

very cool

slate swan
#

yeah

red sundial
#

i use pycord its very shitty

#

lol

slate swan
#

just move to disnake lol

red sundial
#

i will at some point

slate swan
#

very easy

cloud dawn
#

This exactly

red sundial
#

pycord is not pythonic at all

slate swan
#

dang

red sundial
#

very poor code

slate swan
#

that sucks

cloud dawn
#

pycord gave me a stroke

red sundial
#

like if you look at their examples

#

its just so bad

slate swan
red sundial
#

the only reason i picked pycord is because it doesn't require any changes from dpy code

slate swan
#

disnake is the same

red sundial
#

oh really

slate swan
#

you just change the word discord to disnake and your done

cloud dawn
#

Internals of dispy is worse

slate swan
#

im not sure i havent checked

red sundial
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

slate swan
#

panda really?

cloud dawn
#

πŸ˜‚

slate swan
#

😭

slate swan
#

pycord really

@bot.command()
async def joined(ctx, member: discord.Member):
    """Says when a member joined."""
    await ctx.send(f"{member.name} joined in {member.joined_at}")
#

joined?

red sundial
#

lollll

slate swan
#

yes

#

the inv with the button

#

ikr

#

Srw_bored urls work too

ruby flame
#

ok i have a complex here...
my frens keep telling me to use discord.js but i dont wanna learn new lang
so pls tell me python can do all the things which you can do in discord.js

slate swan
#

you can probably do everything djs can

#

?

#

Can anyone help?

slate swan
cloud dawn
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

β€’ Identify the exception raised (in this case ZeroDivisionError)
β€’ Make note of the line number (in this case 2), and navigate there in your program.
β€’ Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

cloud dawn
#

And reversed

slate swan
#

did you provide an id inside the get_channel?

cloud dawn
# slate swan Idk what u mean by that lol
Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:
Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

β€’ Identify the exception raised (in this case ZeroDivisionError)
β€’ Make note of the line number (in this case 2), and navigate there in your program.
β€’ Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
slate swan
#

why are you even hiding the id

#

Idk tbh

#

you cant do anything with it

slate swan
#

also , i dont see the channel being defined inside the function

ruby flame
#

so.... ik most are similar.... just forks of discord.py.... i am fed up now....
pls just tell me one name(library) to start with making bot

slate swan
#

im to slow

slate swan
#

πŸ§‘β€πŸ¦―

#

alright

ruby flame
slate swan
#

dpy

cloud dawn
#

disnake

slate swan
#

hikari seems over the top

#

disnake is like perfect

slate swan
cloud dawn
#

tbf we need a whole new library.

ruby flame
cloud dawn
slate swan
#

Any way to make discord bot livestream a clip?

slate swan
ruby flame
#

k imma go w/ dissnake

slate swan
#

great

#

!pypi disnake

unkempt canyonBOT
slate swan
#

panda really

#

xd

slate swan
#

🚢

cloud dawn
#

πŸ˜‚

slate swan
slate swan
#

bot's cant stream in a vc

cloud dawn
slate swan
slate swan
cloud dawn
#

It's just where he is getting the mp3 from that is the matter.

cloud dawn
slate swan
cloud dawn
#

Idk what you mean by stream you can just use playback.

#

It's certainly not easy though

slate swan
ruby flame
#

i believe i can watch discord.py yt tutorials for starting in disnake?

cloud dawn
slate swan
edgy finch
slate swan
cloud dawn
#

!d discord

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

and the examples folder in github repo

edgy finch
#

!resources here u go

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.

ruby flame
slate swan
#

is it not possible to make a self bot anymore?

slate swan
slate swan
cloud dawn
slate swan
edgy finch
#

ya

slate swan
#

TOS

#

i just wanted to make one to count how many servers I am in

cloud dawn
#

time to sleep

slate swan
#

but I get an event loop closed everytime

slate swan
slate swan
slate swan
slate swan
#

and log in

#

it shows how many servers u r in

edgy finch
#

!resources

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.

cloud dawn
#

For all problems use this dude @unkempt canyon

edgy finch
#

ya ik

#

@unkempt canyon how to make bots

slate swan
#

OwO_cute it can work as a interpreter ( !e command ) , or lookup for the library docs . not actually talk lol

edgy finch
#

ik

#

duh

ruby flame
#

if the devs want they surely can?

#

i tried a bot called discortics

edgy finch
#

okay...

#

nice

slate swan
#

oo

edgy finch
#

i made a bot but hes not respondind

#

ding

slate swan
#

@slate swan

import os
import sys
import asyncio
import discord
import random
import json
import os
from discord.ext import tasks
from discord import File, Message
from discord.ext import commands
from discord.ext.commands import Bot
from discord.ext import tasks
from discord import Webhook, RequestsWebhookAdapter


bot = commands.Bot(command_prefix="s")
bot.remove_command("help")


h = bot.get_channel(706675003952857109)
@bot.event
async def on_connect():
    print (f'bot \nLogged in as: {bot.user}')


@tasks.loop(seconds = 62)
async def myloop():
    await h.send("Remember guys! No profanity :)")


myloop.start()

bot.run("jojojojoj")
edgy finch
#

responding*

#

okay tysm

slate swan
#

?

#

since your bot is not running and you defined that variable

edgy finch
#

???

slate swan
#

Lemme see the error i get when i move it into the area

slate swan
edgy finch
#

can u put the correct codes to make a bot

slate swan
#
@bot.event
async def on_connect():
    print (f'Advertise bot \nLogged in as: {bot.user}')

h = bot.get_channel(706675003952857109)

@tasks.loop(seconds = 62)
async def myloop():
    await h.send("Remember guys! No profanity :)")


myloop.start()
edgy finch
#

tysm

slate swan
#

put it inside your task loop

#

oh im sorry, its been like a year since ive coded lol

#
@bot.event
async def on_connect():
    print (f'Advertise bot \nLogged in as: {bot.user}')


@tasks.loop(seconds = 62)
async def myloop():
    h = bot.get_channel(706675003952857109)
    await h.send("Remember guys! No profanity :)")
edgy finch
#

@slate swan can u put the correct code then

slate swan
slate swan
slate swan
#

why is he thanking me

edgy finch
#

ya, thank u so much

slate swan
edgy finch
slate swan
#
File "C:\Users\Danny\Desktop\VSProjects\securitybot\main.py", line 28, in myloop
    await h.send("Remember guys! No profanity :)")
AttributeError: 'NoneType' object has no attribute 'send
```@slate swan
slate swan
edgy finch
#

which one is correct

slate swan
#

706675003952857109

#

i just right clicked on the channel and pasted after clicking copy id

visual island
slate swan
#

?

#
@tasks.loop(seconds = 62)
async def myloop():
    h = bot.get_channel(706675003952857109)
    await bot.wait_until_ready()
    await h.send("Remember guys! No profanity :)")
``` @visual island
#

right there?

visual island
#

before get_channel

slate swan
#

ohh

slate swan
#
@tasks.loop(seconds = 62)
async def myloop():
    await bot.wait_until_ready()
    h = bot.get_channel(706675003952857109)
    await h.send("Remember guys! No profanity :)")
slate swan
slate swan
#

and yes , do what icy said

slate swan
#

@slate swan```py
@tasks.loop(seconds = 62)
async def myloop():
await bot.wait_until_ready()
h = bot.get_channel(706675003952857109)
await h.send("Remember guys! No profanity :)")

#

right here, right?

#

yea , should work

#
File "C:\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
```@slate swan
visual island
#

you forgot to await something

slate swan
#

do i need to await my bot.run?

visual island
#

no

#

but

#

show your full traceback

slate swan
#

discord.errors.LoginFailure: Improper token has been passed.

#

is in there

#

the error says pretty much itself

#

Improper token has been passed.

#

@slate swan this is handy

#
TYPE    STRUCTURE    EXAMPLE
User    <@USER_ID>    @split rivet
User (Nickname)    <@!USER_ID>    @split rivet
Channel    <#CHANNEL_ID>    [#103735883630395392](/guild/267624335836053506/channel/103735883630395392/)
Role    <@&ROLE_ID>    <@&165511591545143296>
Standard Emoji    Unicode Characters    πŸ’―
Custom Emoji    <:NAME:ID>    :mmLol:
Custom Emoji (Animated)    <a:NAME:ID>    :b1nzy:
Unix Timestamp    <t:TIMESTAMP>    <t:1618953630>
Unix Timestamp (Styled)    <t:TIMESTAMP:STYLE>    <t:1618953630:d>
#

ok, so there is no way to count the servers that I am in other than manually doing it?

final iron
#

Returns a list of the guilds the bot is in

slate swan
#

I am talking about my own account, which would be a selfbot

#

hes using a selfbot

#

they are doing that for their user account

final iron
#

bruv

#

Yall sent rule 5?

slate swan
#

i seen it

#

it shows number of servers u r in

slate swan
#

late night programing by yourself is the bestyert

final iron
#

My commands_ran command actually kicked my ass

slate swan
#

ctrl+c , ctrl+v from stackoverflow is best

final iron
#

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

final iron
#

This actually looks like shit

slate swan
final iron
#

It works doe

slate swan
#

seems good to me , except for the use of f strings

final iron
#

wdym?

#

How are f-strings bad?

slate swan
#

sql injection but your fine

#

f strings in sql queries is bad

#

hes not getting user input

final iron
slate swan
#

yea its fine there , just saying

final iron
slate swan
#

plus you can inject anything with f string

final iron
#

I'm not getting any user input

#

But lets say I wanted to store a welcome channel, how would I do it?

slate swan
#
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
#

ez

slate swan
final iron
#

So how is this better than an f stirng?

slate swan
#

thats how you dont get sql injections

#

? gets replaced by the value

slate swan
#

but just in that format

final iron
slate swan
#

its the same thing?

final iron
#

wdym?

slate swan
#

its the same thing

final iron
#
    async def add_commands_ran(self, ctx: commands.Context) -> bool:
        cursor = await self.connection.cursor()
        await cursor.execute(f"SELECT commands_ran FROM commands_ran WHERE user_id={ctx.author.id} and guild_id={ctx.guild.id}")
        is_none = await cursor.fetchone()
        if is_none is None:
            await cursor.execute(f"""INSERT INTO commands_ran(user_id, guild_id, commands_ran)
                                    Values({ctx.author.id}, {ctx.guild.id}, 1)""")
            await self.connection.commit()
            return True
        else:
            await cursor.execute(f"""DELETE FROM commands_ran WHERE user_id={ctx.author.id} and guild_id={ctx.guild.id}""")
            await cursor.execute(f"""REPLACE INTO commands_ran(user_id, guild_id, commands_ran)
                                    Values({ctx.author.id}, {ctx.guild.id}, {is_none[0] + 1})""")
            await self.connection.commit()
            return True
#

This is what I use to add the commands that were ran

#

I shouldn't be worried about sql injection in this case, correct?

slate swan
#

Yeah your good

#

sql injection happens on user input

final iron
flat flower
#

Hey, who wants to have a fun conversation with me in the voice chat? I will share the topic with you when you join

spring flax
#

The variable name though lol

final iron
#

is_none

#

I had no idea what to name it

#

My naming is actually shit

slate swan
#

its good practice

final iron
#

I'm going to get bullied when I publish my bot on github

slate swan
final iron
slate swan
slate swan
final iron
#

Oh wait, I have a custom prefix command which takes user input. Would I have to change it to prevent injection?

slate swan
#

and here's the reason why the placeholder prevents the injection ```
Between Cache and Execution, there is an additional step: Placeholder Replacement. At this point, the placeholders are replaced with the user’s data. However, the query is already pre-compiled (Binding), so the final query will not go through compilation phase again. For this reason, the user-provided data will always be interpreted as a simple string and cannot modify the original query’s logic. Thus, the query will be immune to SQL Injection vulnerabilities for that data.

#

sql injection happens i.e you wait for a name and he inserts sql statements and you will blindly execute the statement which can be used for bad stuff

#

it's not the query but just a value if you use placeholders

final iron
spring flax
slate swan
final iron
slate swan
slate swan
spring flax
#

why still f strings though

final iron
slate swan
#

sorry i just copy paste the above part

slate swan
final iron
#

This is the table structure

slate swan
final iron
#

I meant like this:

INSERT INTO prefixes ( id , prefix ) VALUES ( ? , '?'), (id , prefix )
spring flax
#

is this aiosqlite?

slate swan
#

you can do that too , but it doesnt matter

slate swan
slate swan
final iron
#

So it automatically gets converted to text?

slate swan
#

yessir

final iron
#

Good

slate swan
final iron
#

When I don't use quotes sqlite3 yells at me (if its meant to be text)

slate swan
#

it doesnt execute it as a statement but as a str

slate swan
final iron
#
            await cursor.execute(f"""REPLACE INTO prefixes(guild_id, prefix)
                                    Values({ctx.guild.id}, '{prefix}')""")
#

If I removed the quotes around {prefix} I get a lot of angry errors

#

So do I just not have to worry about that if I'm using the question marks?

slate swan
#

how can i make it so i can check a date and how much time has passed since that date

slate swan
final iron
#

Thanks

slate swan
final iron
#

So I'll change this command and start using the question marks instead

slate swan
final iron
heavy radish
#

Whaaaat?

final iron
#

Thats what I do to check my uptime

slate swan
heavy radish
#

Oh

#

Don't kill me

#

I'm sorry. Figure it out

slate swan
final iron
final iron
#

Store the timestamp and subtract from the current time

#

Works like a charm for my uptime command

#

Shit I lost the code

slate swan
#

πŸƒβ€β™‚οΈ i save the first datetime for the boot as a bot property and subtract it from current datetime to get the uptime

honest vessel
edgy finch
#

dont break the last rule

#

of this group

#

no foul language

spring flax
#

anyone knows where self.persistent_views_added = True is needed for making persistent dropdown?

heavy radish
#

Nvm, something is still wrong

final iron
#

Since discord auto converts

slate swan
final iron
#

I can just pass the timestamp into <t:timestamp>

heavy radish
#

aghhh

final iron
#

And I'm chilling

heavy radish
#

Thank you

slate swan
#

i put it in a yaml codeblock so i need it to be a timedelta

edgy finch
#

@slate swan still my bot is not responding

slate swan
edgy finch
#

wat to d

final iron
#

I just send it in a normal embed description

honest vessel
#

ctx.message.created_at

edgy finch
#

okay

final iron
#

Looks plain

#

I might want to spice my embeds up

honest vessel
#

maybe print what timezone

slate swan
# final iron

looks good but you should show how much time has passed

edgy finch
#

bot.event
async def on_connect():
print (f'Advertise bot \nLogged in as: {bot.user}')

@tasks.loop(seconds = 62)
async def myloop():
h = bot.get_channel(706675003952857109)

final iron
edgy finch
#

wait

slate swan
#

i just mention the uptime in my botinfo cmd

slate swan
slate swan
final iron
spring flax
heavy radish
#

The commands work but when I do the second command help g. The first command executes with it

slate swan
slate swan
slate swan
#

πŸ§‘β€πŸ¦―

edgy finch
#

im sending the code in dm @slate swan

#

its difficult for me

slate swan
honest vessel
#

@heavy radish checkup invoke decoration for group commands

final iron
#

Am I doing anything wrong: <R:{round(self.bot.start_up_time)}>

#

?

#

Its not showing as a timestamp

spring flax
#

what's bot.start_up_time

edgy finch
#

idk the codes are not working

#

i mean i cannot copy and paste

#

i tried

final iron
#

This is the result I'm getting

slate swan
#

<t:164247925:R>

final iron
#

Oh alr. My first timestamp was like <t:{round(self.bot.start_up_time)}>

#

And it was working

slate swan
#

yeah but rn you have <R:timestamp>

final iron
#

I know

#

I was confused whether to put it at the end or the beginning

#

Oh I didn't have to put it because it defaulted to what I wanted

#

Looking fresh

slate swan
#

can someone send me all the time formats like unix delta and others

edgy finch
#

put it in the end

honest vessel
#

@slate swan can u give url for page?

final iron
#

But its here. You can search for Timestamp Styles and it will show up

spring flax
edgy finch
#

im super happy

#

it started to work

#

like after 10th toutorial

slate swan
edgy finch
#

!resources

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.

slate swan
#

that one is exact

slate swan
honest vessel
#

@slate swan thanks does them format work in d.py/disnake or ?

slate swan
slate swan
slate swan
honest vessel
#

ah sweet

slate swan
#

including about mes

final iron
#

You can send the timestamps yourself

#

<t:63839262281:R>

astral pilot
#

anyone knows a bot that can send a message on a specific time

honest vessel
#

will be in handy showing how longa stream been running

round robin
#

how?
broken code:```py

@bot.event
async def on_command_completion(ctx):error:py

async def on_command_completion(ctx):
^

SyntaxError: invalid syntax```

#

i dont get whats wrong

slate swan
slate swan
honest vessel
#

bot.event?

round robin
slate swan
#

show that part

honest vessel
#

show error msg

slate swan
round robin
#

# Setup the game status task of the bot
@tasks.loop(minutes=1.0)
async def status_task():
    await bot.change_presence(activity=nextcord.Game(config["status"])
#

thats the status part

slate swan
#

is the event inside the function?

#

nvm.

#

you didnt close the bracket

round robin
#

oh

#

my editor didnt even catch that

slate swan
#

is it smthing like sublime

round robin
#

no

#

its a editor in browser

spring flax
slate swan
#

thats not really a property of a view

spring flax
#

oh...i see

slate swan
#

if a view has timeout = None , and all the items in the view has a custom id , it will be persistent

slate swan
round robin
#

is there no get_message function?

#

i want to get a message then message.edit new stuff

grim oar
#

there's fetch_message

#

Hmm

slate swan
slate swan
unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
grim oar
#

O yeah it's in TextChannel

slate swan
slate swan
round robin
slate swan
slate swan
round robin
grim oar
slate swan
slate swan
round robin
#

oh

#

i knew it used it before

#

just didnt know how to or what it needed lol

grim oar
#

You can't cache it if it's not sent on establishing a connection tho

round robin
#

getting a channel is just await bot.get_channel(id) right

grim oar
round robin
#

ok

grim oar
slate swan
#

oh yeah that

#

its static

grim oar
#

it's a subroutine!

slate swan
grim oar
#

aka a normal function

slate swan
#

oh

#

lol

slate swan
#

you dont await it

grim oar
slate swan
#

sarthak youre slow

slate swan
# slate swan why no get?

Caching messages would be a mess for your memory, especially when you look at how much RAM caching only members takes ^^

slate swan
spring flax
#

though if you have a guild object already, it's better to use guild.get_channel(channel ID)

slate swan
#

it's existent but cannot be used , for the cache thing we talked earlier

astral pilot
slate swan
unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
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
#

!d datetime.datetime.now use this to check current time

unkempt canyonBOT
#

classmethod datetime.now(tz=None)```
Return the current local date and time.

If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).

If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*’s time zone.

This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
slate swan
#

if the time is same as the time you want , do your stuff , else dont

astral pilot
#

can u do an example πŸ™‚

slate swan
#

this keeps running every 24 hrs

slate swan
#

hey

#
Traceback (most recent call last):
  File "F:\backup\Fate\init.py", line 12, in <module>
    bot.load_extension('cogs.Inventory')
  File "C:\Users\rajes\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\rajes\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 609, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Inventory' raised an error: AttributeError: module 'discord.ext.flags' has no attribute 'add_flag'

#

why i m getting this error

#

even though add_flag is an attribute

spring flax
slate swan
#

there's no ext.flags iirc

#

never saw that

spring flax
#

There is this

slate swan
#

!d discord.ext.commands.Flag

unkempt canyonBOT
#

class discord.ext.commands.Flag```
Represents a flag parameter for [`FlagConverter`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.FlagConverter "discord.ext.commands.FlagConverter").

The [`flag()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.flag "discord.ext.commands.flag") function helps create these flag objects, but it is not necessary to do so. These cannot be constructed manually.
slate swan
#

yea but they import it from ext

#

It's not in ext.flags

#

a command object has that attribute right?

#

It's in ext

#

And there is no add_flag method existing at all.

slate swan
#

maybe updated

spring flax
#
async def run_once(self):
    await self.bot.wait_until_ready()
    self.add_view(DropdownView())

So...I have this function in a cog. I want to import it to the main file and do

loop = asyncio.get_event_loop()
loop.create_task(run_once())```
I'm a bit confused on where to put `self`
slate swan
#

i dont know whats new

heavy radish
slate swan
#

you can do it inside the __init__ or setup() function

spring flax
#

you mean make the loop there?

heavy radish
#

It worked yesterday

slate swan
slate swan
spring flax
#

!d discord.TextChannel.set_permissions

unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

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

because i was using it

#

You need to pip install discord-flags to get what you want :)

spring flax
#

set_permissions

heavy radish
#

ok

heavy radish
#

What permission is my BOT missing?

slate swan
slate swan
spring flax
slate swan
#

I am not the developer of that library, ask the developer why they removed the library ;)

slate swan
heavy radish
slate swan
slate swan
spring flax
spring flax
#

yeah

heavy radish
#

Does the position of the BOT matter?

vale wing
#

Manage channels

heavy radish
#

It's enabled

slate swan
#

class TheCog(Cog):
   def __init__(.... -> None:
      loop = asyncio.get_event_loop()
      loop.create_task(self.run_once())

   async def run_once(self):
      await self.bot.wait_until_ready()
      self.add_view(DropdownView())
vale wing
heavy radish
#

It edits permission of everyone role

vale wing
#

Does the channel have any other overwrites

vale wing
heavy radish
#

Alr gave it

heavy radish
slate swan
#

the bot should have the permissions you want to edit

#

along with manage_channels

heavy radish
#

Let me try agaib. Brb

#

BTW, Ping if u want me to reply

vale wing
#

If it has any overwrites for roles that the bot has and those overwrites are manage channel = false then you need to remove those or add additional overwrites for the bot set to true

#

Imma check docs maybe it tells what permission exactly you need

#

!d discord.TextChannel.set_permissions

unkempt canyonBOT
#

await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sets the channel specific permission overwrites for a target in the channel.

The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.

The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.

If the `overwrite` parameter is `None`, then the permission overwrites are deleted.

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

Yeah it's manage roles

heavy radish
#

I've got that enabled

#

Let me check other roles

heavy radish
#

which I can't remove

vale wing
heavy radish
#

Doesn't work. I've tried other server and it works

vale wing
#

Does the bot even have the permission to see the channel

heavy radish
#

yes

vale wing
heavy radish
vale wing
#

Not recommended to give admin perms to bots but it will work for sure

vale wing
#

@heavy radish you don't mind inviting me to the server so I can see myself?

heavy radish
#

It's not mine

vale wing
#

Oh

heavy radish
#

It's a public server and i can't give power

spring flax
# slate swan <@!751814647346102303>

it says DiscordSupport object has no attrbiute add_view

    
class DiscordSupport(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        loop = asyncio.get_event_loop()
        loop.create_task(self.run_once())


    async def run_once(self):
        await self.bot.wait_until_ready()
        self.add_view(DropdownView())
vale wing
#

@heavy radish try printing the manage_channel permission for the bot in the channel

#

It's like

#

!d discord.TextChannel.permissions_for

unkempt canyonBOT
#

permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").

This function takes into consideration the following cases...
vale wing
#

And Member has a similar method they work the same iirc

slate swan
slate swan
spring flax
#

yeah I realized but not sure what to do lol

slate swan
#

whaty r u trying to do?

jovial plover
#
    print(before)
    print(after)

Nothing happens.. I have intent enabled as well.

bot = commands.Bot(command_prefix='!', intents=intents)
spring flax
#

add the persistence view when the bot is ready

spring flax
jovial plover
#

😌 ty

#

What is different between

discord.on_member_update(before, after)
discord.on_user_update(before, after)

spring flax
#

!d discord.on_user_update

unkempt canyonBOT
#

discord.on_user_update(before, after)```
Called when a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") updates their profile.

This is called when one or more of the following things change:

β€’ avatar

β€’ username

β€’ discriminator...
slate swan
#

user is a user obj and member is a member obj

spring flax
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

β€’ nickname

β€’ roles

β€’ pending...
spring flax
slate swan
#

their aliases

spring flax
#

No?

grim oar
#

Member is subclass of User

slate swan
#

^

grim oar
#

Member provides more guild specific functionality

slate swan
# honest vessel why not?

if you leak your token your bot can do anything so thats why its recommended to only add the perms you need

honest vessel
#

well stop leak token πŸ˜„

#

aka dotenv .env

slate swan
#

not recommended still

honest vessel
#

my bot is owner

slate swan
#

wut

spring flax
#

Lol

honest vessel
#

of guild

slate swan
#

did you gaved your bot owner?

honest vessel
#

cant do that

spring flax
#

!d discord.ext.commands.Bot.create_guild

unkempt canyonBOT
#

await create_guild(*, name, region=<VoiceRegion.us_west: 'us-west'>, icon=..., code=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

Bot accounts in more than 10 guilds are not allowed to create guilds.
spring flax
#

this?

honest vessel
#

but create server from bot n invite urself

#

apperently u cant make slash commands wen bot is owner

#

n i used template wen setup guild for easier start

alpine vault
#

Isn't this how I make a request?

import requests
import os

url = "https://discordapp.com/api/users/889705507286310972"

payload = {}
headers = {"Authorization": "{{" + os.getenv("BOT_TOKEN") + "}}"}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

BOT_TOKEN is my discord bot token.

No getting any errors but all I get is an {"message": "401: Unauthorized", "code": 0} printed on the screen. What am I doing wrong here?

jovial plover
#

how do you get nickname update on discord.on_user_update

slate swan
#

There is no on_user_update event.

scenic fulcrum
#

@slate swan

slate swan
alpine vault
#

I did

import requests
import os

url = "https://discordapp.com/api/users/889705507286310972"

payload = {}
headers = {"Authorization": "{{" + os.getenv("BOT_TOKEN") + "}}"}

response = requests.request("GET", url, data=headers)

print(response.text)

And I got

[some more stuff was printed on the screen]
  <p>Your client has issued a malformed or illegal request.  <ins>That’s all we know.</ins>

Am I sending too many requests or something? Should I be concerned ?

slate swan
#

You're looking for the on_member_update event.

#

Which gives Member objects back which contains the nickname attribute.

jovial plover
#

Well i mean, im using on_member_update and it doesnt return nickname change

#
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_member_update(before, after):
    # print(before)
    print(after.nickname)```
slate swan
#

And not

Authorization: {{<Token>}}
#

Which is what you have

alpine vault
#

Oh now it worked

#

Great, thanks!

maiden fable
#

BTW would be better to use internals lol

fervent shard
#
@bot.command(pass_context = True)
@commands.has_permissions(manage_roles=True)
async def mute(ctx, member: discord.Member,*, reason=None):
    if member == ctx.author:
       em1=discord.Embed(description=f"**you** cannot `mute` yourself", colour=discord.Colour.red())
       await ctx.send(embed=em1)
    else:
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="muted loser")
        x = get_role(925322561775099934)
        x1 = get_role(925320902692974613)
        x2 = get_role(918684634341072929)
        x3 = get_role(919183869264146522)
        x4 = get_role(919191088365994004)
        x5 = get_role(923187785303728148)
        x6 = get_role(924258916106403871)
        await member.remove_roles(x, x1, x2, x3, x4, x5, x6)
        em2=discord.Embed(description=f"{member.mention} has been `muted` for **{reason}**", color=discord.Colour.green())
        em3=discord.Embed(description=f"{member.mention}, you have been `muted` for **{reason}**", colour=0)
        await ctx.send(embed=em2)
        await member.send(embed=em3)
        await ctx.add_roles(member, mutedRole)```
the x variables come up as errors but it doesnt say which error it is
slate swan
#

guys how can i display when my bot connects to a website with aiohttp?

honest vessel
#

display?

slate swan
grim oar
#

Make a task which should make a POST request to the server?

slate swan
#

so make a request? to connect to the endpoint

#

and then print it? orrrrrrrrrr

grim oar
#

What type of communication technique the server use? Raw tcp/ip, websockets or http sessions? If latter then yeah create a task which should run and make POST req when the bot is ready

spring flax
#

when I do channel = await guild.create_channel(...) how do I set the channel topic to the ID of what was just created?

spring flax
# grim oar wdym

like if I make the channel and it's Id is 1234, how do I set that in the channel topic

grim oar
slate swan
grim oar
slate swan
grim oar
spring flax
slate swan
grim oar
#

The protocol is same, hyper text transfer protocol, the method is diff!

slate swan
#

so just make a POST request and when i do just print that its ready?

grim oar
#

well you sent the payload to the server, now do whatever you like

slate swan
grim oar
#

What you talking about lol, you asked me to tell how to make a server aware that your bot is connected to discord, so after you make the request do whatever you wanna do lol it doesn't matter

idle saffron
#

Hello!!
Hope you all are doing well.
Im working in a discord bot, but i need some help in get the list of users from servers.
If anyone wants to help me I will be really thankful!
Great night/day to everyone

grim oar
#

!d discord.Guild.members

unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
grim oar
#

Use that

idle saffron
#

Hey thanks!

maiden fable
#

@idle saffron it needs members intent BTW

spring flax
#

ah okay I was hoping I didn't need to make another API call

#

is that the only way?

maiden fable
#

Actually u will have to do another API call

#

Since u won't have the ID before making the channel

honest vessel
#
channel = await create(...
await channel.edit(topic=channel.id)
``` kinda
maiden fable
#

Yea this is what u'll have to do

grim oar
#

Shebang

maiden fable
#

???

boreal ravine
grim oar
maiden fable
#

whose

maiden fable
#

Ah

idle saffron
#

Indeed im making a discord mass dm bot, someone can help me pls?

grim oar
#

No

honest vessel
#

lol

idle saffron
#

I just need help with few things

honest vessel
#

monka

maiden fable
#

Still

honest vessel
#

@idle saffron turn on roblox instead

boreal ravine
#

why

slate swan
velvet tinsel
slate swan
#

i should go to sleep tho its 3am

honest vessel
#

havnt slept for two days :/

velvet tinsel
#

What

#

Get sleep right now

velvet tinsel
slate swan
waxen granite
#

How do i send msg whichsends the perms required by the bot when a cmd is executed but the bot doesnt have the permission

grim oar
#

Use error handlers

waxen granite
#

I do but it doesnt work, i guess its done by putting the code in every single command

slate swan
#

else the error wont be raised

green bluff
#

how would i make something like this but sort it out with roles

#

and if the roles r the same

#

use alphabetical order

#

and create an exeption for roles like staff and owner

#

would that be hard

#

no answer = guessing its hard

slate swan
#

!e py a = ['z' , 'a','s'] print(sorted(a))

unkempt canyonBOT
#

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

['a', 's', 'z']
green bluff
#

how would i sort out

#

what is top roles

#

with exception of staff and owner

#

im kinda making like a ranking system

slate swan
#

remove the staff and owner role from the list before sorting

green bluff
#

?

#

how would i do that

#

@slate swan

#

sorry for the ping

slate swan
green bluff
#

i dont have a list of role names wdym a list of role names

#

do i have to create one

#

i dont understand what u mean

maiden fable
#

!d discord.Guild.roles

unkempt canyonBOT
#

property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
maiden fable
#

@green bluff it's already sorted

#

The first element of this list will be the lowest role in the hierarchy.

green bluff
#

so do i only list the roles up till the role which is not staff?

maiden fable
#

Wym...

#

What u wana do

green bluff
#

like pretend its a userinfo command

#

if a person has staff or owner i dont want that to be listed as their top role

#

i want to create an exception like dont list those roles

#

if a person has those

#

as their top role

maiden fable
#

!d discord.Member.top_role

unkempt canyonBOT
#

property top_role: Role```
Returns the member’s highest role.

This is useful for figuring where a member stands in the role hierarchy chain.
maiden fable
#

This...?

#

Idk I'm confused

green bluff
#

ik

#

so u know when i do top_role

#

it says im owner right

#

but i dont want it to list that im owner or staff

#

i want it to list the top role thats below staff

maiden fable
#

Ah

#

I guess access member.roles and remove the roles from the list till staff role

#

Using slicing

green bluff
#

how?

#

can u give me an example

maiden fable
#

!e

print([1, 62, 92, 74][:2]) 
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

[1, 62]
maiden fable
#

See

#

!d slice

unkempt canyonBOT
#

class slice(stop)``````py

class slice(start, stop[, step])```
Return a [slice](https://docs.python.org/3/glossary.html#term-slice) object representing the set of indices specified by `range(start, stop, step)`. The *start* and *step* arguments default to `None`. Slice objects have read-only data attributes `start`, `stop`, and `step` which merely return the argument values (or their default). They have no other explicit functionality; however, they are used by NumPy and other third-party packages. Slice objects are also generated when extended indexing syntax is used. For example: `a[start:stop:step]` or `a[start:stop, i]`. See [`itertools.islice()`](https://docs.python.org/3/library/itertools.html#itertools.islice "itertools.islice") for an alternate version that returns an iterator.
spring flax
#

How does one get the message history and put it in a text file?

green bluff
#

ohh so :2 removes the last 2 highest numbers

maiden fable
unkempt canyonBOT
#

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

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

Examples

Usage...
green bluff
#

and i do that with roles

spring flax
#

I know the channel.history(**kwargs) but what about the txt file

maiden fable
maiden fable
green bluff
#

ohh so if i do 5

#

it runs till the fifth elem,ent

maiden fable
#

!d discord.AsyncIterator.flatten

unkempt canyonBOT
#

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

Flattens the async iterator into a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") with all the elements.
spring flax
#

oh .flatten() right

maiden fable
maiden fable
green bluff
maiden fable
#

Yea

#

5th element's index is 4

spring flax
#

okay when I have the list how do I put it in a txt file lol

green bluff
maiden fable
#

Or the message content

green bluff
#

how would i do that with roles tho

spring flax
green bluff
#

like role = ctx.guild.roles

maiden fable
#

!d open exists

unkempt canyonBOT
#

open(file, mode='r', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)```
Open *file* and return a corresponding [file object](https://docs.python.org/3/glossary.html#term-file-object). If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "OSError") is raised. See [Reading and Writing Files](https://docs.python.org/3/tutorial/inputoutput.html#tut-files) for more examples of how to use this function.

*file* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to `False`.)
maiden fable
#
list = [msg-1, msg-2]
final = [(msg.content, msg.created_at, msg.author.name) for msg in list]

Idk something like this should work

#

There was an easier way with itertools iirc

green bluff
#

for me or for dia

maiden fable
#

Dia

spring flax
maiden fable
maiden fable
green bluff
maiden fable
#

!d itertools.groupby

@spring flax I haven't really tried, but try

unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

maiden fable
#

Weird Python

#

!d itertools.groupby

unkempt canyonBOT
#

itertools.groupby(iterable, key=None)```
Make an iterator that returns consecutive keys and groups from the *iterable*. The *key* is a function computing a key value for each element. If not specified or is `None`, *key* defaults to an identity function and returns the element unchanged. Generally, the iterable needs to already be sorted on the same key function.

The operation of [`groupby()`](https://docs.python.org/3/library/itertools.html#itertools.groupby "itertools.groupby") is similar to the `uniq` filter in Unix. It generates a break or new group every time the value of the key function changes (which is why it is usually necessary to have sorted the data using the same key function). That behavior differs from SQL’s GROUP BY which aggregates common elements regardless of their input order.
maiden fable
#

Yea there

#

But idk if this is what u r looking for

slim plover
#

!e
print("You sussy baka")

unkempt canyonBOT
#

@slim plover :white_check_mark: Your eval job has completed with return code 0.

You sussy baka
maiden fable
#

#bot-commands

slim plover
#

oh

#

k

unkempt canyonBOT
maiden fable
#

!d zip or try using this, I don't really know

unkempt canyonBOT
#
zip

zip(*iterables, strict=False)```
Iterate over several iterables in parallel, producing tuples with an item from each one.

Example:

```py
>>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
...     print(item)
...
(1, 'sugar')
(2, 'spice')
(3, 'everything nice')
```...
surreal blade
#

my discord bot is an absolute mess, I have all the commands not as cogs just as
@bot.command() async def help(ctx):
etc...

would organising it into cogs just be as simple as
putting it inside a class that inherits from cogs and creating the command in there?

#

fuck it, ill work it out, it's a hard question to answer not knowing what i know dw haha

ember magnet
#

https://paste.pythondiscord.com/ahozokahow.py
Line 122
I tried to make a Ticket System but the bot wont react on the on_reaction_add event. It worked fine when I tested it first, but then i wanted to enhance it more and now it just doesnt react anymore. I tried to undo my changes and test it with print, but nothing works and i dont get any error message. I cant see what im doing wrong

placid skiff
#
if channelexsits:
      None

What is this?

pine crown
#
import discord
from discord import Client, Intents, Embed
from discord_slash import SlashCommand, SlashContext
from discord.ext import commands

@commands.has_permissions(ban_members=True)
@client.command(pass_context=True)
async def BanUser(ctx, user: discord.Member=None, *, reason="The reason was not entered"):
  if user is None:
    await ctx.send("Please enter the user you want to ban.")
  elif user == ctx.message.author:
    await ctx.send("You cannot ban yourself.")
  elif user.guild_permissions.administrator:
    await ctx.send("You cannot ban a admin.")
  else:
    await user.ban(reason=reason)
    await ctx.send(f"Banned {user.name} for {reason} by {ctx.author.mention}")
#

how to turn it into a slash command?

placid skiff
placid skiff
#

F

placid skiff
# ember magnet yeah

!d on_raw_reaction_add
on_reaction_add works for message which are stored in the cache, once your bot turns offline it deletes the cache, you should use on_raw_reaction_add

#

i'm stupid today

#

D_D

placid skiff
unkempt canyonBOT
#

disnake.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://docs.disnake.dev/en/latest/api.html#disnake.on_reaction_add "disnake.on_reaction_add"), this is called regardless of the state of the internal message cache.

This requires [`Intents.reactions`](https://docs.disnake.dev/en/latest/api.html#disnake.Intents.reactions "disnake.Intents.reactions") to be enabled.
placid skiff
pine crown
ember magnet
pine crown
# placid skiff Because they are two different modules, disnake is one single module and has the...

well but anyways

@commands.has_permissions(ban_members=True)
@slash.slash(name="Ban", description="Bans a user")
async def BanUser(ctx, user: discord.Member=None, *, reason="The reason was not entered"):
  if user is None:
    await ctx.send("Please enter the user you want to ban.")
  elif user == ctx.message.author:
    await ctx.send("You cannot ban yourself.")
  elif user.guild_permissions.administrator:
    await ctx.send("You cannot ban a admin.")
  else:
    await user.ban(reason=reason)
    await ctx.send(f"Banned {user.name} for {reason} by {ctx.author.mention}")

why doesnt this create a slash command

placid skiff
#

it is a fork of discord, so you will have to change nothing in your code except that you have to change every discord into disnake, there is an example of a slash command:

from disnake.ext.commands import *
from disnake import ApplicationCommandInteraction

# your client / bot here
...
@slash_command(name="echo", description="Send a message")
async def echo(ctx: ApplicationCommandInteraction, message: str):
  await ctx.send(message)

the message is an option of the slash command so it will appear when you will digit /echo
there is a classic command with disnake:

from disnake.ext.commands import *
...

@bot.commands()
async def echo(ctx: Context, message: str):
  await ctx.send(message)
placid skiff
pine crown
#

i get error while trying to do slash_command

placid skiff
pine crown
#

ok

heavy folio
#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
heavy folio
fervent shard
#

code:

@bot.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, reason):
      save_warn(ctx, member)
      dm = await bot.fetch_user(member.id)
      em=discord.Embed(title="Warning", description=f"Server: {ctx.guild.id}\nReason: {reason}"
      await dm.send(embed=em)

@bot.command()
@commands.has_permissions(kick_members=True)
async def warnings(ctx, member: discord.Member):
      warns = warns_check(member)
      await ctx.send(f"{member.name} has {warns} warnings.")

@bot.command()
@commands.has_permissions(kick_members=True)
async def removewarn(ctx, member: discord.Member, amount: int):
      remove_warn(ctx, member, amount)
      await ctx.send(f"Removed {amount} warnings from {member.name}!")```
error:
  ```File "main.py", line 119
    await dm.send(embed=em)
    ^
SyntaxError: invalid syntax```
quick gust
#

You never closed brackets in your embed instance

maiden fable
#

U can simply do await member.send()

quick gust
placid skiff
#

well, it isn't a command sadly for you but to make something case-unsentive you can do this:

slate swan
#

im all ears, i feel really stupid πŸ˜…

placid skiff
#
message = "hello"
response=input("say hello!")

if response.lower()==message:
  True
slate swan
#

I'm confused because str.upper should make the string all Case which should solve the case-sensitivity issue

placid skiff
#

the message variable store "hello" all lower, the response is a string taken in input which will be lower case, so even if you write "HELLO" it will be "hello"

#

str.upper() makes the string all upper case

#

!e

msg = "hey"
print(msg.upper())
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

HEY
placid skiff
#

as you see it turns the string upper case

slate swan
#

Yeah, the command is all upper-case, so it should make it work

placid skiff
#

you deleted the message so i can't tell you why

slate swan
#
    if message.content.startswith(str.upper("$FIRE")):
        await message.channel.send(Vehicles["Fire"])
    if message.content.startswith(str.upper("$POLICE")):
        await message.channel.send(Vehicles["Police"])
surreal blade
#

so if i have
def setup(bot) -> None: bot.add_cog(Profile(bot))

after my cog

should i be calling setup(bot) in my main.py or something? (or the script that's being run)
Or where is this function called, the function exists in all cog examples

placid skiff
slate swan
#

so my understanding is
input goes $fire, then the bot makes it all upper case, then checks if the command is written properly. which it should. and then it does its stuff

placid skiff
pine crown
#

how to make slash commands

placid skiff
slate swan
#

ahh gotha thanks

pine crown
placid skiff
#

show command and errors

surreal blade
placid skiff
pine crown
# placid skiff show command and errors
from disnake.ext import commands
import discord

intents = discord.Intents.default()

intents.members = True

client = commands.Bot(
    command_prefix='-',
    intents=intents,
    case_insenstivive = True
)
client.remove_command('help')



@client.slash_command(description="Shows members", aliases=["membercount"])
async def members(ctx):
    await ctx.send(f'{ctx.guild.member_count}')


@commands.has_permissions(ban_members=True)
@client.slash_command(description="Bans a user")
async def BanUser(ctx, user: discord.Member=None, *, reason="The reason was not entered"):
  if user is None:
    await ctx.send("Please enter the user you want to ban.")
  elif user == ctx.message.author:
    await ctx.send("You cannot ban yourself.")
  elif user.guild_permissions.administrator:
    await ctx.send("You cannot ban a admin.")
  else:
    await user.ban(reason=reason)
    await ctx.send(f"Banned {user.name} for {reason} by {ctx.author.mention}")
surreal blade
#

thanks, appreciate the response, you're helping everyone so i'm sure youll feel exhausted soon haha

placid skiff
placid skiff
#

disnake is a fork, they're one and same but disnake has more features

pine crown
# placid skiff in the same way you use them with discord
import disnake
from disnake.ext import commands

intents = disnake.Intents.default()

intents.members = True

client = commands.Bot(
    command_prefix='-',
    intents=intents,
    case_insenstivive = True
)
client.remove_command('help')



@client.slash_command(description="Shows members", aliases=["membercount"])
async def members(ctx):
    await ctx.send(f'{ctx.guild.member_count}')


@commands.has_permissions(ban_members=True)
@client.slash_command(description="Bans a user")
async def BanUser(ctx, user: discord.Member=None, *, reason="The reason was not entered"):
  if user is None:
    await ctx.send("Please enter the user you want to ban.")
  elif user == ctx.message.author:
    await ctx.send("You cannot ban yourself.")
  elif user.guild_permissions.administrator:
    await ctx.send("You cannot ban a admin.")
  else:
    await user.ban(reason=reason)
    await ctx.send(f"Banned {user.name} for {reason} by {ctx.author.mention}")
        


client.run("i wont send token")
placid skiff
surreal blade
#

is disnake expected to be the slash command continuation of discord.py?

placid skiff
placid skiff
placid skiff
surreal blade
#

nice, that's good news guess I should make the change soon before i keep developing

pine crown
placid skiff
pine crown
# placid skiff exactly
import disnake
from disnake.ext import commands

intents = disnake.Intents.default()

intents.members = True

client = commands.Bot(
    command_prefix='-',
    intents=intents,
    case_insenstivive = True
)
client.remove_command('help')



@client.slash_command(description="Shows members", aliases=["membercount"])
async def members(ctx):
    await ctx.send(f'{ctx.guild.member_count}')


@commands.has_permissions(ban_members=True)
@client.slash_command(description="Bans a user")
async def BanUser(ctx, user: disnake.Member=None, *, reason="The reason was not entered"):
  if user is None:
    await ctx.send("Please enter the user you want to ban.")
  elif user == ctx.message.author:
    await ctx.send("You cannot ban yourself.")
  elif user.guild_permissions.administrator:
    await ctx.send("You cannot ban a admin.")
  else:
    await user.ban(reason=reason)
    await ctx.send(f"Banned {user.name} for {reason} by {ctx.author.mention}")


client.run("e")
placid skiff
pine crown
surreal blade
placid skiff
pine crown
placid skiff
#

did you pass arguments?

pine crown
#

?

#

the other commands work tho

placid skiff
#

oh wait you don't need the * in async def BanUser(ctx, user, *, reason)

placid skiff
#

in disnake arguments are taken untill you write them

pine crown
#

now it will work rgith?

placid skiff
#

well, you will not know untill you try

tawdry perch
placid skiff
#

the problem could be the case too

placid skiff
pine crown
#

i waiting bot to go oofline

surreal blade
#

@placid skiff do you have a snippet of how you instantiate your bot
if not no worries ill work it out, was just wondering if there was anything else for me to investigate

heavy radish
#

In theory, will this work?

pine crown
placid skiff
pine crown
placid skiff
placid skiff
surreal blade
placid skiff
placid skiff
heavy radish
surreal blade
#

that it is, never used that feature before

pine crown
placid skiff
heavy radish
#

Oh

placid skiff
#

i'm just waiting my partner to finish calling routine xD

pine crown
placid skiff
#

to retrieve the author you can just do ctx.author

#

it returns the user or member object which has called the command

pine crown
#

ok

placid skiff
surreal blade
#

yeah I did, just trying to work out the easiest way to get it done and basically just implement the
def setup(self): for cog in COGS: try: print(f" loadin {cog}") self.load_extension(f"lib.cogs.{cog}") except NoEntryPointError: print(f" failed to load {cog}\nNo setup found") # except ExtensionFailed: # print(f" failed to load {cog}\nThe extension or its setup had an execution error") else: print(f" {cog} loaded")
part into my code

#

into my main.py for now haha before i go into making my own inherited bot class

placid skiff
#

right then πŸ˜†

surreal blade
#

but ill probs be using yours for a bit as reference so i appreciate the help, thanks again

placid skiff
#

no problem

placid skiff
# pine crown thank you

reference to the docs from now on, it really helps when you take the hand of it
remember that disnake use both standard commands and slash one but they doesn't share the same interaction. slash commands use disnake.ApplicationCommandInteraction, commands use disnake.ext.commands.Context
For their purpose is the same they have some differences

pine crown
#

ok

slate swan
#

Hello,
I installed the package of the fivem, and It writes me the following error:
ModuleNotFoundError: No module named 'fivem'

Please help me,
Thanks

vale wing
#

Is it really discord bots related issue?

slate swan
#

pip install fivem

vale wing
#

And what output did you receive

slate swan
slate swan
vale wing
#

!pypi fivem

unkempt canyonBOT
vale wing
#

@slate swan what IDE do you use

slate swan
#

visual studio code

vale wing
#

Have you reloaded it after the installation

slate swan
#

yeah

placid skiff
#

you installed it from your console or from visual studio console?

vale wing
#

Most likely something is wrong with the package itself but I will check this by myself

#

Never seen anyone using scripts param in setup.py

placid skiff
#

check if the visual studio interpreter is related to your local python interpreter

slate swan
#

How?

vale wing
#

Yeah the problem is with the package @slate swan

slate swan
#

Yes, but how?

vale wing
#

@slate swan you know how to work with github right?

slate swan
#

yes

#

I think

vale wing
#

Ok dm me

#

This is gonna take long and kinda out of topic

ember magnet
#

I have this:

`@bot.event
async def on_raw_reaction_add(payload):
print(f"Reaction {payload.user_id}")
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, bot.guilds)
global confirmation

if payload.emoji.name == '🎟️':
    >>here<<
    category = discord.utils.get(guild.categories, id=932890002193547304)
    channel = await guild.create_text_channel(name=f"🎫︱{payload.member}", category=category)`

I wanna remove the reaction there when it is the right emoji but i cant find anything that works about payload and remove reaction

placid skiff
#

payload.emoji returns an emoji object, so it has all emoji methods, you can use it to delete the emoji

vale wing
vale wing
#

I don't remember every single emoji's unicode sorry 😁

#

But you can use it of course