#discord-bots

1 messages ยท Page 1061 of 1

warped mirage
#

It has to be ?

#

And anyways I did say I wanna switch all of that to a cog file

wet crystal
#

why does this return "None"?

bot_name = str(bot.user).split("#")[0]

print(bot_name)
torn sail
wet crystal
brave forge
#

what is the problem?
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "time".

full lily
#

whatever you gave, it can't be converted to an integer

brave forge
#

@full lily That's how I wrote

1) mute @nick 1m lol 
2) mute @nick 60 lol```
full lily
#

!e

int("1m")
unkempt canyonBOT
#

@full lily :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ValueError: invalid literal for int() with base 10: '1m'
full lily
#

^

brave forge
#

what ?

potent spear
full lily
#

That'd do you good @brave forge ^^

full lily
#

use the converter that was linked above

potent spear
#

All that's left for you then is to typehint the arg to the class name

brave forge
full lily
#

a while?

potent spear
#

you can use timeout...

#

!d discord.Member.timeout

unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the
given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to
use this...
potent spear
#

where the until arg is equal to the converted arg you passed in the command

#

Unless you're talking about a voice_channel mute

brave forge
#

@potent spear no no no no. Here with links to this documentation right away I will not pay attention to your messages

potent spear
#

you'll have to learn how to use the docs one way or the other

brave forge
#

@potent spear in order to use this documentation, you need to be a professional

full lily
#

I know it looks daunting, but it's really the only way to know what kind of classes and methods are offered in the library

#

you've been linked to the method that you should use

#

all that you need to look at is this discord.Member.timeout, to know where to import from

brave forge
#

@potent spear she is stupid and created not for newcomers but for those who already know how to do everything without her. And it is used purely to look and remember.

full lily
#

and the function signature await timeout(until, /, *, reason=None), to know what arguments to provide

#

and obviously the description of what the method does

potent spear
#

still remains the same, I'd rather spend a day looking at how the docs work than guessing and googling

wet crystal
#

bot = commands.Bot(command_prefix='*')

@bot.event
async def on_ready():
    print(f'{bot.user} has booted up succesfully!')

class EmbedModal(nextcord.ui.Modal):
    def __init__(self):
        super().__init__(
            "Embed Maker",
        )

        self.emTitle = nextcord.ui.TextInput(Label = "Embed Title", min_Length = 2, max_Length = 124, required = True, placeholder = "Enter Embed Title")
        self.add_item(self.emTitle)

        self.emDescription = nextcord.ui.TextInput(Label = "Embed Description", min_Length = 5, max_Length = 4000, required = True, placeholder = "Enter Embed Description", style = nextcord.TextInputStyle.paragraph)
        self.add_item(self.emDescription)

    async def callback(self, interaction: nextcord.Interaction) -> None:
        title = self.emTitle.value
        desc = self.emDesc.value
        em = nextcord.embed(title=title, description=desc)
        return await interaction.response.send_message(embed=em)

@bot.slash_command(name="embed", description="Create a custom Embed!", guild_ids=[id])
async def embed(interaction: nextcord.Interaction):
    await interaction.response.send_modal(EmbedModal())

why doesnt this add a slash command to my server?

brave forge
#

@potent spear no. I don't want to touch this shit

potent spear
#

what are your sources? how do you know what methods a class has without looking at the docs?

full lily
brave forge
paper sluice
brave forge
#

@full lily and why I don't want to see I described above

full lily
#

3. to deal with this piece of shit, you need to take those who wrote this shit as slaves??

paper sluice
brave forge
#

@full lily
the fact that the documentation you give me is stupid. The method described in it probably works. But in order for it to work, it needs to be described normally, and in this documentation he described it in a bastard way, well, in other things, like all this documentation

slate swan
#

*i dont want the documentation, give me the code

brave forge
full lily
#

I do agree that the way the documentation is written is pretty esoteric, but learning to read it is an essential skill

#

I've shown you what parts you need to look at, and hopefully that will make it more readable for you

#

You won't always have a discord server to go to, to ask for help. The docs will be your help

potent spear
#

time typehint is incorrect

paper sluice
#

str(int) is not a valid type hint

wet crystal
full lily
#

did you see the time converter that was linked above?

wet crystal
#

but the application did not respond @paper sluice

#

it says at least

slate swan
#

i mean, you want to timeout a member ๐Ÿšถโ€โ™‚๏ธ
go to docs, look for Member, click on timeout under member
and you have the docs, there's nothing too hard about it.

paper sluice
brave forge
potent spear
#

that's not completely true

#

we all started with the docs at some point

slate swan
brave forge
#

@slate swan if I know how blender 3d works, then for me any lesson, even with a deaf-mute, will be clear

full lily
#

everyone looks at docs. It's impossible to memorize every class of every library that you work with

potent spear
#

learning python WHILE writing a bot is a steep learning curve

slate swan
#

especially when you refuse to learn with docs ^

wet crystal
#

No, I just said the Bot responded with:

Application did not respond

paper sluice
brave forge
wet crystal
paper sluice
slate swan
brave forge
slate swan
#

this says otherwise~

potent spear
paper sluice
slate swan
#

also, in your command function ```py
async def command(self, ctx, member: discord.Member = None, *, time: str(int), reason = 'ะžั‚ััƒั‚ัั‚ะฒัƒะตั‚')

brave forge
potent spear
#

you're clearly not passionate about programming, you're more frustrated ๐Ÿ˜†

paper sluice
slate swan
#

apparently, someone else's being a jerk.

brave forge
#

@blissful lagoon Hey, you. let's give out mute @slate swan for insults!!

midnight gorge
#

why im getting the ImportErro:r: cannot import name 'commands' from 'discord.ext' (unknown location)

i have python installed and python installed from Microsoft too

#

I'm using vsc

potent spear
full lily
#

is it not a big C?

brave forge
#

@blissful lagoon or are you only enough to be blacklisted after the muta!?

potent spear
#

flexing his add_reaction privilege

midnight gorge
full lily
#

hahah you guys don't have that?

potent spear
slate swan
potent spear
midnight gorge
paper sluice
potent spear
midnight gorge
midnight gorge
potent spear
slate swan
brave forge
midnight gorge
#

only thing is that i uninstall it and install it again

midnight gorge
brave forge
midnight gorge
#

oh that's not it

potent spear
#

anyways, restarting vsc should fix it

midnight gorge
#

hmm

#

ok

paper sluice
hollow badger
#

!mute 419481276765175808 incident_investigating

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @brave forge until <t:1653348806:f> (59 minutes and 59 seconds).

daring olive
#

please submit a separate report to @novel apex @potent spear

potent spear
daring olive
#

ok let's move on

#

i said let's move on

potent spear
#

have you read it?

#

it has nothing to do with what happened previously

slate swan
#

jam_cavedude i wonder why other topical channels, but not this channel has reaction perms

paper sluice
#

this is more active than other topical channels

#

*usually

potent spear
#

I suggest of enabling this, it can save lots of simple "yes and no" replies

slate swan
#

^ this, and this replies too

daring olive
#

reaction perms are disabled both here and in #python-discussion due to the moderation burden it created; people abused it

#

moderating reactions is nearly impossible due to lack of logs

#

using the actual emoji in messages is more feasible from a moderation standpoint

slate swan
#

oh, with both of them being fairly active channels, that makes sense/

potent spear
#

abusing reactions? thinkmon

daring olive
#

spelling out insults or inappropriate words

#

is just 1 example of many

potent spear
#

damn, you'd have to be creative with that

wet crystal
#

probably didnt even reach taht point

#

this is the error btw

#

nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: TextInput.init() got an unexpected keyword argument 'min_Length'

paper sluice
#

huh? show code

wet crystal
# paper sluice huh? show code

This is EVERYTHING

import nextcord
from nextcord.ext import commands

TOKEN = "token"

bot = commands.Bot(command_prefix='*')

@bot.event
async def on_ready():
    print(f'{bot.user} has booted up succesfully!')

class EmbedModal(nextcord.ui.Modal):
    def __init__(self):
        super().__init__(
            "Embed Maker",
        )

        self.emTitle = nextcord.ui.TextInput(label = "Embed Title", min_Length = 2, max_Length = 124, required = True, placeholder = "Enter Embed Title")
        self.add_item(self.emTitle)

        self.emDescription = nextcord.ui.TextInput(label = "Embed Description", min_Length = 5, max_Length = 4000, required = True, placeholder = "Enter Embed Description", style = nextcord.TextInputStyle.paragraph)
        self.add_item(self.emDescription)

    async def callback(self, interaction: nextcord.Interaction) -> None:
        title = self.emTitle.value
        desc = self.emDesc.value
        em = nextcord.embed(title=title, description=desc)
        return await interaction.send(embed=em)

@bot.slash_command(name="embed", description="Create a custom Embed!", guild_ids=[976133314610069514])
async def embed(interaction: nextcord.Interaction):
    await interaction.response.send_modal(EmbedModal())

bot.run(TOKEN)
#

I also tried interaction.send_message in the callback but nothing changed

paper sluice
#

!d nextcord.ui.TextInput

#

:/

unkempt canyonBOT
#

class nextcord.ui.TextInput(label, *, style=<TextInputStyle.short: 1>, custom_id=..., row=None, min_length=0, max_length=4000, required=None, default_value=None, placeholder=None)```
Represent a UI text input.

New in version 2.0.
paper sluice
#

ya its min_length not Length

wet crystal
#

testing

#

@paper sluice
Atleast the Modal popped up this time and I was able to enter text etc.
But now theres a other error

File "c:\Users\user\Documents\Python\exm.py", line 26, in callback
desc = self.emDesc.value
AttributeError: 'EmbedModal' object has no attribute 'emDesc'

#

I think I got it

#

I GOT IT

#

thankfully somewhen

flint isle
#
    @commands.slash_command(name="removereaction", guild_ids=config)
    async def rmreaction(self, ctx, reaction: Option('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both'],required=True ), amount: Option('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0, required=False)):

eroror:

disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: unhashable type: 'Option'

stone beacon
#

You probably have to set the Option as a default value not a type hint

#

That : probs needs to be an =

#

(I think)

slate swan
#

anyone really familiar with the discord api?

heavy shard
#

if it's readable to you you don't need to force it

dusky pine
#

well, if you're planning to open source this, do so

desert heart
#

You can use a dictionary which maps a tuple of role IDs to strings e.g. ```py
messages = {
(1234, 4567): "You are an Genearl Manager, you cannot release the franchise owner!"
}
for (role_a, role_b), message in messages.items():
if ...: # check the users have the roles
return await ctx.reply(message)

#

The dictionary is still gonna need a separate entry for each message but at least you aren't repeating as much code

#

Actually, it can be further improved. I realised the messages are just combinations of smaller parts

outer violet
#

Does anyone have a fun api I can use?

desert heart
#

Something like ```py
messages = {
1234: "General Manager",
4567: "franchise owner"
}
...
await ctx.reply(f"You are a {messages[role_id]}, you cannot release the {messages[other_role_id]}!")

But it may not be so simple if a user can have more than one of those roles simultaneously.
heavy shard
#

or maybe assigning internal level to a role, and if your level is lower than a person you act at, it informs about it

desert heart
#

Yeah, that's a good idea too. Also realised I haven't looked at this too carefully. The string used is the same as the role name, so using a dictionary isn't even needed for the names.

slate swan
stone beacon
#

Making that look good is gonna be a tuff one

slate swan
#

i'm making discord bots, for my university, for get information like getting schedule and etc.

slate swan
stone beacon
#

Well you can iterate over the dictionary and add stuff individual using add_field

#

Although it will still look bad as you have nested lists and stuff in their

slate swan
#

i'm making this bot just need 1-2 hours but... making the data looks good need more than a day guycry

#

i'm really stuck dude. guycry ๐Ÿฅฒ

heavy shard
#

could you paste the json somewhere in a text form, not a screenshot?

slate swan
#

of course.

#

http://47.254.238.244/jadkul/3ka05
{"status":true,"data":{"3KA05":{"Senin":["Analisis&amp;Peranc. Sistem Inf. *\/**","4\/5\/6","E313","L"],"Jum&#039;at":["Terapan Teori Graf","","UGTV",""]},"FENNI AGUSTINA":{"3KA05":["Senin","Pengantar Sains Data","8\/9","E313"]},"L":{"MOHAMMAD IQBAL":["3KA05","Selasa","Sistem Penunjang Keputusan *","5\/6\/7"]},"E313":{"L":["NURWENDO HARICAHYADI","3KA05","Rabu","Disain &amp; Manaj.Jaringan Komputer*"]},"1\/2\/3":{"E228":["","MOCHAMMAD AKBAR MARWAN","3KA05","Rabu"]},"Sistem Basis Data 2 *\/**":{"5\/6\/7":["E514","","YULI KARYANTI","3KA05"]},"Rabu":{"Sistem Berbasis Pengetahuan **":["8\/9","E514","","TRISTYANTI YUSNITASARI"]},"TEAM TEACHING":{"3KA05":["Sabtu","Konsep Data Mining","1\/2","E318"]},"":{"INDAH WAHYUNI":["3KA05","Sabtu","Pemodelan &amp; Visualisasi Data #","3\/4"],"EKA FITRI RAHAYU":["3KA05B","Sabtu","Tatap Muka Penulisan Ilmiah","8\/9"]},"E318":{"":["RISKY WIJAYA","3KA05","Sabtu","Praktikum Terapan Teori Graf"]},"6\/7":{"":["","TIM DOSEN","3KA05C","Sabtu"]},"Tatap Muka Penulisan Ilmiah":{"8\/9":["E433","","AINI SURI TALITA","3KA05D"]},"Sabtu":{"Tatap Muka Penulisan Ilmiah":["8\/9","E433","","ANNA FITRIA"]},"3KA05A":{"Sabtu":["Tatap Muka Penulisan Ilmiah","8\/9","E433",""]},"DIANA IKASARI":{"3KA05E":["Sabtu","Tatap Muka Penulisan Ilmiah","8\/9","E433"]},"E433":{"":["LELI SAFITRI"]}}}

heavy shard
#

the problem is it's not english so i'm not sure how to interpret it

slate swan
#

The Actual Data:
Kelas = Class, Hari = Day, Mata Kuliah = Courses, Waktu = Time, Ruang = Room, Status = Status, Dosen = Lecturer.

heavy shard
#

oh that helps

stone beacon
#

It will be very easy for your eyes and easier to convert to an embed for ya

#

In terms of readability

#

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

stone beacon
heavy shard
#

i'm trying to wrap my head around how the json represents this table and i'm failing ๐Ÿ˜ฆ

stone beacon
#

I tried and got lost even after pretifying it cuz non english

slate swan
heavy shard
#

it seems messed up

heavy shard
#

like once day of week appears as key, the other as an item, then a lecture is a key

#

looks like it should be csv that was somehow forced to be json

#

it seems to be corrupted data to me

slate swan
#

hmm.... damn

heavy shard
#

what about source of this table screenshot, couldn't you scrap it?

slate swan
#

but the data...

heavy shard
#

scraping is sometimes very easy

#

you just need beautifulsoup, i could help you in it

slate swan
heavy shard
#

yes

slate swan
#

okay, add friends ๐Ÿ˜„

warped mirage
#

Guys I need help @heavy shard YO

slate swan
#

you shouldnt ping people like that for help

warped mirage
#

Lmao wassup

slate swan
#

bricks, cement and paint and manwork

#

that makes up the ceiling*

warped mirage
#

Tbf Iโ€™m still stuck on how to create the tables and stuff in a cog . Since I create my tables mainly in main.py

slate swan
#

creating invites with the api takes in channel id correct?

slate swan
#

its a method of the channel obj iirc

#

yeah so the channel Id would work

warped mirage
#

Like I do ye setup db in main.py and cursor executes and create tables . Idk if I can make the tables in a cog because I already made a db idk itโ€™s just so confusing

slate swan
#

idk why discord didn't allow invites to be made for the guild in general

#

!d discord.TextChannel.create_invite i agree, but anyways

unkempt canyonBOT
#

await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates an instant invite from a text or voice channel.

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

yeah it is kinda weird

slate swan
#

you can probably help me. do you know how id get the first Channel (not category) of a guild? @slate swan

#

cz i would recommend restarting the project if there arent a great numbe of commands

warped mirage
#

Hmmm idk . So I make the db in main.py and my levelling system is in the main.py but Iโ€™d rather do in cogs as the systems are better but uknow u must do it all in one file since u canโ€™t create tables in multiple files eg 3

slate swan
#

also, I want it to find the first channel that is viewable for the @ everyone role

maiden fable
slate swan
#

okay im insane

#

but it could be a vc?

slate swan
maiden fable
#

Hm

warped mirage
#

lol

maiden fable
# slate swan yeah

Why would u want to generate a VC invite tho? It's for making ppl join VC directly instead of guild

slate swan
maiden fable
#

Your wish

slate swan
warped mirage
#

Well before anything lemme say something

slate swan
#

im annoying?

#

ashley or hunter could you help?

warped mirage
#

I have 1 on message event , level command , lb command , disable / enable the level system , ban , mute , unmute , kick , a server command and user command thatโ€™s all I have. I could restart but I need someone to full one help me with the changes

slate swan
#

@maiden fable ๐Ÿ˜„

maiden fable
#

With?

slate swan
maiden fable
#

Ash told u tho

warped mirage
#

ah itโ€™s so hard to explain

slate swan
warped mirage
#

So in main.py I have the level system and all the executes and that stuff . Making more systems in my main.py will make it a huge mess so I wanna make a cog : warning.py and make more tables there while still having main.py tables work and stuff

#

If it all makes sense

maiden fable
#

Ngl the best thing is to use bot.dispatch
That's what many ppl do since that results in clean code @warped mirage

warped mirage
maiden fable
stone beacon
maiden fable
#

Someone else here sent that code yesterday

slate swan
#

nooo

maiden fable
#

No

#

That's gonna return the channel

slate swan
#

it will return a TextChannel object or None itself

maiden fable
#

Directly

slate swan
#

it could return None

#

if there is not a single channel in which messages can be sent

#

textchannel object as in the id or what part of the object?

#

or viewed*

maiden fable
#

Imagine not having even a single viewable channel

slate swan
maiden fable
unkempt canyonBOT
slate swan
#

to get the channel ID I can just do channelid = channel.id ?

slate swan
maiden fable
#

Yea

slate swan
#

alright

warped mirage
#

Iโ€™ll try ok

keen mural
#
if amount.endswith('k'):
        withdrawamount = (amount[:-1])
        withamount = withdrawamount * 1000
        wallet = result['Wallet']
        bank = result['Bank']
        print(f'{withamount}')
        if withamount > bank:
          await ctx.reply("You don't even have that much lmao")``` so basically amount is smth in the cmd, for example 3.3k i just dont really know what im doing and its returning stuff like this
bright palm
maiden fable
#

Or make a converter

keen mural
#

idk much about floats

#

nvm i figured it out ty @bright palm

warped mirage
#

@slate swan this is what I mean obvs different style but how many can I make

slate swan
#

@maiden fable If I already have the guild would I just remove the .guild ?

slate swan
warped mirage
#

Yes can I have multiple of them ?

#

To make tables

slate swan
# warped mirage Yes can I have multiple of them ?

yes you can but but but, still you have a less number of commands so I recommend upgrading to discord.py 2.0 which offers a lot more functuonality and has bug fixes, and its setup_hook function is what you'd need in order to run the setup functions of your db, like im using hikari and its got a Startup event too

warped mirage
#

As I said before Iโ€™ll do anything but I need help fixing the code after

slate swan
warped mirage
#

Is there a lot of changes in 2.0 ?

#

Like ban commands / permissions do they change a lot

#

Or events

slate swan
#

all the changes in 2.0

warped mirage
#

Page does not exist yet

slate swan
slate swan
#

oooof forgot that they changed the url yesterday

slate swan
#

its all personal preference

warped mirage
#

There arenโ€™t to many changes tbf but it looks cleaner

#

Iโ€™m used to v 1 tho lol so it will take time now to learn v 2 damn

slate swan
#

@slate swan Hm i got a, AttributeError: 'Guild' object has no attribute 'channel'

warped mirage
#

Ok

slate swan
warped mirage
#

Well Ashley do u think u could help me update my code when I update or nah

slate swan
#

@slate swan your issue with relative for pyk got fixed?

#

yup

#

imports*

#

everything is all fixed with imports and docs

slate swan
warped mirage
#

Ok as a guess can u tell me how many errors I will get from my current code ๐Ÿ˜‚

slate swan
slate swan
#

totally not something you would like doing with dpy

slate swan
slate swan
warped mirage
#

Idk how to restart tbf

slate swan
warped mirage
#

Unless u change my code into something better I have no other ideas

slate swan
#

i mostly only use docs because its like a shortcut tbh

slate swan
#

And you see the source from the docs itself most of the time, most sphinx themes provide that option

warped mirage
slate swan
#

yes

#

and a cogs folder, with a .env file with your token and stuff

#

or a json file

#

me who uses a py file๐Ÿง

slate swan
#

it gets the job done!

#

takes up more space

#
  • imports
#

was gonna say that

#

a simple .env file is easier to setup

#

^

maiden fable
#

Just write all the Python code in an env file and use dotenv module to get that ezzz

slate swan
#
bot.run(__import__("secretstuff").token)

๐Ÿ˜ณ

#

one liner ๐Ÿ‚

stone beacon
#

On my bucket list

slate swan
#

๐Ÿ˜ณ

slate swan
#

envs are the only choice there

slate swan
maiden fable
#

It ain't gonna work since Python requires indent blocks. But any other lang which requires brackets can work @stone beacon @slate swan

slate swan
#

๐Ÿ˜ญ

maiden fable
slate swan
slate swan
#

i realised yesterday that you can use web development options like console and inspect on discord canary app...

#

lol

maiden fable
slate swan
#

hey guys

maiden fable
#

textwrap*

slate swan
#

why take on more pain ๐Ÿ˜”

#

good news i joined a tech course for next year in my school and theyre gonna teach us basic engineering like basic electricity and programming with cpp java and py๐Ÿ˜ณ

slate swan
#

yeah with capacitors etc

stone beacon
#

Conngratulations! don't die

slate swan
#

okimi the electrician

#

๐Ÿง‘โ€๐Ÿ”ง

#

a mechanic uses that

#

shh

#

fails

maiden fable
slate swan
#

i use it to ๐Ÿ˜ณ

slate swan
supple thorn
#

Okimii the god of thunder

#

Only thunder

slate swan
#

๐Ÿ˜

#

๐Ÿ‘ท

slate swan
slate swan
#

i love || hunter ||

slate swan
#

sarthak ๐Ÿ˜”

#

okimii the builder, change your name to Bob okimii ๐Ÿ˜”

#

why would i?

#

bob the builder....

#

sarthak

#

change your name to builder so were matching

#

๐Ÿฅฐ

#

๐Ÿ˜ฉ alrighty

#

๐Ÿ’“

heavy shard
#

can we script it? yes, we can!

slate swan
#

yuppp

slate swan
#

coc๐Ÿง

#

who plays coc now ๐Ÿ˜”

#

not me

#

hunter about to !ot

maiden fable
slate swan
maiden fable
#

O

#

!ot

unkempt canyonBOT
maiden fable
#

You're welcome

slate swan
#

ouch

slate swan
#

๐Ÿ‘๏ธ ๐Ÿ‘๏ธ

slate swan
#

yeah

maiden fable
#

Oh okay

slate swan
hallow night
#

Hey, What do i need to run for my discord bot to be online?

#

im VERY new

hallow night
#

thats the .py file right?

stone beacon
#

Can't go wrong here

#

Now realizing those links are practically invisible to the avg newcomer

warped mirage
slate swan
#

fine

warped mirage
#

Btw Iโ€™ll be on pc in couple of mins

#

How do I update version

slate swan
#

pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)

maiden fable
slate swan
#

uhuh

#

@slate swan I got, AttributeError: 'Role' object has no attribute '_roles'

slate swan
# slate swan code?
channel = discord.utils.find(lambda cnl: cnl.permissions_for(guild.default_role).view_channel and not isinstance(cnl, discord.CategoryChannel), ctx.guild.channels)
channelid = channel.id
slate swan
warped mirage
#

And itโ€™s some random git, shouldnโ€™t it normally be verified by discord.py

slate swan
warped mirage
#

Who made the git

#

Some random person ?

slate swan
warped mirage
#

Ok makes more sense

maiden fable
#

!d discord.TextChannel.permissions_for

unkempt canyonBOT
#

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

This function takes into consideration the following cases...
maiden fable
#

Uh @unkempt canyon

slate swan
#

Huh?

slate swan
slate swan
maiden fable
#

Nvm my discord was lagging

slate swan
#

Oh

maiden fable
#

Weird

#

!d discord.Guild.default_role

unkempt canyonBOT
slate swan
#

would it be ctx.default_role ?

maiden fable
#

Works for me bro

#

What's yr dpy version

slate swan
warped mirage
maiden fable
#

pip show discord.py

slate swan
#

it says version 1.7.3

maiden fable
#

Try updating to 2.0

slate swan
#

how?

maiden fable
slate swan
#

will it automatically delete my old discord.py version?

maiden fable
#

Yea

slate swan
#

I don't have git installed

maiden fable
#

I have an idea

stone beacon
#

o0

heavy shard
#

yes

maiden fable
#

Manually download the zip file from github.com and unpack it then open a command prompt in that folder then do pip install .

slate swan
#

how do I install git, it'll probably be easier

stone beacon
#

It will be

#

Much better for you to install git

maiden fable
#

And istg rud0lf your pfp reminds me of an old friend haha

slate swan
maiden fable
#

Just click Next

#

And for the text editor

slate swan
#

which?

#

@maiden fable

maiden fable
#

Next

slate swan
maiden fable
#

Next

slate swan
maiden fable
#

Next

slate swan
maiden fable
#

Next

slate swan
maiden fable
#

Next

heavy shard
#

i can see a pattern in here ๐Ÿ™‚

maiden fable
#

Lmao there's a page where u dont gotta do next

slate swan
maiden fable
#

When u select a coding IDE

slate swan
heavy shard
#

sorry didn't want to sound sarcastic

maiden fable
#

By default it's choclatey or smth

slate swan
maiden fable
slate swan
maiden fable
slate swan
maiden fable
# slate swan

If u have selected the IDE, then just click next at everything

#

Oh cool, just click Next

slate swan
maiden fable
#

Just click Next

#

Everytime now

slate swan
#

alr

#

do I just click finish?

#

or do I laucnch git bash

#

@maiden fable

maiden fable
#

No

#

Don't launch just finish

slate swan
maiden fable
#

Sure

dusky pine
#

oh, now you git it

dusky pine
maiden fable
#

No I didn't git the joke

heavy shard
#

it's a pip dry

slate swan
maiden fable
#

Yea

slate swan
#

do I need to adjust somethng in thonny too?

maiden fable
#

No

slate swan
#

so I have 2.0 now

#

๐Ÿ‘€

#

I still get the AttributeError: 'Role' object has no attribute '_roles' ๐Ÿ˜ญ

maiden fable
#

What the

#

Does yr IDE show any errors?

slate swan
#

yes the same thing

maiden fable
#

No the IDE

#

Not Python. Like on the GUI any red line or smth

slate swan
#

Attribute doesn't have red lines or yellow

maiden fable
#

Hm

slate swan
#

It will just be white

maiden fable
#

Idrk dude I gotta study for tomorrow's exam

#

Sorry, but can I help you later?? @slate swan

slate swan
jade tartan
slate swan
#

Can u show

#

Screenshot

jade tartan
slate swan
#

No

jade tartan
#

No error it just wont give the role to the user and show the channel with that wrole

#

role'

warped mirage
#

Wait guys how do I download latest version of dpy again

visual island
jade tartan
slate swan
warped mirage
#

Wdym

warped mirage
#

Does that work ?

slate swan
#

yes

warped mirage
#

ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

slate swan
#

install git

warped mirage
#

pip install git?

slate swan
warped mirage
#

??

slate swan
#

you have to download git to use pip with git urls

warped mirage
#

i will need help tho

slate swan
#

its fine

warped mirage
#

no viruses xd

#

ok i spammed press next and its downloaded

#

umm brb

slate swan
warped mirage
#

ffs why so long ,

#

I cba im not doing 2.0

#

For now

heavy shard
#

just because it's longer than 10 seconds?

warped mirage
slate swan
warped mirage
#

Currupt

#

Tf????????

maiden fable
#

She's kidding

warped mirage
#

idc lol ill download it later , cuz rn its in alpha stage

jade tartan
#

someone please

slate swan
heavy shard
jade tartan
#

Nope well it doesnt work as in it wont sorry wrong code

#

i mean this one

warped mirage
slate swan
heavy shard
#

you need proper intent in main file, you're doing something with intents in the cog, which won't work

slate swan
jade tartan
#

Wdym?

visual island
#

Have you set the intents correctly? You should enable it in both your code and developer portal.

#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
unkempt canyonBOT
#

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

second function
slate swan
#

and yes, intents can be issue too

warped mirage
#

@slate swan this happens in my cog

#

probs im not able to use em

slate swan
warped mirage
#

xd

slate swan
#

it would be self.client in the class, as you defined in the init dunder

#

and you miss "self" which is the first argument for a class method

warped mirage
#

nah doesnt.

warped mirage
#

ye i added class at start now

#

still errors

slate swan
#

huh, class?

#

!self

unkempt canyonBOT
#

Class instance

When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.

class Foo:
    def bar(self):
        print('bar')

    def spam(self, eggs):
        print(eggs)

foo = Foo()

If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.

Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').

Why is this useful?

Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.

Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.

formal basin
#

Will this work?

visual island
keen talon
glad cradle
#

also your list is not declared inside the function so you need to put global variableName

formal basin
#

But I put that in my other bot and works so how wonโ€™t it work on this bot

#

Oh oops

#

No I never

maiden fable
robust verge
#

!self

unkempt canyonBOT
#

Class instance

When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.

class Foo:
    def bar(self):
        print('bar')

    def spam(self, eggs):
        print(eggs)

foo = Foo()

If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.

Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').

Why is this useful?

Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.

Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.

slate swan
#

How can I create a channel in a different server?

#

My Code:

guild = bot.get_guild(STAFF_SERVER)
await guild.create_text_channel(f'inquiry')

gives me this:

AttributeError: 'NoneType' object has no attribute 'create_text_channel'```
slate swan
#

Bro

#

I just realised the bot isn't in the guild ๐Ÿ’€

digital mason
#

Good morning everyone

jade tartan
slate swan
#

guys guys, I was creating a leaderboard command for ranks, and what would be the best way to arrange tuples according to the level values inside them

#

for example, my tuple looks like this -> (user_id, guild_id, xp, level)

robust fulcrum
#

Guys i am getting this error
But i saw the tutorial on GitHub but that have no error
Can anyone help me?

heavy shard
slate swan
loud junco
slate swan
loud junco
slate swan
loud junco
paper sluice
#

sorted(tuple, key=lambda x: x[-1])

slate swan
loud junco
#

(),
()

#

U missed ,

paper sluice
#

ah right

#

i was so confused, f discord

slate swan
#

so...

robust fulcrum
robust fulcrum
paper sluice
#

!e

a = [
    (4, 3, 2, 7),
    (1, 2, 7, 6)
]
print(sorted(a, key=lambda x: x[-1]))
unkempt canyonBOT
#

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

[(1, 2, 7, 6), (4, 3, 2, 7)]
robust fulcrum
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

paper sluice
#

not the iterable, when u do key=lambda x: x[-1] on a = [(4, 3, 2, 7),(1, 2, 7, 6)] it looks for the last elements of the tuple inside the list, so it sorts by the last 7 and 6

heavy folio
#

Iirc

#

Just don't use replit

potent spear
keen talon
potent spear
#

the main issue here is replit, not the version of dpy

heavy folio
#

Indeed

heady sluice
#

how send message

loud junco
heady sluice
#

ok thanks

#

Cts undefined

loud junco
#

ctx

#

Define it in the function

slate swan
#
def custom_cooldown(message):
    if message.author.permissions.manage_messages:
        return None  # no cooldown
    elif utils.get(message.author.roles, name="Nitro Booster"):
        return commands.Cooldown(2, 60)  # 2 per minute
    return commands.Cooldown(1, 60)  # 1 per minute

@bot.command()
@commands.dynamic_cooldown(custom_cooldown, commands.BucketType.user)
async def ping(ctx):
    await ctx.send("pong")

This was a example for custom cooldown in discord.py server however i'd like to ask is there anyway to make a cooldown condition if the second argument for the command was something specified?

heady sluice
#

ay I found a pretty good explanation, dude's a legend

slate swan
# heady sluice how send message

find your device -> start it -> let it load -> open discord -> select a server -> select a channel -> click on the text box -> write some shit -> press the sent button/enter button -> the message is now sent -> summing the above steps, use common sense

heady sluice
#

does this work on replit too?

loud junco
#

...

#

Dude really believes that

slate swan
heady sluice
#

oh

#

that sucks

loud junco
#

...

slate swan
#

puberty syndrome

loud junco
#

Whats wrong with Ashley

#

๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚

slate swan
heady sluice
#

so you can't send a message on replit?

loud junco
slate swan
heady sluice
#

oh

loud junco
heady sluice
#

what do I say there

slate swan
heady sluice
#

oh ok

loud junco
slate swan
#

wait, replit has a complete different branch related to hosting, didnt know that'

loud junco
#

?

#

What branch

slate swan
heavy shard
#

wow. you can host any file? any time?

loud junco
#

With a rip hosting

loud junco
heavy shard
slate swan
#

no never mind, they just say hostingbut in a cooler way

loud junco
#

๐Ÿ˜‚๐Ÿ˜‚

jade tartan
#

Do you guys have a mute cmd for yours guys bot?

loud junco
slate swan
jade tartan
# loud junco Muting others?

yes cuz tbh i have a mute cmd but tbh when the member is muted they can still type in the text channels and i dont want them to do that

#

so thats why i was asking

#

example?

slate swan
slate swan
jade tartan
#

here ill show you my code

robust fulcrum
jade tartan
#
    @commands.has_permissions(manage_messages=True)
    @commands.cooldown(1, 5, commands.BucketType.guild)
    async def mute(self, ctx, member: discord.Member, *, reason=None):
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="Muted")

        if not mutedRole:
            mutedRole = await guild.create_role(name="Muted")

            for channel in guild.channels:
                await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
        embed = discord.Embed(title="Muted", description=f"{member.mention} was muted ", colour=discord.Colour.blue(
        ), timestamp=datetime.datetime.utcnow())
        embed.add_field(name="Reason:", value=reason, inline=False)
        await ctx.reply(embed=embed)
        await member.add_roles(mutedRole, reason=reason)
 Reason: {reason}")```
heady sluice
#

pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)

robust fulcrum
#

Ok

jade tartan
slate swan
#

thats for disnake iirc, dpy accepts a datetime object

heady sluice
#

mm add_roles has a reason?

slate swan
#

yeah

heady sluice
#

and what's that last line there?

slate swan
#

but it accepts a datetime.datetime/datetime.timedelta....

loud junco
#

Ur duty is not over

slate swan
#

weird

heady sluice
#

!d discord.Member.timeout

unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the
given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to
use this...
heady sluice
#

hm

loud junco
slate swan
#

weird

#

dpy is weirded

#

effing weird

#

....?

cloud dawn
#

Being able to pass timedelta actually is pretty gut.

heady sluice
#

get Englished
you don't say until 10 minutes

#

or until 4 days

#

it's positional only

potent spear
#

datetime.timedelta(seconds=...)
all you need
or if you don't want to do maths, you have other kwargs in that constructor

heady sluice
#

yeah but it has to make sense yk

slate swan
#

pWut that depends on what library you use

jade tartan
#

So

potent spear
#

really?

cloud dawn
#

You mean specific user slash commands?

#

Yeah for a specific user?

slate swan
#

I dont even have a timeout command ;-;

robust fulcrum
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

cloud dawn
#

You are asking the question pithink

placid skiff
#

Ash is not aggressive so she doesn't timeout her members D_D

slate swan
cloud dawn
#

I'm just asking if the groups visibility is user specific.

#

You can't.

cloud dawn
#

You can write a check but you can't make them invisible.

robust fulcrum
placid skiff
cloud dawn
#

I think you're not grasping the context of complexity this involves.

placid skiff
#

bruh what do you think group commands does? lol
It's not like they're not visible to everyone, but not everyone can use them D_D

heady sluice
#

how does user specific work anyways

#

where do you define it

cloud dawn
slate swan
#

theres no user specific commands

cloud dawn
#

It's either global or guild.

heady sluice
#

no a group's one command

#

with parameters

cloud dawn
heady sluice
#

yes

#

you can get a group with get_command

slate swan
#

group commands are nothing but a command with subcommands

cloud dawn
slate swan
#

nothing to do with user/server accessibility

cloud dawn
heady sluice
#

no

cloud dawn
#

I think they we're pretty generous as well with 100.

#

No one needs 100+ slash commands.

slate swan
#

^ people should really stop making commands that are never needed or have very basic functionality with the slash ui

heavy folio
robust fulcrum
#
client = commands.Bot(command_prefix="%")

Guys is it correct for prefix
(Me using client not Bot)

heady sluice
#

@command
async def hello(inter, subcommand, *args):
await inter.idk_but_send("Yeah you used a subcommand too Ig, just solved everything in one command")

heavy folio
#

Are using dpy

#

If you are you can use GroupCog

robust fulcrum
#

Sad :(

slate swan
#

leave

#

.topic

lament depotBOT
#
**Do you think there's a way in which Discord could handle bots better?**

Suggest more topics here!

heady sluice
#

I'm sorry for ur loss

slate swan
#

leave

heavy folio
robust fulcrum
#
client = commands.Bot(command_prefix="%")

Guys is it correct for prefix
(Me using client not Bot)

slate swan
cloud dawn
#

How would Discord know that you disallowed it in your code?

slate swan
#

what is it though

robust fulcrum
#

Sorry no error me mad lmao

heady sluice
#

but I know there was something so somebody wouldn't see a command

heavy folio
#

Doesn't slash v2 already do it

slate swan
#

your "has_permissions" isnt passed to the discord pBear so stop dreaming about that

cloud dawn
heady sluice
#

๐Ÿ˜”

slate swan
cloud dawn
#

But those are handled locally by generating a message. Slash doesn't work like that.

robust fulcrum
#

How can we know about version of discord.py using pip?

robust fulcrum
#

Ok

cloud dawn
#

Discord is busy with slashDM right now.

heavy folio
#

Or discord.version If you have the terminal

cloud dawn
#

__import__("discord").__version__

heady sluice
cloud dawn
robust fulcrum
#

I downloaded latest version with pip 2.0.0 but it showing 1.7

slate swan
#

pip on replit is useless

heady sluice
slate swan
#

replit uses poetry

robust fulcrum
cloud dawn
robust fulcrum
slate swan
#

you gotta install discord.py git branch using poetry

robust fulcrum
#

Hmmm poetry add (link)

#

Like this ?

slate swan
#

poetry add git+link

#

git+ will be as it is

robust fulcrum
light violet
#

I too forked disnake๐Ÿ’ฉ nd made my own

potent spear
#

tf is your bio link even

loud junco
#

๐Ÿ˜‚

brave moth
#

is it possible to add cooldowns on on_message ?

paper sluice
#

huh?

jade tartan
#

Someone

paper sluice
paper sluice
#

so define it first

jade tartan
#

ohh ok

potent spear
robust fulcrum
#

Guys my replit keeps adding aiohttp again and again even it's already installed

slate swan
#

thats how replit works..

heavy shard
#

ohhh that's replit... with funny link names... i used it before

#

didn't know you can use it for bots

quaint epoch
loud junco
#

?

quaint epoch
#

aiohttp is for streaing downloads asynchrounously

heavy shard
#

afaik

quaint epoch
#

!d aiohttp

unkempt canyonBOT
#

Common data structures used by aiohttp internally...

quaint epoch
#

isn't it part of the stdlib?

#

i used to think requests is part of the stdlib too, but it ain't

flint isle
#
    @commands.slash_command(name="removereaction", guild_ids=config)
    async def rmreaction(self, ctx,reaction: Option('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both'],required=True ), amount: Option('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0, required=False)):
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: unhashable type: 'Option'
potent spear
#

have you looked at examples of the Option by now?

regal pulsar
heavy shard
#

coding on phone is cumbersome

robust fulcrum
brave moth
#

like for a levelling, i want to add cooldown

flint isle
kind trellis
#

The d.py library is able to handle uploading GIFs in embeds, right?

slate swan
#

thats not related to the library, yeah, discord allows it

kind trellis
#

I just wanna make sure cause I haven't seen a bot coded in Python use a local GIF file

slate swan
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

kind trellis
#

Yeah, I already did that with PNG files, but never a GIF until now

slate swan
#

a gif works just like a normal image

flint isle
potent spear
#

Ctrl f in this channel Iโ€™d suggest

slate swan
#

how to put variable in if statement?

colourtypes = ['blue',
               'cyan',
               'orange']

if colourtypes in message.content.lower():
        await message.channel.send()

heavy shard
#

other way around, if message.content.lower() in colourtypes

#

but you need to send something

slate swan
#

thxs for the help

heavy shard
#

send() shouldn't be just empty ()

slate swan
heavy shard
#

ah okay ^_^

slate swan
#

if any( color in message.content.lower() for color in colortypes)

slate swan
flint isle
potent spear
#

Ctrl f option

#

There are most likely codeblocks where people use this correctly

flint isle
#
In 4.options.0.choices.0.value: Choice values must be of type "integer"
In 4.options.0.choices.1.value: Choice values must be of type "integer"
In 4.options.0.choices.2.value: Choice values must be of type "integer"
  warnings.warn(
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-3' coro=<startup() done, defined at C:\Users\Andy\PycharmProjects\WhiskeyBotMain\wb.py:111> exception=AttributeError("'NoneType' object has no attribute 'get_channel'")>
Traceback (most recent call last):
  File "C:\Users\Andy\PycharmProjects\WhiskeyBotMain\wb.py", line 131, in startup
    location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
AttributeError: 'NoneType' object has no attribute 'get_channel'```
```py
    @commands.slash_command(name="removereaction", guild_ids=config)
    async def rmreaction(self, ctx,reaction: int = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: int = commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
        msgs = [message async for message in ctx.channel.history(limit=amount)]
flint isle
#

i understand the bottom one

potent spear
#

Fix that one first

flint isle
#

but idk what part of the options arent int

visual island
flint isle
#

wait how does a list of ints look?

potent spear
#

Really?

#

[1,2,3]

flint isle
#

oh lol i had it as strings. now i understand

remote lake
#

!rule 1

unkempt canyonBOT
remote lake
#

oh it works

timber kindle
#

I keep getting this error when I try to make a command for Banning:

Traceback (most recent call last):
  File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 111, in ban
    await discord.Guild.ban(member, reason)
  File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/guild.py", line 2026, in ban
    await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
AttributeError: 'str' object has no attribute 'id'

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

Traceback (most recent call last):
  File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 145, in on_command_error
    raise error
  File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'id' ```

this is the code

```py
@bot.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *,  reason):
    await member.send(
        f"You've been banned from **{member.guild.name}** for reason: **{reason}**"
    )
    await discord.Guild.ban(member, reason)```
potent spear
#

Have you read the error?

timber kindle
#

yes

potent spear
#

discord.Guild has to be ctx.guild

#

Thereโ€™s a difference between a class and an object

flint isle
#
choices=['checkmark','furheart','both'] ```
#

do i just remove the '

potent spear
#

Ofc not

#

checkmark isnโ€™t an integer lol

flint isle
#

then how do i make it int lol

paper sluice
brazen raft
#

How are you using choices in your code

flint isle
green bluff
flint isle
#

ill just copy the command since idk what part you mean lol

#
    @commands.slash_command(name="removereaction", guild_ids=config)
    async def rmreaction(self, ctx, reaction: int = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: int = commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
        msgs = [message async for message in ctx.channel.history(limit=amount)]
        count = 0
        for amount in msgs:
            if reaction == 'checkmark':
                await amount.clear_reaction('โœ…')
                await amount.ctx_reply(f'cleared (checkmark) reaction^ (number {count} out of {amount} messages')
                count = count + 1
                return
            elif reaction == 'furheart':
                await amount.clear_reaction('<furheart:802746458088013864>')
                await amount.ctx_reply(f'cleared (furheart) reaction^ (number {count} out of {amount} messages)')
                count = count + 1
                return
            elif reaction == 'both':
                await amount.clear_reaction('โœ…')
                await amount.clear_reaction('<furheart:802746458088013864>')
                await amount.ctx_reply(f'cleared (furheart and checkmark) reactions^ (number {count} out of {amount} messages')
                return
            else:
                ctx.respond('{option -> reaction must be checkmark, furheart, or both.')
                return
brazen raft
#

It's outside of my field of knowledge about the library though

flint isle
#

(disnake)

paper sluice
#

!d disnake.ext.commands.Param

unkempt canyonBOT
#
disnake.ext.commands.Param(default=Ellipsis, *, name=None, description=None, choices=None, converter=None, convert_defaults=False, autocomplete=None, channel_types=None, lt=None, ...)```
A special function that creates an instance of [`ParamInfo`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.ParamInfo "disnake.ext.commands.ParamInfo") that contains some information about a
slash command option. This instance should be assigned to a parameter of a function representing your slash command.

See [Parameters](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#param-syntax) for more info.
visual island
timber kindle
#
    await ctx.guild.ban(member, reason)
TypeError: ban() takes 2 positional arguments but 3 were given```

I do ?ban (my alts username) test
and it gives this reason after changing it to ctx.guild.ban
brazen raft
slate swan
brazen raft
#

ints don't have an id attribute either

pale bridge
#
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    import music
  File "/home/runner/musicot/music.py", line 20
    async def disconnect(self,ctx):
    ^
IndentationError: unexpected indent

does anyone know what does this mean

slate swan
visual island
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

green bluff
timber kindle
slate swan
robust fulcrum
#

Anyone know how can we make a code run comamnd like @unkempt canyon have?

visual island
tidal hawk
#

Has anyone had an issue where your trying to shut down the bot inside terminal via CTRL + C

#

and the bot stops but terminal get's freezed?

potent spear
#

just spam the ctrl+c I'd say

tidal hawk
#

Spammed it 50x times

#

Still no luck

potent spear
#

you don't have an exception handler for a keyboardinterrupt right?

#

a typical except Exception

tidal hawk
#

Not sure If that says something but ctrl c works for other py scripts

jade tartan
worldly solstice
#

Hey guys, is there a way to send end embed to more then 1 webhook at once?
Thats my code:

 #create the embed
webhook = DiscordWebhook(url=hookurl_sale, username=username_sale)
embed = DiscordEmbed(title=name, description="๐ŸŸฅ SOLD", color=0x0099ff)
embed.set_title(name)
embed.set_url(buyNow)
embed.set_image(url=str(pic))
embed.add_embed_field(name="Rank", value=str(rank), inline=True)
embed.add_embed_field(name="Buyer", value=f"[{wov_name}]({profile})", inline=True)
embed.add_embed_field(name="Blocknumber", value=f"[{blockNumber}]({tx_link})", inline=False)
embed.add_embed_field(name="Attributes:\n", value=metadata, inline=False)
webhook.add_embed(embed)
#send the embed to webhook
webhook.execute()
print("send webhook")
print("------------------------------------------------------")```
flint isle
potent spear
slate swan
flint isle
jade tartan
slate swan
potent spear
jade tartan
#

Wait is it like mute.role = []

pale bridge
#
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    import music
  File "/home/runner/musicot/music.py", line 48
    def setup(client):
                     ^
IndentationError: unindent does not match any outer indentation level

how do i fix this

potent spear
#

this has already been answered, don't repost

pale bridge
#

ok

flint isle
slate swan
potent spear
jade tartan
#

Wait i think i know why

#

hold up

#

I think i forgot to add a line

flint isle
slate swan
#

yes, and by doing that you are allowing the reactions argument to be a normal string

flint isle
# slate swan yes, and by doing that you are allowing the reactions argument to be a normal st...

hmm i got

disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: ParamInfo(name='', name_localizations=<disnake.i18n.LocalizationValue object at 0x0000027A5E692380>, description='Your choice depicts what reaction will be removed', description_localizations=<disnake.i18n.LocalizationValue object at 0x0000027A5E6923B0>, default='reaction_name', param_name='', converter=None, convert_default=False, autocomplete=None, choices=['checkmark', 'furheart', 'both'], type=<class 'str'>, channel_types=[], max_value=None, min_value=None, large=False) is not a valid parameter annotation
slate swan
#

so you removed the = too.

flint isle
#

yes

#

i have ```py
async def rmreaction(self, ctx, reaction: commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):

now
slate swan
#

๐Ÿšถโ€โ™‚๏ธ ```py
async def command(inter, param = commands.Param(*args)):
...

flint isle
#

ah

slate swan
#

its not an annotation, you are providing a value for that arg

flint isle
#

i have an error in the ide that says unresolved refrence 'param'

heavy shard
#

:furheart:

#

๐Ÿ˜ฆ

flint isle
flint isle
# slate swan ๐Ÿšถโ€โ™‚๏ธ ```py async def command(inter, param = commands.Param(*args)): ... ``` ...

    @commands.slash_command(name="removereaction", guild_ids=config)
    async def rmreaction(self, ctx, reaction: param = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: param = commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
        msgs = [message async for message in ctx.channel.history(limit=amount)]
slate swan
#

;-;

#

!e ```py
def a( arg : param = 1): ...

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'param' is not defined
slate swan
#

this is what u r doing

heavy shard
#

let arg be typehinted param and be equal commands.Param( ... )

flint isle
#

i tried replacing the int typehing with str and didnt get an error

#

but something in my code is still broken

#

wait which of these are supposed to be selected

heavy shard
#

wrong permissions would give you error 403