#discord-bots

1 messages · Page 1048 of 1

sick birch
#

It’s off by default

slate swan
#

they dont have Intents.message_content in their code

robust fulcrum
#

It will take me 1 month pls help it's my request pls

#

I'll learn it after making command surely

slate swan
#

and stop using discord_components pls 🙏

robust fulcrum
gaunt mortar
slate swan
#

the library is no longer maintained
components are available in discord.py already
they mess with discord.py internals causing unwanted errors

slate swan
sick birch
slate swan
#
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix="$", intents=intents, message_content=True, messages=True)``` should be ```py
intents = discord.Intents.default()
intents.members = True
intents.message_content=True
intents.messages=True
client = commands.Bot(command_prefix="$", intents=intents,  )```
sick birch
#

And I doubt anyone here is going to give you fully working code for exactly what you want

granite parcel
#

how do i set perm for a role for channel in ctx.guild.channels?

robust fulcrum
sick birch
#

Spoonfeeding is against our philosophy here

#

Sorry but we can’t do that

robust fulcrum
#

But

sick birch
#

Can’t help you unless you put in a little bit of effort by reading the docs

robust fulcrum
granite parcel
#

-;-

slate swan
#

@robust fulcrum u go and do some search on github

robust fulcrum
robust fulcrum
robust fulcrum
#

8

slate swan
#

I'm on 9

#

cokecane sent you a library, did you check it (meh, i made it.)

gaunt mortar
robust fulcrum
#

Me India

slate swan
#

So school student is not a valid excuse

sick birch
slate swan
#

@robust fulcrum i can give you a basic idea how that works...

robust fulcrum
#

I'll be happy :)

slate swan
#

don't expect too much

robust fulcrum
#

Il

#

Ik I'll try to manage

slate swan
#

He's just giving u idea

#

starting off with making a request, you would be using requests/aiohttp to make a request to that website ```py
import requests
import aiohttp

response = requests.get("url to the endpoint") #in requests
response = await clientsession.get("url to the endpoint") # in aiohttp where clientsession is an aiohttp.ClientSession object
, now you would like getting the response json which can be done easily bypy
response_json = response.json() # in requests
response_json = await response.json() #in aiohttp
``` response_json is a dictionary which you can print and use to get info

if you wanna try something easier, i made a library named pokelance ( pip install pokelance) which you can use if you're interested

#

is there a way to create discord channels via a bot command?

#

good for you that the site does not require any kind of headers or auth

slate swan
unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission
to create the channel...
slate swan
#

aight bet

slate swan
granite parcel
#

how do i set perm for a role for channel in ctx.guild.channels?

slate swan
#

!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...
granite parcel
#
        if result is None:
            role = await ctx.guild.create_role(name="Muted")
        for channel in ctx.guild.channels:
            await channel.set_permissions(role, speak=False, send_messages=False, read_message_history=True, read_messages=True)```
#

this is my code

#

and its setting the perm only for ctx channel

placid skiff
#

Welcome to discord bots section

slate swan
#

Hello, could someone help me to create a bot because I'm struggling a bit ?

sick birch
#

What do you need help with?

brave forge
#

drop the link to discord.ui

granite parcel
#

@sick birchcan u go through my code

sick birch
#

Is there specifically anything wrong with it?

slate swan
sick birch
#

Where do these articles come from?

slate swan
#

vinted

brave forge
#

@sick birch which module is better to use for buttons in discord.py ?

sick birch
granite parcel
brave forge
#

@sick birch so that there are buttons under the message

slate swan
#

but after I have the api I don't know how to do it

placid skiff
#

you need some experience for that
Sadly you can't just project something and then think that you can do it without any experience at what do you need to do it.
You will need to check if vinted has an API, if not you will have to use some webscraping method and it will be a lot harder, if they do you will need to study requests and learn how to get datas from the API and then you can start with making your bot

brave forge
sick birch
#

If you have 2.0 it should come preinstalled

slate swan
#

and i have a last question, do you have any videos to advise me to learn python and how to code bots ?

brave forge
slate swan
#

Can someone help me making music bot?

placid skiff
#

I dunno, Robin can I sponsor a youtuber here? D_D

sick birch
#

Then you should just be able to import it

sick birch
granite parcel
#

it is not setting the perms what is wrong @sick birch

brave forge
sick birch
#

The docs?

uncut comet
#

hey i have a issue when switching from requests to aiohttp is anyone able to help? i have added print messages to see how far it gets and i dont get any issues it just stops

        print("hu")
        print(members.avatar.url)
        print(joke.avatar.url)
        async with aiohttp.ClientSession() as cs:
            print("56")
            async with cs.get(members.avatar.url) as r:
                img_data = await r.read()
                print("huh")
                with open('./image/match2.jpg', 'wb') as handler:
                    print("looop")
                    handler.write(img_data)
                    print("work?")
            print("here")
            async with cs.get(joke.avatar.url) as r:
                img_datas = await r.read()
                with open('./image/match1.jpg', 'wb') as handler:
                    handler.write(img_datas)
        await cs.close()
        print("lo")

output

hu
https://cdn.discordapp.com/avatars/477895129084985354/ffc1a0e6bb690c37f3c7fc5358ba47b2.png?size=1024
https://cdn.discordapp.com/avatars/443893362135793670/283a5b1f7e2ac9959eb4a26ffc6d2cb3.png?size=1024
sick birch
#

2.0 docs

unkempt canyonBOT
#

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

Retrieves the content of this asset as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.
slate swan
#

just do avatar.read().

#

Huh

brave forge
#

like some version discord.py available on github@sick birch

slate swan
#

Alri

placid skiff
sick birch
#

2.0

brave forge
brave forge
sick birch
#

I’m not sure what you’re asking for. Buttons have full support with regular old discordpy with nothing extra

slate swan
#

Robin could u help me making music bot py

sick birch
slate swan
#

Okay

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

uncut comet
uncut comet
#

okay thank you ill try it

placid skiff
#

!d discord.Asset.read

unkempt canyonBOT
#

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

Retrieves the content of this asset as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.
placid skiff
#

The method you're using will do this

#

so essentially you will get the avatar of the user as a bytes object

uncut comet
#

ahh okay thank you ill try it

brave forge
#

shit fucking needs this down to be banned on github
https://github.com/Rapptz/discord.py

sick birch
#

What?

brave forge
#

this shit has never worked for me!

slate swan
#

sounds like a "you" issue, since there are hundreds of people using it already.

brave forge
sick birch
#

Not sure what you’re on about but I’d be happy to help you fix it

brave forge
uncut comet
#

okay im back hahaha

        with open('./image/match1.jpg', 'wb') as handler:
            handler.write(await members.avatar.read)

with no error but windows says its corrupted

sick birch
#

You have to install it manually

placid skiff
brave forge
sick birch
#

two teams?

brave forge
unkempt canyonBOT
honest shoal
#

wait what is this

brave forge
#

нуы

#

yes

slate swan
#

no no

brave forge
#

I have it worth it

slate swan
brave forge
slate swan
honest shoal
#

lol

slate swan
# brave forge shit!!!

you not being able to use something doesn't make it "shit" , and fyi your "like" is just a forked ( copied ) version of tje "shit"

brave forge
#

@slate swanahahahah. This git will finally be removed

slate swan
#

who said that?

brave forge
sick birch
#

I'm so lost

brave forge
#

@slate swan
it is better to install the one through pip than through git

sick birch
#

Discord.py on pip is 1.7.3 which does not have button support

brave forge
#

pip install disocrd2 --> discord2==2.0.1

maiden fable
#

@sick birch can u code me a music bot?

#

!pypi discord2 what's this

unkempt canyonBOT
maiden fable
#

Interesting

slate swan
sick birch
maiden fable
slate swan
maiden fable
stone beacon
#

I think their name explains their motives quite well

wanton cipher
#

How does the disnake.Spotifiy thing work and how can I get a spotify activity?!?!

slate swan
#

disnake.Spotify is an instance of discord.Activity, you can loop on a member.activities and check if isinstance( activity, discord.Spotify is true

wanton cipher
#

I just realize because I did it to the bot, worked, everyone or anything else, nothing works

slate swan
unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See #1738 for more information.

wanton cipher
dull terrace
#

collecting data on discord bot patreon earnings and votes

wanton cipher
#

is there an intent I need?

dull terrace
#

this is the results of it

#

85 votes a day if you have 1k servers and £31 per month

slate swan
wanton cipher
slate swan
slate swan
slate swan
#

is that with a s

slate swan
slate swan
#

ah

wanton cipher
#

wait

#

huh?

#

what am I doing wrong?

slate swan
wanton cipher
#

when I try get people activity, it doesn't work

slate swan
#

they dont have an activity going on?

wanton cipher
#

they do

#

one sec

slate swan
#

show ur code too

wanton cipher
#

(this works on the bot itself but not others)

dull terrace
#

Based on lots of maffs, you earn £31 per 1000 servers per month on average with game bots, with my current ad buys it'd cost £70 for 1000 servers (maybe)

#

so if retention is less than 2 months on average it'd be a loss suspicious

slate swan
#

How can i get when it was deleted at?

<t:{int(message.deleted_at.timestamp())}:F>```
#

you sure thats the correct app? also,
can i see you actual bot instance

wanton cipher
slate swan
#

I’m developing a bot and I tried to run it, and I got a unable to create process using

It then says under Process finished with exit code 101

HELP

wanton cipher
#

@slate swan is that what you wanted?

#

I just can't fit the overwrites to on_ready, on_disconect, on_command_error, or on_resumed...

tough lance
#

Why don't you use get_member instead of fetch_member

slate swan
#

Someone please HELP

wanton cipher
tough lance
#

Yea

#

Fetch returns somewhat of user data

#

Don't remember what

slate swan
#

yeah thats what i needed, well your code seems correct and the intents too

#

cant say what the problem is, but lemme recheck

wanton cipher
#

sorry, I'm just pissed xD

#

thank you so much

stone beacon
tough lance
slate swan
stone beacon
#

Probably

stone beacon
#

u using a venv?

slate swan
#

message does not have a deleted_at property

slate swan
#

if you are in a on_message_delete event etc, just use datetime.datetime.now()

#

just double checked everything is in path and if due is still there @stone beacon

tough lance
slate swan
#

Is this related to me?

tough lance
#

Ya

slate swan
#

If so thanks!!!!

stone beacon
#

Lovely

tough lance
slate swan
#

So what should I do then?

#

I’m using pycharm

#

for my IDE

tough lance
#

As the answer said uninstall python and reinstall with "Install for all users" option ticked

#

During installation

slate swan
#

will it make my bot get lost?

#

i installed python but am using Pycharm, should I delete pycharm?

slate swan
tough lance
#

Just uninstall python

slate swan
#

I want it to display the time it was deleted```py
@bot.event
async def on_message_delete(message):

embed=discord.Embed(title=f"Message Deleted", color=discord.Colour.blue())
embed.add_field(name=f"Member", value=f"{message.author.mention}")
embed.add_field(name=f"Message Content", value=f"{message.content}")
embed.add_field(name=f"Channel", value=f"{message.channel.mention}")
embed.set_author(name=f"{message.author.name}#{message.author.discriminator}", icon_url=message.author.display_avatar.url)
embed.set_footer(text=f"Message ID: {message.id} | {datetime.utc.now()}")

channel = bot.get_channel(975795336570363925)
await channel.send(embed=embed) ```
tough lance
#

Show your imports

slate swan
#

rip

unkempt canyonBOT
#

classmethod datetime.utcnow()```
Return the current UTC date and time, with [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzinfo "datetime.datetime.tzinfo") `None`.

This is like [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now"), but returns the current UTC date and time, as a naive [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object. An aware current UTC datetime can be obtained by calling `datetime.now(timezone.utc)`. See also [`now()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.now "datetime.datetime.now").

Warning

Because naive `datetime` objects are treated by many `datetime` methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing the current time in UTC is by calling `datetime.now(timezone.utc)`.
dull terrace
#

is there an easy way to remove unicode characters from a string?

spice adder
#

re.sub('Unicode regex pattern', string "")

dull terrace
#

7739monkathink i'd have to put every unicode pattern in existence

slate swan
#

its either .now() or utcnow()

slate swan
spice adder
#

Heyo, I've asked this here before but didn't really get a clear answer on it, but I'm wondering about how to do 2 things:

  1. In on_member_ban, I'm wanting to check if the user is in another server which the bot is in, and if they are, to have it kick them.
  2. In a slash command, have the bot send the response to another server.

I know that mutual guilds can be checked, I'm just not sure how to get specific or how to really go about doing it anything with that. Any help is greatly appreciated peepoJam

dull terrace
#

if ctx.author.id != ctx.message.author.id @brave forge

tough lance
dull terrace
#

i think that should do it iirc

spice adder
slate swan
#

its just doing 1 != 1

tough lance
#

Well

spice adder
#

Oh wait,!8 did that backwards

dull terrace
spice adder
#

String comes last

brave forge
dull terrace
#

so if the person interacting is not equal to the message author

slate swan
exotic maple
#

Ik this may not be relevant..

How do i use a color for an embed text e.g

slate swan
#

interaction.user.id != ctx.author.id

tough lance
slate swan
dull terrace
tough lance
#

Did it work?

#

I'm on mobile

slate swan
exotic maple
#

That works

tough lance
#

```diff

  • your message
exotic maple
#
- you message
#

thanks

dull terrace
#

you have interaction as your thing not ctx..

tough lance
#

^^ yea like the interaction Param is given the variable ctx

#

For most libs

slate swan
#

@tough lance which python should I download

tough lance
slate swan
#

ok ok

spice adder
quaint epoch
#

lemme see

tough lance
quaint epoch
#

nope, i can't find it

tough lance
#

He was doing datetime.utc.now()

exotic maple
#

How do i include an Argument into a command error?

slate swan
#

how can my bot send the server avatar of a user?

placid skiff
#

Wdym by "click" D_D

placid skiff
#

!d discord.ext.commands.BadArgument

unkempt canyonBOT
#

exception discord.ext.commands.BadArgument(message=None, *args)```
Exception raised when a parsing or conversion failure is encountered
on an argument to pass into a command.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
placid skiff
#

For example if you open the docs you will see what method and params bad argument has, if your error is an instance of bad_argument it will have all that params and methods

#

It means what do you mean?

#

What do you mean by "click"?
It can be anything, a reaction, a button, different object has different handlers

#

And one advise: english is essential for programmers, it is not an option

exotic maple
#

...

placid skiff
#

Bro i swear I can't understand what do you mean

slate swan
#
            if ctx.author.id != ctx.message.author.id:
                await interaction.response.send_message(f'**{ctx.author.mention}** занялся сексом с **{member.mention}**')
        button1.callback = button1_callback```
#

? розмовляй по укр ок?

#

а то я тебе не розумію

#

О

#

Угу

#

Что нужно?

#

ur black af

velvet compass
#

!rule 4 please

unkempt canyonBOT
#

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

velvet compass
slate swan
velvet compass
#

For moderation purposes, we request all communication on server to be in english

slate swan
#

geometry dash is a cool game

slate swan
#

you think the war is their fault

velvet compass
slate swan
#

this is about discord bots

velvet compass
#

And what do any of your messages have to do with that topic?

slate swan
#

uhm

#

warbot

velvet compass
#

What?

slate swan
#

?

olive osprey
#

It's not about the language itself, but due the fact that the Moderators & Admins need to fulfill their staff duties, which may create complications if it's in another language. It's pretty sinmple, besides that it's getting really off-topic

velvet compass
#

Its a server rule, we request everyone to write in english so we can moderate effectively. You did agree to those rules when you joined

#

This isn't an American server, its a worldwide membership.

#

Anyways, this is off-topic for this channel. If you have further questions regarding our rules and policies you can ask in #community-meta

kindred epoch
#

Check if the user that clicked the button is the author

#

What lib are you using

#

Try asking in their support server

quaint epoch
#

that isn't how you do it

#
class v(disnake.ui.View):

  @disnake.ui.button(label="hello", style=disnake.Style.green)
  async def callback1(self, button: disnake.ui.Button, inter: disnake.Interaction):
    # do stuff```
#

a call back returns the button AND an interaction

kindred epoch
#

@brave forge there u go

heady sluice
#

!d discord.Interaction I so have to take a look at this

unkempt canyonBOT
#

class discord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
heady sluice
#

I don't like how it's different from Context

#

no

#

View subclass outside of everything

#

buttons in View subclass

#

you can access v anywhere

#

you can use it everywhere and anywhere

#

you just create an instance like this v()
you can save it like
vinstance = v()
or just use it in your command directly
await ctx.send(view=v())

#

or whatever your class is called

#

well that's a bit more complicated

#

I would pass the user who invoked the command to the class

#

take the user in your __init__

#

check if interaction.user == member in your callback

#

example:

#
class v(disnake.ui.View):
    def __init__(self, member):
        self.member = member

    @disnake.ui.button(label="hello", style=disnake.Style.green)
    async def callback1(self, button: disnake.ui.Button, inter: disnake.Interaction):
        if interaction.user == self.member:
            # do stuff

@bot.command()
async def hello(ctx):
    await ctx.send(view=v(ctx.author))
rocky hornet
#

lol a cool hack i made

async def temp_mute_channel_member(
              channel, member, duration, reason): ...

discord.abc.Messageable.temp_mute_member = temp_mute_channel_member

discord.Message.temp_channel_mute_author = property(
    lambda self: partial(
        self.channel.temp_mute_member, self.author
    )
)

discord.ext.commands.Context.temp_channel_mute_author = property(
    lambda self: self.message.temp_channel_mute_author
)
heady sluice
#

what is this

#

literally da heck is this 😭

#

???

sick birch
#

There's no need to be rude

heady sluice
#

so I'm dumb because of missing python knowledge? 😭

#

day to day I'm gaining interest to help rather in the discord.py server

#

or just not

#

just leave it

velvet compass
#

I have not seen anything from them that seems toxic. If anything, it is your own behavior.

slate swan
#

why is it always american?

#

whats wrong with America?

velvet compass
#

@novel apex is always available for reports if I or any other mod missed something

feral lichen
#

what do i have to import/install for buttons? idk and confused

kindred epoch
slate swan
#

what?

kindred epoch
#

yup thats the exact reaction mods had

slate swan
#

you do know english isnt the only language Americans speak right?

pliant gulch
#

Not every american speaks english

slate swan
#

yup

feral lichen
#

bro keep on topic

slate swan
#

i ment America as the continent and not the united states lmfao

feral lichen
#

go to general or sum if youre gonna argue

slate swan
#

you can just make a command and pass the argument to a class

feral lichen
#

if you dont mind telling me what do you have to import for buttons/install?

slate swan
#

which you can make the View subclass outside of the cog

heady sluice
#

okimii we have like the same minds

slate swan
#

meh already gave you an example😅

feral lichen
#

broo someone answer my question please

heady sluice
#

ofc I did

heady sluice
#

inside discord.ui

feral lichen
#

using discord.ui for some reason on pycharm doesnt work :/

slate swan
heady sluice
#

from discord import ui? Idk you can access it anyway

slate swan
feral lichen
slate swan
#

do you have dpy 2.0/master/main

feral lichen
#

holdup its magically not giving an error

slate swan
#

😅

feral lichen
#

thats odd anyways thanks ig

slate swan
#

if its through the class room how didnt it reached you?🤔

olive osprey
#

You do know that you can have multiple classes in one file, right?

feral lichen
#

why is this happening? my cog was fine beforehand i added buttons

velvet compass
#

It might be time to take a short break, you seem to be frustrated

feral lichen
#

lol

slate swan
#

it seems like a break would be the best option for him

heady sluice
#

the setup function now has to be async

feral lichen
#

ah so async bot.add_cog?

heady sluice
#
async def setup(bot):
    await bot.add_cog(Cog(bot))
feral lichen
#

oh okay thanks

velvet compass
#

Cursing at them will not help

olive osprey
#

Where's the exact problem?

slate swan
#

its kinda basic oop lmao

pliant gulch
#

This is like the fourth time or so that they've been rude to the people trying to help

#

Or at least from what I've seen

feral lichen
olive osprey
#

If they think that does help them, let it be 002shrug

heady sluice
#

in the main file, you also have to await bot.load_extension()

pliant gulch
feral lichen
pliant gulch
olive osprey
#

Alright, do you know how to make a basic button? Which does only take the Button press from the author? If yes, just reverse it, don't check for the author, but for the mentioned User.

heady sluice
# feral lichen what would that be?

this was in my main file before the update:

for extension in os.listdir("cogs"):
    if extension.startswith("cog"):
        try:
            bot.load_extension(f"cogs.{extension[:-3]}")
        except commands.errors.ExtensionAlreadyLoaded:
            bot.reload_extension(f"cogs.{extension[:-3]}")
        print(f"Loaded {extension[:-3]}")

now it's

@bot.command()
async def load_cogs(ctx):
    for extension in os.listdir("cogs"):
        if extension.startswith("cog"):
            try:
                await bot.load_extension(f"cogs.{extension[:-3]}")
            except commands.errors.ExtensionAlreadyLoaded:
                await bot.reload_extension(f"cogs.{extension[:-3]}")
            print(f"Loaded {extension[:-3]}")
olive osprey
#

Alright, which library are you using? d.py 2.0?

olive osprey
#

what

feral lichen
#

what

heady sluice
#

because it could've been a fork other than dpy 2.0

olive osprey
#

There are 3rd party libraries, if it's such a "stupid" question why don't you read the docs to understand how buttons work? It's pretty easy for me, but did I mention that it's a "stupid" question? Honest question: are you trolling?

pliant gulch
#

5th time now

dapper tendon
#

How do I put words about me in the bot?

heady sluice
#

why even question the people trying to help you? we're here because we've gone through these stuff and we won't ask you questions that don't make sense

pliant gulch
olive osprey
heady sluice
#

there are plenty examples on github

olive osprey
#

I dont think that the docs are that bad, but still if you think they are bad let me atleast try to help you, instead of getting aggressive towards me.

#

Why don't you switch to d.js then?

pliant gulch
#

If your more familiar with djs why not use it instead

heady sluice
#

why dpy then

olive osprey
#

lmao

heady sluice
#

choose discord.js, the language is easier, it's faster, the documentation is better, the helpers are better

#

I recommend learning object oriented programming if we're in it

olive osprey
#

but you just said the documentation is easier for you to read, so why not continue learning Javascript instead of being mentally frustrated asking other people for help?

pliant gulch
#

And to be fair, djs is far more advanced than dpy

#

They got some good stuff in there

olive osprey
#

Yeah it definetly is

heady sluice
#

djs has voice receiving bro I'm switching rn

olive osprey
#

lmao

pliant gulch
#

Their developer community is pretty good as well

#

Their repo is very professional from the looks

pliant gulch
dense swallow
#

how do i make grp commands in d.py v2 (hybrid cmds)

@commands.hybrid_group()
async def test(self):
    ...

# how do i call the next one?
# just @test.command?
heady sluice
#

well that's a good question

pliant gulch
#

Correct you do @test.command

heady sluice
#

()

olive osprey
#

Yeah, but then don't be that aggressive. I don't even want to say that you have anger issues or anything else, maybe you even have your own mental problems that do give you reasons to switch into such mood that fast. Just try to let people help you, and dont insult them if they are actually trying to help you. It really isn't poductive. Anyways I'm out for today, I wish you a nice evening/day

pliant gulch
#

!d discord.ext.commands.HybridGroup.command

unkempt canyonBOT
#

@command(*args, **kwargs)```
A shortcut decorator that invokes [`hybrid_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.hybrid_command "discord.ext.commands.hybrid_command") and adds it to
the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HybridGroup.add_command "discord.ext.commands.HybridGroup.add_command").
dense swallow
#

but it gave me this error:
TypeError: Command signature requires at least 1 parameter(s)

pliant gulch
#

Give it another parameter then

dense swallow
#

like?

heady sluice
pliant gulch
#

Not sure, but a place holder?

dense swallow
#

self

heady sluice
#

you need ctx

#

or inter

#

what's usual for hybrid commands?

dense swallow
#

idk

pliant gulch
#

Prob ctx

dense swallow
#

so replace inter with ctx?

#

but then will it work with slash cmds?

heady sluice
#

you just have to have something after self

#

variable naming is not important

#

what the variable contains is important

dense swallow
#

alright i passed in inter

heady sluice
dense swallow
#

ok that seems to resolve it

heady sluice
#

why are we bringing Russian into this everytime

#

!ot

unkempt canyonBOT
heady sluice
unkempt canyonBOT
#

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

heady sluice
#

I didn't say you have to do it in Russian

olive osprey
#

Yeah at this point it just seems to be non sense trolling tbh, I won't answer anything of this from this point on. If you do have coding related questions, feel free to ask them in here, and let anyone who is able to help you, try to help you if you really need it.

kindred epoch
#

ok and?

heady sluice
#

exactly

kindred epoch
#

having more cuss words in a language isnt good either

#

if you think thats good then you're wrong

velvet compass
#

I think this has run its course

olive osprey
#

Well, every language has the same cuss words in the end, but that's not a suitable topic for this channel

velvet compass
#

Lets please move on

kindred epoch
velvet compass
#

And remember, @novel apex is always accepting reports.

kindred epoch
#

at this point he should be warned once, everytime he gets mad he brings in russian things

heady sluice
olive osprey
#

Let's just ignore it from now on if it's not related to the channel, and the problem is solved.

velvet compass
#

I have to run, which is why I'm mentioning it

brave forge
#

@velvet compass
give me mute for 30 minutes

velvet compass
#

Why? Just avoid the server for 30 minutes and use some self control

flat solstice
#

In my logging should I log thread events in the same channel as channel events or in separate channels

sick birch
flat solstice
short silo
#

Are the message IDs for a particular channel in a consecutive sequence?

sick birch
#

Personally I'd like that the bot let me customize it

slate swan
unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") 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...
slate swan
#

use this, and use .id property on the iterable elements

dapper tendon
#

What is the problem

slate swan
#

no they are not, each message on discord has a specific ID and they are not in order.

slate swan
#

why the $ there?

dapper tendon
slate swan
dapper tendon
#

@slate swan

slate swan
#

you dont have pip added to path

slate swan
flat solstice
# sick birch Personally I'd like that the bot let me customize it

the bot will offer some level of customisation. the bot is storing a mandatory default logging channel, and then optional logging channel for each type of event, if there is a channel for that event then it will use that channel but if not it will use the default logging channel. in the case of threads I was wondering if I should add in a specific channel for thread events bc then the bot will be checking if it has the thread events then the channel events then the default log

slate swan
#

message_content is a 2.0 thing and its available only on github, not pypi

dapper tendon
slate swan
#

install git~

#

^

dapper tendon
slate swan
#

either you didnt install libraries or chose diff interpreter w no libraries ig

#

try to switch it by ctrl shift p

#

thats replit and it usually chooses what to install itself.

slate swan
glacial echo
#

!eval

pr​int("hello world!")
unkempt canyonBOT
#

@glacial echo :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     pr​int("hello world!")
003 |       ^
004 | SyntaxError: invalid non-printable character U+200B
slate swan
#

Unable to create process using C:\Users\USER\AppData\Local\Programs\Python\Python310\python.exe

C:\Users\USER\PycharmProjects\pythonproject\venv\main.py

#

HELP

slate swan
#

wdym

potent spear
#

main.py needs to be in the pythonproject, not in the venv directory

slate swan
#

oh

#

I’m an idiot

#

How do I get it out of venv

potent spear
#

drag and drop?

slate swan
#

!eval print("Hello, world!")

slate swan
slate swan
#

he said a nono word

#

U

#

H

potent spear
#

U

slate swan
#

?

#

Uh?

slate swan
slate swan
potent spear
slate swan
#

It won’t get out of the venv direction yet

slate swan
potent spear
#

what have you even tried? nothing?

slate swan
#

Listen, there’s no need to be patronising- I’m asking for help and you volunteered to help, but I don’t appreciate you trying to make me feel bad about myself. If you want to help me then go on, but no snarky remarks

potent spear
#

well, this is a help channel for discord bots and you're asking how to move a file.
This isn't very relevant to the channel, a help channel can be used for this

slate swan
#

Well the question was about a bot.

#

it’s ok I’ll figure it out on my own or ask someone else

potent spear
#

Just because you're doing whatever this is inside of a bot does not make it discord bot related...
"i have a toaster in my house, do i ask a carpenter how to fix it?"

slate swan
#

you are ignoring my point but k

#

You can try redirect it

gaunt mortar
#

What is the best/cleanest way to do something when a button is clicked ? I've seen several examples using different solutions (callback, on_button_click but I think it's not from discord.py)..

gaunt mortar
#

By using

buttonName = Button()
torn sail
#

I would subclass it (if ur not already doing that) and create an async method named callback with one argument interaction

sharp imp
#

In python how do you get the bot to say the guild name? I'm sort of new to coding

keen mural
#

ayo what i do wrong

gaunt mortar
keen mural
livid hinge
#

it looks like there is some syntax error, can you paste the code here

keen mural
#
@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        em = discord.Embed(title=f"**Wait a little bit lmao**",description=f"Try again in `{int(error.retry_after/60)}` minutes.", color=discord.Colour.red())
        await ctx.send(embed=em)
  if isinstance(error, commands.CommandInvokeError):
    await ctx.reply("You don't have a profile, use .start to create one!")```
livid hinge
#

its unindented further than the start of the function is indented

keen mural
#

yeah i see now

#

it looked normal on screen though

livid hinge
#

yeah it did

keen mural
#

weird

#

thanks i guess though 😄

minor totem
sharp imp
heavy shard
sharp imp
#

thank you

short silo
#

can someone redirect me to docs for discordpy where i can see how to work with threads, i cant find it.

torn sail
#

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

torn sail
#

click the title for the docs for v2

short silo
#

Thanks

sage otter
#

Those are disnake docs.

#

Those aren’t the same as dpy docs.

slate swan
#

eh?

#

thats discord docs

sage otter
slate swan
#

dk what made them do this

#

!d discord.Client

unkempt canyonBOT
#

class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord.
This class is used to interact with the Discord WebSocket and API.

A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").
slate swan
short silo
#

eh i couldnt find much in the dpy docs site that i had so, i just shifted to disnake lol

sage otter
#

What????

#

You swapped libraries because you couldn’t find something in the docs.

short silo
#

i am just starting to learn, it was gonna be dpy, now its disnake

sage otter
#

AMshrug have fun I guess.

short silo
#

disnake's docs seem more user friendly tbh

slate swan
#

they are 90% same

sage otter
#

The front page is the only difference.

short silo
#

welp, guess i will jump right into it

slate swan
#

fair

sage otter
#

The api ref is ripped right out of dpy

native wedge
#

whats the different between nextcord and disnake

#

is there a better library or

torn sail
flint isle
#
Traceback (most recent call last):
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\common_bot_base.py", line 418, in _load_from_module_spec
    spec.loader.exec_module(lib)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\David Powell\PycharmProjects\WhiskeyBotMain\cogs\events.py", line 14, in <module>
    class events(commands.Cog):
  File "C:\Users\David Powell\PycharmProjects\WhiskeyBotMain\cogs\events.py", line 57, in events
    async def ping(self):
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 663, in decorator
    return InvokableSlashCommand(
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 357, in __init__
    options = expand_params(self)
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\params.py", line 690, in expand_params
    raise TypeError(f"Couldn't find an interaction parameter in {command.callback}")
TypeError: Couldn't find an interaction parameter in <function events.ping at 0x000002A387C925F0>

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

Traceback (most recent call last):
  File "C:\Users\David Powell\PycharmProjects\WhiskeyBotMain\wb.py", line 39, in <module>
    bot.load_extension('cogs.events')
#
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\common_bot_base.py", line 490, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\common_bot_base.py", line 421, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: Couldn't find an interaction parameter in <function events.ping at 0x000002A387C925F0>
#

code

    @commands.slash_command(name="ping",description='Check Bots Latency')
    async def ping(self):
        bot.get_command("ping").invoke
torn sail
flint isle
flint isle
torn sail
#

im not sure in disnake

#

ill check tho

#

!d disnake.ext.commands.slash_command

unkempt canyonBOT
#

@disnake.ext.commands.slash_command(*, name=None, description=None, dm_permission=None, default_member_permissions=None, options=None, guild_ids=None, connectors=None, auto_sync=None, extras=None, **kwargs)```
A decorator that builds a slash command.
torn sail
#

guild_ids kwarg

flint isle
#
Ignoring exception in slash command 'ping':
Traceback (most recent call last):
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 585, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\params.py", line 678, in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\utils.py", line 555, in maybe_coroutine
    return await value
  File "C:\Users\David Powell\PycharmProjects\WhiskeyBotMain\cogs\events.py", line 62, in ping
    self.bot.get_command("ping").invoke()
AttributeError: 'NoneType' object has no attribute 'invoke'

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

Traceback (most recent call last):
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1346, in process_application_commands
    await app_command.invoke(interaction)
  File "C:\Users\David Powell\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\slash_core.py", line 594, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'invoke'

    @commands.command(name="ping")
    async def ping(self, ctx: commands.Context):
        await ctx.send(f"Pong! {round(self.bot.latency * 1000)}ms")

    @commands.slash_command(name="ping", description='Check Bots Latency', guild_ids=guild_ids)
    async def ping(self, interaction):
        self.bot.get_command("ping").invoke()
zealous jay
#

Hey!

#

Im getting this error
channel = await self.client.fetch_channel(int(channel_id_server_1)) AttributeError: type object 'menciones' has no attribute 'client'

#

Why am I getting this error?

#
    def __init__(self, client: commands.Bot) -> None:
        self.client = client
#

Here im defining client, this commands is inside a cog

#

And im calling the class from the main file

sick birch
zealous jay
#

Yeah it's probably something with importing the class

#

Just realised

#

So that's not really the problem

#

Im working on it

flint isle
frozen patio
#

A slash command in what lib?

#

disnake

#

Ok so

flint isle
# frozen patio disnake

yes. i am trying to get it to execute a command that is defined earlier in the cog so i dont need to duplicate my code

frozen patio
#

Basic slash command in Disnake

@commands.slash_command(name="Hello", description="Hello command")
async def hello_cmd(self, inter: ApiCommandInteraction):
    await inter.send("This is the hellcommand!")
#

I think this is right

#

O Cogs

flint isle
#

'ApiCommandInteraction' is not defined

frozen patio
#

Define it in the cogs imports??

flint isle
#

huh? idk how to do that

frozen patio
#

That is basic Python?

flint isle
#

ok... where do i define that lol. in the

import disnake
```or
```py
from disnake.ext import commands

or am i doing it in the completely wrong spot

frozen patio
#

The top

#

of the file

#

from disnake.ext import ApiCommandInteraction

flint isle
#

cannot import name 'ApiCommandInteraction' from 'disnake.ext' (unknown location)

frozen patio
#

Oh

flint isle
#

the basic command example they gave on the page was

    @commands.slash_command(name="ping",description='Check Bots Latency')
    async def ping(self):
        bot.get_command("ping").invoke
frozen patio
#

Then try `APICommandInteraction

flint isle
#

same error

#

the example i put above works

frozen patio
#

Well

#

Hmmmmmmmm

#

from disnake import ApplicationCommandInteraction

#

That is the import name

flint isle
frozen patio
#

How aare you sending the slash?

flint isle
frozen patio
#

You need a way

frozen patio
flint isle
frozen patio
#

You need to define an interaction

flint isle
#

umm this works wiht no issues


    @commands.slash_command(name="ee", description='Check Bots Latency', guild_ids=guild_ids)
    async def ping(self,inter):
        await inter.response.send_message("Pong!")
#

but now i need to find how i can run a defined command via a slash command

#

so I can run $hello via /hello

#

i need to sleep

#

its late ill be back later

hasty chasm
#

does anyone have a good alternative to heroku for pushing code to my discord bot
github has blocked usage to heroku

hasty chasm
#

all those ones require money to use or reference heroku is there any other way for me to host

regal pulsar
#

!d disnake.ApplicationCommandInteraction

unkempt canyonBOT
#

class disnake.ApplicationCommandInteraction```
Represents an interaction with an application command.

Current examples are slash commands, user commands and message commands.

New in version 2.1.
frozen patio
regal pulsar
#

hmm

#

i see

frozen patio
#

!d nextcord.Interaction

unkempt canyonBOT
#

class nextcord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
frozen patio
#

Way easier in terms of Typing

regal pulsar
#

true

#

i just do from disnake import ApplicationCommandInteraction as ACI

frozen patio
#

Ah

#

I just remembered the as ... thing

regal pulsar
#

lol

frozen patio
#

I do not use it tho

#

🤔

regal pulsar
#

its handy with with

#
with open("file.txt") as file:
  pass
frozen patio
#

I haven't coded a bot in like 6 weeks

slate swan
unkempt canyonBOT
#

class disnake.Interaction```
A base class representing a user-initiated Discord interaction.

An interaction happens when a user performs an action that the client needs to be notified of. Current examples are application commands and components.

New in version 2.0.
slate swan
regal pulsar
#

yep

austere vale
#
async def on_message(message):
  blacklist_wrds = ["word"]
  for word in blacklist_wrds:
    if word in message.content:
      await message.channel.send("No naughty words!")
      await message.delete()
  await bot.process_commands(message)

is there a way to add smth to this so that it includes caps lock too and its not case sensitive?

torn sail
#

Dang you beat me

distant wing
#

well you used backticks so we'll call it even

austere vale
#

oh where do i putt that in?

torn sail
#

If statement

distant wing
#

message.content.lower() will lower the text of the message

#

make it all lowercase

austere vale
#

if word in message.content.lower():
?

distant wing
#

you should be able to figure out how to use that for what you want

austere vale
#

ohh

torn sail
austere vale
#

tysm

echo knot
#

just a vague question, is it difficult to code a bot thats like ticket tool?

maiden fable
echo knot
maiden fable
#

U can't really measure experience-

echo knot
#

XD im dumb

#

um

#

idk how to say it then

echo knot
maiden fable
#

Since how many months have u been coding in Python?

echo knot
#

Not much, I've basically just started

#

Im just curious like roughly how long it will take me

maiden fable
echo knot
#

k thx

#

how long have you been coding for?

maiden fable
#

Uh, 2 years now

echo knot
#

are you able to code a bot with a ticket system?

maiden fable
#

Uh, I don't like where this is going...

echo knot
#

wdym

maiden fable
#

But yea

echo knot
#

k thats cool

#

well thx for the help

torn sail
#

Ok you didn’t ask him to code it, good

echo knot
#

Hell no I would never lmao

maiden fable
echo knot
#

lmao I'm just trying to learn how to code

maiden fable
#

!resources are a great way to start!

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.

echo knot
#

sick, thx

fleet sand
#

How do I put role id in here?

some_role = #role id
@commands.has_role = (some_role)

The format of the id is <@& some number here >

vale wing
fleet sand
#

Like this?

some_role = <@&1234567890>

@bot.command(name = "test", help = "test")
@commands.has_role(some_role)
"""Description of test"""
async def test(ctx):
    await.....
torn sail
#

I think just the id

fleet sand
#

The number?

torn sail
#

Yes

fleet sand
#

I will try

fleet sand
slender night
#

Can we make a discord bot which changes its code according to the commands?

#

Like: !add-code print("Hello")

vale wing
#

@fleet sand how well do you know python

regal pulsar
unkempt canyonBOT
#

exec(object[, globals[, locals]])```
This function supports dynamic execution of Python code. *object* must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). [1](https://docs.python.org/3/library/functions.html#id2) If it is a code object, it is simply executed. In all cases, the code that’s executed is expected to be valid as file input (see the section [File input](https://docs.python.org/3/reference/toplevel_components.html#file-input) in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3/reference/simple_stmts.html#return) statements may not be used outside of function definitions even within the context of code passed to the [`exec()`](https://docs.python.org/3/library/functions.html#exec "exec") function. The return value is `None`.
vale wing
#

Not a good idea to just use this

fleet sand
slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the
command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including
caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role...
fleet sand
maiden fable
#

Cool

fleet sand
#

What I want is the role id

slate swan
slate swan
maiden fable
#

Huh?

fleet sand
slate swan
slate swan
maiden fable
#

Invi char 👀

fleet sand
slate swan
maiden fable
#

Ah, yes

#

_ _

slate swan
slate swan
# maiden fable _ _

imagine this message getting logged as an updated message with its old and new contents

maiden fable
#

Nvm, reactions dont work here

fleet sand
slate swan
#

wouldnt it be better to check perms then

#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of
the permissions necessary.

Note that this check operates on the current channel permissions, not the
guild wide permissions.

The permissions passed in must be exactly like the properties shown under
[`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions")...
supple thorn
#

!d discord.Permissions

unkempt canyonBOT
#

class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.

The properties provided are two way. You can set and retrieve individual
bits using the properties as if they were regular bools. This allows
you to edit permissions...
fleet sand
#

How about two roles with the same name but different permission?

slate swan
#

how do you differ between both the roles then... ..

supple thorn
vale wing
fleet sand
#

Wait... role id need quotes?

vale wing
#

No

fleet sand
#

Let me try

supple thorn
#

No

slate swan
# supple thorn Id?

imagine copying both the roles ids to your clipboard, pasting then and remembering which id is which role's, then opening the role menu again to assign roles

slate swan
supple thorn
supple thorn
fleet sand
#

I don't know, I'm totally confused right now

#

I even try role id with quotes

supple thorn
#

You don't put role id with quotes

fleet sand
#

I know

#

Because it didn't work, I even try quote on them

supple thorn
fleet sand
# supple thorn What is your current code now
guild_role_guildofficer = os.getenv(GUILD_ROLE_OFFICER)

@bot.command(name = "nodewar", help = "Command for Node War announcement. Permission: Guild Officer and above.")
@commands.has_role(guild_role_guildofficer)
async def nodewar(ctx, role: discord.Role, input_time, *, message):
    """
    • parameter 1 = ctx or the name of the command which is "nodewar"
    • parameter 2 is role for which this announcement is targetted
    • parameter 3 is time for nodewar
    """
    time_format = "%H%M"
    event = datetime.strptime(input_time, time_format)
    channel = bot.get_channel(guild_channel_announcement)
    embed = discord.Embed(
    title = f"Announcement: Node War",
    description = f"Tonight we will be having a Node War at __**{event.strftime('%-I.%M %p')}**__ server time.\n\n{message}\n> • We will take note on member attendance.\n> • Please join voice-chat on our discord.\nIf you can't join our Node War, please apply at <#{guild_channel_leave_application}>.\nThank you for your attention.",
    color = 0xFFFF00,
    timestamp = datetime.utcnow())
    embed.set_footer(text = f"{ctx.message.author.name}")
    await ctx.message.delete()
    await channel.send(f"Dear {role.mention}", embed = embed)
@nodewar.error
async def announce_error(ctx, error):
    if isinstance(error, commands.MissingRole):
        await ctx.message.delete()
        await ctx.send("You don't have permission to use this command!", delete_after = 3)
    elif isinstance(error, commands.error.RoleNotFound):
        await ctx.message.delete()
        await ctx.send("The command is .nodewar guild_role time_of_nodewar\nFor example:\n> .nodewar Alibaba 1700", delete_after = 5)
    else:
        raise error
#

Eh?

fleet sand
supple thorn
#

Any error?

fleet sand
#

It hits missing role

supple thorn
fleet sand
#

The error is MissingRole

supple thorn
#

Then it's working

#

What's the problem with it working?

fleet sand
#

No, I have the role to use the command

slate swan
slate swan
#

....

supple thorn
fleet sand
#

When @commands.has_role is the name of the role like ```("Guild Officer"), it works.

But when I want to use role id on @commands.has_role it goes to error and told me "You don't have permission to use this command!"

supple thorn
#

Check it again

fleet sand
#

Ofc it's the right id

supple thorn
#

Copy the role id again and paste it here

#

Usually it's human error

#

Rather than machine error

fleet sand
#

How about role id of the mods here?

slate swan
#

...

supple thorn
#

What

#

Literally how does that help

fleet sand
#

<@&831776746206265384>

slate swan
#

oh god, the role has to be in the server that the command is run in

#

please

fleet sand
#

I just show you I know how to find role

slate swan
#

._.

supple thorn
slate swan
#

just @commands.has_role(831776746206265384)

supple thorn
#

That's the moderators role id

#

Here

slate swan
#

who stores ids in an env in the first place

#

and the reason it isnt working

#

is because everything in an env is of str type

#

and has_role accepts an integer

cerulean geyser
fleet sand
fleet sand
slate swan
supple thorn
slate swan
#

😭

fleet sand
#

Shit

#

Dotenv returns string

maiden fable
#

Just do int() 😐

fleet sand
#

It seems

#

I need to change it into int

slate swan
#

😭

fleet sand
#

😄

#

Sorry Ashley, and thank you guys!

slate swan
#

welcome.....

slate swan
fleet sand
#

So I can give people my bot then they will need to costumize it to their own server

slate swan
#

uh...fine

fleet sand
#

Through editting .env

slate swan
#

😔 rip bot variables

fleet sand
#

It just channel ids and role ids

maiden fable
#

They are set to default (cleared) on restart

cloud dawn
#

Same I use globals

slate swan
#

instead of loading an env in every cog rather load it in the main file, and use botvars

#

thats my point

maiden fable
#

Ah

#

Yea, repeatedly opening the file can result in an error

cloud dawn
#

Who is senjan I've never seen him before.

maiden fable
#

I have been a prey to the same error before lemon_pensive

maiden fable
cloud dawn
#

Explains the wot

slate swan
fleet sand
#

Wait, storing id in env is bad?

maiden fable
#

Ashley gonna get mad now

cloud dawn
maiden fable
#

@cloud dawn gimme the ID, I am gonna hack the server =D

slate swan
cloud dawn
maiden fable
#

Token? 👀

fleet sand
#

Token is a must

cloud dawn
fleet sand
fleet sand
cloud dawn
slate swan
#

it will be just too much work anyways

#

plus a whole lot of errors

cloud dawn
#

Regardless of what server or token it is using it should work.

fleet sand
#

I don't know about this

#

Where can I learn it?

cloud dawn
#

You could get started with databases.

fleet sand
cloud dawn
robust fulcrum
regal pulsar
#
import disnake
from disnake import ApplicationCommandInteraction as ACI
from disnake.ext import commands
from disnake.ext.commands import Bot
import os
import dotenv

dotenv.load_dotenv()
TOKEN = os.getenv("TOKEN")

bot = Bot()


@bot.event
async def on_ready():
    print(f"Logged Into {bot.user}")


@bot.slash_command()
async def tl(inter: ACI):
    msg = await inter.response.send_message("Spanish")
    await inter.channel.create_thread(name="spanish", message=msg, auto_archive_duration=1440)
    await inter.response.defer()


bot.run(TOKEN)
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 20035): Guild premium subscription level too low

#

the error ^

#

its something about private threads needing a level 1 server

quick gust
#

i believe auto archive is a premium only feature?

regal pulsar
#

no

#

with boosts you can leave the thread open for longer

#

my duration is fine

#

but it tries to create a private thread

#

which is a premium feature

slate swan
# robust fulcrum At url i have to paste api? And at last Pokemon name?

MAKING REQUESTS TO ANY API USING THE REQUESTS LIBRARY (BASIC)

#Generally used method
import requests
response = requests.get("https://www.api.com/endpoint")
content = response.json() #converting the response to json format since most APIs are based over json response types. NOTE - An API can also return images, html, etc...

#Now assuming the response as follows
'''
{
  "main": {
    "title": "response title",
    "description" : "response description"
  },
  "external": "some other data"
} 
'''
#now you can use dictionary methods to fetch the required keys from the response, an example is as follows
title = content["main"]["title"] #or (content["main"]).get("title")
print(title)

MAKING REQUESTS TO ANY API USING THE AIOHTTP LIBRARY (BASIC)

#Generally used for asynchronization
import aiohttp
import asyncio

#requests with aiohttp can never be made outside an async function
async def get_resp():
  async with aiohttp.ClientSession() as session:
    response = await session.get("https://www.api.com/endpoint")
    #assuming same reponse type as discussed above
    content = await response.json()
  return content

print(asyncio.run(get_resp()))

This is probably not the right channel to tell such things, you might consider claiming a help channel #❓|how-to-get-help

regal pulsar
regal pulsar
#

wow

slate swan
#

the person's been asking about requests to an api from the past day 😔 i kinda felt bad

sacred plume
#

Can't you get the user avatar like this anymore ?

    asset = member.avatar_url_as(size = 128)
AttributeError: 'Member' object has no attribute 'avatar_url_as'

I' using py-cord development version(latest)

slate swan
regal pulsar
#

🤡

slate swan
#

I swear py-cord's docs dont even try to open

regal pulsar
#

lol

quick gust
#

what does that do?

#

interesting

slate swan
#

weird

regal pulsar
#

oh wow

slate swan
#

when did they even add it

regal pulsar
#

i just tried it out

#

its cool

#

a bot template

#

a cogs folder, bot.py and a .gitignore

#
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from discord.ext import commands
import discord
import config

class Bot(commands.Bot):
    def __init__(self, **kwargs):
        super().__init__(command_prefix=commands.when_mentioned_or('$'), **kwargs)
        for cog in config.cogs:
            try:
                self.load_extension(cog)
            except Exception as exc:
                print('Could not load extension {0} due to {1.__class__.__name__}: {1}'.format(cog, exc))

    async def on_ready(self):
        print('Logged on as {0} (ID: {0.id})'.format(self.user))


bot = Bot()

# write general commands here

bot.run(config.token)
slate swan
tranquil relic
#

My brain hurts from pandas and excel when i sort data everything is fine but then smaller number randomly sneak in

slate swan
#

extra options

regal pulsar
slate swan
#

an example

#

kinda useless

regal pulsar
#

i see

placid skiff
robust fulcrum
#

@slate swan i tried you code it sent me all information in form of json
How can I get information in form of discord embed

slate swan
uncut comet
#
        with open('./image/match1.jpg', 'wb') as handler:
            handler.write(await members.avatar.read)

with no error but windows says its corrupted im trying to replace my old requests way of getting pfps

pure crypt
#

what is the best way to safe id's?

slate swan
#

Umm guys how can i fix this problem?

#

ImportError: cannot import name 'PartialMessageable' from 'discord.channel'

robust fulcrum
slate swan
#

how can i fix this??

quaint epoch
#

it doesn't exist

slate swan
unkempt canyonBOT
#

class discord.PartialMessageable```
Represents a partial messageable to aid with working messageable channels when
only a channel ID is present.

The only way to construct this class is through [`Client.get_partial_messageable()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_partial_messageable "discord.Client.get_partial_messageable").

Note that this class is trimmed down and has no rich attributes...
quaint epoch
slate swan
quaint epoch
#

!d discord.channel.PartialMessageable

unkempt canyonBOT
#

class discord.PartialMessageable```
Represents a partial messageable to aid with working messageable channels when
only a channel ID is present.

The only way to construct this class is through [`Client.get_partial_messageable()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_partial_messageable "discord.Client.get_partial_messageable").

Note that this class is trimmed down and has no rich attributes...
quaint epoch
#

huh

slate swan
#

why do you think some one would document about a file?

slate swan
quaint epoch
slate swan
uncut comet
#

hello im trying to use aiohttp for the first time could i get some help

            async with aiohttp.ClientSession() as cs:
                async with cs.get(f"https://cdn.discordapp.com/emojis/{i}.png") as r:
                    emojis = await r.read()
            await cs.close()
            await ctx.guild.create_custom_emoji(name=emojinames[coot], image=emojis)

output

 Command raised an exception: ValueError: Unsupported image type given
slate swan
#

!d discord.Emoji.read

unkempt canyonBOT
#

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

Retrieves the content of this asset as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.
uncut comet
#

ahhh okay my bad

slate swan
#

just bot.get_emoji(id) and use the read method

uncut comet
#

the emojis its being given are emojis which arent in the same server as the bot

#

so would that still work?

slate swan
#

👀

placid skiff
#

I've started the auto_help project hehehe_qlash

robust fulcrum
native root
#

does anyone here know how to combine a discord webhook and a discord bot together

#

like when I run my python script it sends a message to the channel through the discord bot but using a webhook