#discord-bots

1 messages Β· Page 546 of 1

maiden fable
valid niche
#

omg i'm so freaking stupid

#

lmao

#

i removed the entire library from the setup.py, but that also means if i build it it won't actually build the library

limpid knot
#

How to get a channel via its name?

#

wait no nvm i have my old bots to look at

#

channel = discord.utils.get(ctx.guild.channels, name=w)

waxen granite
#

Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions what does this means?

slate swan
#

it means missing permissions

manic wing
slate swan
#

and forbidden

waxen granite
#

The bot doesnt have perms? Or the cmd invoker?

slate swan
#

bot

waxen granite
#

The bot is admin

#

...

slate swan
#

u sure?

waxen granite
#

Yes

#

Also all other perms are ticked as well

slate swan
#

what command is it and where this occurs?

waxen granite
#

Mute cmd

#

In a server

#

It sends me this error

slate swan
#

bot is probably trying to add a role that is above its highest role

waxen granite
#

Thr muted role is higher than the player current role

slate swan
#

since @jovial minnow

limpid knot
#

i am creating a chat bot, is it a good idea to let people set the responses of the messages how they want it?

slate swan
waxen granite
#

It was working fine a few days ago when i set it up

broken dirge
#

Can someone tell me what's wrong with my code?

#

`@ client.command(pass_context=True)
async def login(ctx):
await ctx.send("Password: ")

def check(m):
    return m.author == ctx.author and m.channel == ctx.channel

msg = await client.wait_for('message', check=check)

code = ["lol", "Lol", 1]

if msg in code:
    await ctx.send("Welcome!")
elif msg not in code:
    await ctx.send("Try again!")`
slate swan
#

if msg.content

#

and just put else instead of elif ....

broken dirge
kindred epoch
#

@broken dirge you dont need pass_context now, its outdated, you already passed context in login() which is ctx.

#

and you always need to pass it in commands

reef shell
#

if you can write codes using your cell phone, then yes, It's possible

clear rapids
#

use replit

#

or pydroid

reef shell
#

Where did you get stuck tho

#

Oh edited

#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
reef shell
#

!d discord.TextChannel.fetch_message

unkempt canyonBOT
#

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

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

by id

#

on_message event takes in message as arg

#

Please don't use Uppercase characters in variable names

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of β€˜recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
reef shell
#

Check the docs

#

Yeah, this one is for on_message event

#

That's what you should know as you are trying to using it BingShrug

#

okay, tell me when you want to trigger that action?

#

You want to react to a message when you start your bot?

#

And that message is constant?

#

I mean, do you want to react to a specific message everytime your bot starts?

#

Your endgoal is still vague

#

Please be clear about what you want to do

#

Then make a command for it, not an event

#

A command which will take channel and message id

#

and will react to that message

slate swan
#

Hi ! I have a bot made for one server only, for a community.
That community now opened another server for fivem, and i need to make the bot work in both of them.
Let's say i want to give member_role to someone: I have this in my config.py file member_role_id = 701557951894388866 and this in my command member_role = ctx.guild.get_role(member_role_id) and it works.

But would await user.add_roles(member_role) work if i had member_role_id = 701557951894388866 or 900103414837551149 in the config.py file ?

*any other ideas on how i can make this bot on multiple guilds ?

reef shell
#

No?
You need to use command decorator

lusty swallow
reef shell
#

wdym

lusty swallow
#

is this slash?

reef shell
#

if you are not using cogs, then @bot.command()

#

Yep, make a command using it

#

Your wish

#

Whatever you want to call the command

#

Yes, please finish coding it, try it and if you get errors then post it here, don't ask for help for every single lines.. Hope you understand

reef shell
#

You know how to take in arguments in commands, right?

lusty swallow
#

wait what do you want to do?

#

the commands seems to just add a reaction to a specific message

#

static command?

reef shell
#

You said you want to take input

lusty swallow
reef shell
#

....

#

Even he is confused about what he wants to do

lusty swallow
#

i think you need to do

@bot.command()
async def react_message(ctx, message_id: int = 0):
    if message_id == 0: return
    message = await ctx.channel.fetch_message(message_id)
    await message.add_reaction("πŸ‘")
#

it's usually easier to think of it as a single process rather than input and function seperately

#

you can also use reference so it reacts when you entered the command while replying

slate swan
#

Followed the instructions the discord.py documentations told me

#
import discord


class MyClient(discord.Client):
    async def on_ready(self):
        print(f"Logged in as {self.user}")

    async def on_message(self, message):
        print(f"Message from {message.author}: {message.content}")


client = MyClient()
client.run("my bots token")
#
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

The above exception was the direct cause of the following exception:
discord.errors.LoginFailure: Improper token has been passed.
RuntimeError: Event loop is closed

I got these 3 errors by the code above

reef coyote
#

Oh

#

You have a invalid token

slate swan
#

It isn't invalid

#

I double checked

lusty swallow
#

check it again just in case. might be missing a character or something

slate swan
#

hm ok

reef coyote
#

Also what the hell is myclient

#

Nvm

lusty swallow
reef coyote
#

Regenerate it if anything

#

Sometimes it glitches out

slate swan
#

Ohohoh shiit ur right i never copied the first characters πŸ˜„

reef coyote
unkempt tartan
#

im making a discord bot, and the server has its channels restricted for those only authenticated. How do I give my bot permission to speak in these channels

reef coyote
#

Here's a tip just use the copy button on that site so you don't forget! πŸ˜€

#

.env would be a great start

#

pip install python-dotenv

#

You have a file like tokens.env

slate swan
reef coyote
slate swan
#

there are otherways of calling your client?

reef coyote
lusty swallow
#

make a config.py file and add this

token = 'stuff'
```so when you import it, you do
```py
config.token
reef coyote
slate swan
#

Ok I hope xD

reef coyote
lusty swallow
reef coyote
#

I'm insane I'm leaving this to you @lusty swallow

#

I'm reading .py as env I'm going crazy

lusty swallow
slate swan
lusty swallow
#

if you did that, you need to do config.dictionary['token']

lusty swallow
limpid knot
#

POV: you are dumb

#

.js

lusty swallow
#

wym?

#

the channel is ctx.channel

#

try using the code as it is

#

does it still not work?

rapid whale
#

How to let the bot check if a channel is a stage channel, a text channel or a voice channel? This would be used for a Channelinfo command btw.

dapper cobalt
random sleet
#

how do i get space between?

#

and bold text?

kindred epoch
lusty swallow
#

Your text

#

spaces depends but if that is what i think it is, i think they are using blank fields in embeds

random sleet
kindred epoch
#

ye

random sleet
lusty swallow
#

paste the code

random sleet
#
async def embed(ctx):
    embedVar = discord.Embed(title="Verify", description="Vil du gerne kunne se hele discorden? SΓ₯ reager herunder", color=0x00ff00)
    await ctx.send(embed=embedVar)```
hardy yoke
#

camelCase in python (*angry noises)

lusty swallow
#
@bot.command()
async def embed(ctx):
    embed_var = discord.Embed(title="Verify", description="Vil du gerne kunne se hele discorden? SΓ₯ reager herunder.\n\n\n\n\n**Test**\nStuff, color=0x00ff00)
    await ctx.send(embed=embed_var)
#

try this @random sleet

#

it's snake case for variable and camel case or pascal case for class

random sleet
lusty swallow
slate swan
lusty swallow
slate swan
#

how can i get a variable from a dif function

brisk fiber
#

!botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

brisk fiber
#

@slate swan sorry forgot to ping ^

lusty swallow
#

if possible, you should make the bot a class instance instead so you can use self.var

brisk fiber
lusty swallow
#

bot.var sometimes doesn't work when i try it with a list but works if i use a integer. Not sure if it's a oop limitation or im just an idiot

lusty swallow
#

it's like making a global var. it's bad habit

shrewd pasture
#

im attempting to make stuff with json and i need one of the lines to look like this per user:
"server-ids": ["ID 1", "ID 2", "ID 3", etc etc...] and then i need to add another ID to it. and when a user runs the command it checks the array if the id is in it or not. Please lmk if you can help i dont really understand json

lusty swallow
slate swan
#

Okay i put all the code in a class, im trying to makew a login system

lusty swallow
#

it makes it easier to debug

random sleet
#

how do i set the title as a link?

lusty swallow
random sleet
lusty swallow
#

add that to your description where you want to use it

#

wait

#

wait

#

is that a title or a description?

random sleet
lusty swallow
#
embed=discord.Embed(title=title, url='google.com', description=description)
#

@random sleet

#

there's a url param in embed

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
lusty swallow
#

there's a url param there

random sleet
lusty swallow
#

it's the most common type

random sleet
lusty swallow
#

check the documentation for the full list

slate swan
#
token = input(f"{w}Token: {b}")
            
                bot = commands.Bot(command_prefix=prefix)
                bot.run(token)
#

now im trying to make an event for the on connect

lusty swallow
#

why?

slate swan
#

set status

lusty swallow
#

you need on ready

slate swan
#

ik

lusty swallow
#

so why on_connect?

slate swan
#

ohh

#

get them mixed up trbbh

lusty swallow
#

on_ready is when the bot is ready while on_connect is when the bot is connected to the server but not necessarily ready

slate swan
#

i know this may sound silly

#

but how do i take my bot offline

#

i changed my code and it's still running

valid niche
slate swan
#

i need it to go offline lol

#

any help would be super appreciated Xd

slate swan
valid niche
#

you can cause the discord API to disconnect you

#

instead, pass an activity= kwarg to the bot constructor

long dove
#

hello, how do I make a hard space for an embed field value to where it looks like

Hello @ Hello
1       2

rather than

Hello @ Hello
1 2
brave vessel
#

!e

to_space = "look         at      these uneven      spaces      i        want them    to     be     separated by   one    space"
print(' '.join(to_space.split()))
unkempt canyonBOT
#

@brave vessel :white_check_mark: Your eval job has completed with return code 0.

look at these uneven spaces i want them to be separated by one space
lusty swallow
slate swan
#

i use a blank emoji kk

lusty swallow
#

long message
1111 1111111

long message
1111 1111111
cloud dawn
#

just use blank text in the middle like a normal person

lusty swallow
cloud dawn
lusty swallow
#

i was just answering op's question. it can be any solution whichever applies

whole plinth
#

I have a link of a png, how do I turn it into a byte-like object for the webhook avatar?

lusty swallow
#

wait no, it also avatar param also accepts url

dapper cobalt
#

I think you want bot.wait_for().

#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
mental roost
#

Hey, all I'm currently learning the basics of Python and still not finished with it. Before I move to OOP but my question is when can I start learning bot development for discord or projects like web scrapping do they require just the basics to start off or we must learn more than basics

dusk pumice
#

You may read the docs and if you donxt understand it, ask here

cerulean osprey
dusk pumice
#

You may think bot and client is same

#

Just change bot to client

cerulean osprey
#

Alr, cuz everywhere else in my bot says client lmao

#

Ty

ebon island
#

How can I go about handling something like discord.errors.DiscordServerError?

hardy yoke
worthy wagon
valid perch
worthy wagon
#

I don't know why it posted 3 times

#

last time I did this a few months back, the same way, it was working, now I'm getting a 'Role' object has no attribute role

valid perch
#

Can you show error?

worthy wagon
valid perch
#

Can you show the actual error

worthy wagon
#

That is the actual error bro

#

Unless you're talking about the type of error

valid perch
#

This is what I mean by an actual error

Traceback (most recent call last):
  File "e.py", line 7, in <module>
    raise TypeError("Again !?!")
TypeError: Again !?!
#

The full error

#

Le traceback if you will

worthy wagon
#

AttrError

#

AttributeError.

valid perch
#

Just copy and paste it here

#

The full error that gets printed to screen

worthy wagon
#

hold up then man

valid perch
#

I'm holding

worthy wagon
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Role' object has no attribute 'role'

valid perch
#

Can you post the full traceback

worthy wagon
#

sure bro Idk what the difference is though but yeah

valid perch
#

Or is that everythng it sends?

#

Well the full traceback contains more information, such as exact lines. For example, based on what you've said the image you sent couldnt possibly be it

worthy wagon
#

here:

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

Traceback (most recent call last):
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Role' object has no attribute 'role'
#

let me guess, you want the top part as well

valid perch
#

Yes please

worthy wagon
#

LMFAO

valid perch
#

Or is that too much for you?

worthy wagon
#

nope one sec

valid perch
#

lmfao

#

I can make a guess based on the given info tho if you'd prefer

pliant gulch
#

Your searching through a list of roles, for a role attribute that matches what you passed

worthy wagon
#
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\core.py", line 864, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Role' object has no attribute 'role'
Traceback (most recent call last):
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(args, **kwargs)
  File "c:\Users\Cvpe4\Desktop\Mod Bot (Genesys) v1.1\cogs\misc.py", line 18, in role
    role = discord.utils.get(guild.roles, role=rle)
  File "C:\Users\Cvpe4\AppData\Local\Python\lib\site-packages\discord\utils.py", line 270, in get
    if pred(elem) == v:
AttributeError: 'Role' object has no attribute 'role'
worthy wagon
pliant gulch
#

Uh, yes it does tell you something

#

It tells you that your trying to search for Role.role where role is equal to what you passed

#

and if you think about it logically Role has no attr role

worthy wagon
#

If I change the way it's ran, I get a 'str' object has no attribute id

pliant gulch
#

What is rle, the argument you are passing supposed to be? The name of the role?

worthy wagon
#

Yes.

pliant gulch
#

Then switch out role kwarg inside of get to name

#

As again, to reiterate the attributes are represented by the kwargs passed to get

#

So basically it would be searching for Role.name where name is equal to what you passed

worthy wagon
#

change get to name

pliant gulch
#

no

#

Change the role kwarg your passing to get to name

#

role= -> name=

worthy wagon
#

bro what

worthy wagon
#

that makes 0 sense, cause from the way I'm reading this, you want me to change discord.utils.get to discord.utils.name, which doesn't exist

pliant gulch
#

No????

#

I'm telling you to change the KWARG you are PASSING

worthy wagon
#

I'm not passing a kwarg called role

#

that's a variable in the command

pliant gulch
#

Yes, the KWARG you are passing to utils.get

#

The function searches FOR attributes represented by the kwargs you pass

#

Passing role here is the same thing as looking for Role.role

worthy wagon
#

role = discord.utils.get(guild.roles, role=rle), is a my variable, not my kwarg.

pliant gulch
#

what are you

#

(guild.roles, role=rle)

worthy wagon
#

you've confused me more than this error code has

pliant gulch
#

I'm saying to CHANGE this part

#

you are passing the kwarg, role

worthy wagon
#

uhuh?

pliant gulch
#

Yes, change that to name as I said earlier

#

this function searches for attributes, represented by the kwargs you pass

pliant gulch
worthy wagon
#

'NoneType' Object has no attribute ID.

#

never mind man, I'm gonna write this a different way, thanks for the help you did provide.

pliant gulch
#

That means get returned None meaning the name you provided wasn't found

#

I don't see why you can't just typehint discord.Role to rle parameter of your command

#

which converts that argument into a discord.Role object anyways

#

I'm not sure of the point for utils.get here

worthy wagon
#

I attempted that

#

And got the same error.

#

Otherwise I would've kept it that way.

pliant gulch
#

Then whatever you are passing is not returning a result

#

Are you passing the name correctly?

worthy wagon
#

I'm aware of that.

pliant gulch
#

Is there any unicode characters inside of the name

worthy wagon
#

I tried giving it a name and an ID

#

And no.

pliant gulch
#

Β―_(ツ)_/Β―

visual island
#

and if you remove the bot.loop.create_task(initialise()) it sends once?

#

try using asyncio.create_task() instead of bot.loop.create_task()

hasty iron
#

both those things won’t affect if the bot sends messages twice

cerulean osprey
#
client = discord.bot(command_prefix = '-' )```
This is giving me an "AttributeError: module 'discord' has no attribute 'bot'". How do I fix this? I have `from discord.ext import commands` on there too bc someone told me to, but I also have `import discord` as well
cerulean osprey
#

Alr ty

tall canopy
#

Hi,may i ask that is there a way to read the data and transfer to command?Like i found a countdown website and i would like to use it in discord.

valid perch
#

@commands.cooldown(...) likely

tall canopy
odd walrus
#

trying to make a function for my disc bot
had await inside my function and it shows that it cant be outside async so do i do
async def blabla
or remain def blabla
cause im making this block so i can add into my discord command making it easier to manage and look

slate swan
#

an error appears when selecting from the list

#

@lusty swallow

slate swan
#

?

lusty swallow
#

??

#

i don't know russian

#

ohh yeah

#

you can't wait for interaction

#

make a subclass of view and add callbacks to it

#

or you can make a makeshift solution by using listener maybe

patent lark
patent lark
#

make sense?

slate swan
#

Hello

#

can anyone help me right now becuase i think im doing smthing wrong rn

random sleet
#

Hey

Dont know whats wrong here.

slate swan
#

I HAVE THE SAME PROBLME WTF

random sleet
slate swan
#

idk what im doing wrong

random sleet
slate swan
#

k

#

`import discord
from discord.ext import commands
intents= discord.Intents.all()
client = commands.Bot(command_prefix", intents=intents, case_insensitive=True)

cl = ["Random", "Moderation"]

for cog in cl:
client.load_extension(f"cogs.{cog}")
print("{} cog loaded".format(cog))

class MyHelpCommand(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
e = discord.Embed(color=0x374bbc, description='')
for page in self.paginator.pages:
e.description += page
await destination.send(embed=e)

client.help_command = MyHelpCommand()

@client.event
async def on_command_error(ctx, error):
await ctx.send(error)

@client.event
async def on_ready():
print(f"{client.user.name}#{client.user.discriminator} is running with id {client.user.id}")
await client.change_presence(
activity=discord.Activity(
type=discord.ActivityType.streaming, name="Secuirty", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"
)
)`

random sleet
#

You dont have set any prefix

#

try this

slate swan
#

send me code

random sleet
slate swan
#

what did i do wrong i copy paste it and it send me this

random sleet
#

client = commands.Bot(command_prefix="!", case_insensitive=True, intents=intents)

#

this will work

slate swan
#

omg tysm it worked

random sleet
slate swan
#

!dhelp

odd walrus
#

mans mad

hasty iron
#

lmao

slate swan
#
@bot.command(aliases=['statistics'])
async def stats(ctx):
  for data in db['user_key']:
    username = data.split(":")[1]
    reddoots = data.split(":")[2]

    if data.split(":")[3] == ctx.author.id:   

      embed=discord.Embed(title="Reddoot Statistics", description="Welcome back to the **Dashboard**", color=0xff3d3d)
      embed.add_field(name="Reddoots", value=f"{reddoots}", inline=True)
      embed.add_field(name="Username", value=f"{username}", inline=True)
      await ctx.send(embed=embed)

its not sending

lusty swallow
#

it's probably failing this if data.split(":")[3] == ctx.author.id:

final iron
#

Were there any major changes to tasks.loop() in the master version of dpy? My loop has stopped working since I updated

lusty swallow
#

can you provide the code? There were no break changes at this time. maybe you did something?

final iron
#
    @tasks.loop(minutes=1)
    async def bazaar_json_data(self):
        url = 'https://sky.shiiyu.moe/api/v2/bazaar'
        async with aiohttp.request('GET', url) as r:
            response = await r.json()
        with open('bazaar_data.json', 'w') as f:
            data = json.dumps(response,
                  indent=4, sort_keys=True,
                  separators=(',', ':'), ensure_ascii=False)
            f.write(data)
        print(f"Reloaded json data for bazaar prices.")
lusty swallow
#

did you start the loop?

final iron
#

Yes

#

In the class init statement

#

It was working fine before

#

For about 3 weeks I think

lusty swallow
#

try moving the start to on_ready

#

i'm not that experienced with aiohttp so maybe ask someone else

final iron
#

Its working now

lusty swallow
#

oof what did you do?

final iron
#

I moved it to the on_ready portion

#

Let me see if its looping though

#

Yes it working

#

Any idea why updating broke it?

lusty swallow
#

wym?

#

i think it was trying to run before the bot was even ready

#

not sure... maybe because of the slash commands, they have to change what run() does

final iron
#

Now im just wondering if anything else was affected

slate swan
#

@odd walrus omg im so sorry that was my brother i was at the bathroom

#

idk what i did wrong i need help

hasty iron
#

learn python

#

!resources

unkempt canyonBOT
#
Resources

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

boreal ravine
slate swan
#

wydm

boreal ravine
#

wtf

slate swan
#

@boreal ravine send me the whole code pls

boreal ravine
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

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

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

@slate swan

lilac latch
#

How to add multiple prefixes?

boreal ravine
#

idk if you've heard of that before

final iron
#

Damn

lusty swallow
slate swan
slate swan
# lilac latch How to add multiple prefixes?

you can pass a list in the bot constructor:

bot = commands.Bot(command_prefix=['!', '*', '?'])```
or you can use commands.when_mentioned_or like this:
```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!', '?', '*'))```
lusty swallow
#

damn didn't know you can pass multiple to command prefix

#

well i'm using customizable command prefix so on_message is kinda mandatory for me

boreal ravine
#

python lists are there for a reason

covert igloo
#

is there a reason why discord.utils and enums stopped working

#

they are both still installed

#

I tried reinstalling them and dpy

patent lark
# random sleet Hey Dont know whats wrong here.

your discord.Embed() object variable is embed24, but you call set_author on an embed variable, what is embed? no such thing in your function, it should be embed24.set_author() not embed.set_author()

lusty swallow
# boreal ravine ???

can you check a sql server for the prefix to be used on the guild and only that guild using a list? I added a command to change prefix mid process too

edit: you were replying to a different msessage. I misunderstood. sorry

boreal ravine
#

πŸ‘

slate swan
#
@commands.command()
    async def dm(self, ctx, user: discord.Member, message=None):
       user = self.bot.get_user(user)
       channel = self.bot.get_channel(900224317298729051)
       await user.send(message)
       embed = discord.Embed(description=f"**A Message Was Sent With The DM Command!**\n> `Author:` {ctx.author}\n> `Member Sent To:` {user}\n> `Message:` {message}",color=discord.Color.from_rgb(255, 255, 255))
       embed.set_author(name=f"DM Command Logs | {ctx.author}",icon_url=ctx.author.avatar_url)
       await channel.send(embed=embed)
``` it wont send either messages
smoky marsh
#

still open?

#

oh wait

stable delta
#

just do await user.send(message)

slate swan
#

thank you

gloomy quest
#

i think its ctx.purge

slate swan
#

Debug it or add prints everywhere

slate swan
gloomy quest
#

wait

slate swan
gloomy quest
#

the code is alright

slate swan
#

Lmao

gloomy quest
#

discord is messing around

stable delta
#

I'm p sure it only is for text channel

#

so ctx.channel.purge was right

gloomy quest
#

yeh

#

it was

#

i thought i could trust discord

#

but i cant

#

like yesterday discord didnt even give an error in a simple await ctx.send

boreal ravine
#

delete_after=True

gloomy quest
boreal ravine
#

Why true?

#

it's supposed to be an integer

#

literally says "delete_after"

#

Nice

boreal ravine
gloomy quest
#

yeh

#

btw

#

i recommend to use nextcord

boreal ravine
gloomy quest
#

ohh

trim barn
#

what a nightmare lmao

#

i only know python and and i'm not adamant about changing any libraries

gloomy quest
#

i thought i needed to use that weirdo javascript

#

yes

boreal ravine
gloomy quest
#

use nextcord

boreal ravine
slate swan
#

that's why i switched to pycord

trim barn
gloomy quest
slate swan
#

i'm decently close with the main dev so

gloomy quest
boreal ravine
#

just js OOP is confusing for me

unique breach
#

how do you use someones id to ping them in an embed?

boreal ravine
#

cant make a bot without learning oop Β―_(ツ)_/Β―

gloomy quest
#

u cant ping in an embed

slate swan
#

Please don't use ableist language

slate swan
#

it won't give them a notification but

gloomy quest
#

it wouldnt ping them

trim barn
gloomy quest
#

no

#

it will just not have more features

unique breach
gloomy quest
#

u will be stuck with the old features

#

and no support

slate swan
#

just it won't be yellow outline and they won't get a notification

unique breach
#

ok

gloomy quest
boreal ravine
slate swan
#

why stop

gloomy quest
gloomy quest
slate swan
#

oh shit ion know that

#

they have hella other devs tho

gloomy quest
#

So many people forked his api

#

And made things like

slate swan
gloomy quest
#

discord2.py

#

nextcord.py

#

soham.py(yeah ok no)

slate swan
#

soham

#

wth

gloomy quest
#

lol

#

jk

#

pycord

#

cordpy

slate swan
#

cordpy

trim barn
#

i have a feeling pycord will be the next big winner

gloomy quest
#

IhateJS.py

gloomy quest
#

yeh maybe

#

danny be like

#

noooooo

#

why people not remembering me

#

naruto sad music

slate swan
#

hmm or Disthon

#

we have some pretty good devs

gloomy quest
#

even tho i cant code a whole api

trim barn
#

so basically pycord is literally the same thing

slate swan
#

i'm the only one under 15

gloomy quest
slate swan
#

everyone else 18+

trim barn
#

go to bed yall u got school in the morning

slate swan
#

i'm 13 LOL

gloomy quest
#

i learnt code when i was 8

trim barn
#

yall bro

#

if y'all 13 you need to stay safe with my discord bot lmao

slate swan
#

i have my own Anti-Nuke, that has yet to be bypassed(no one has got over 16 bans on it)

gloomy quest
#

oh

untold token
#

Pycord development is really slow

#

And Pycord needs a lot of improvements

#

Disnake is a really good one

slate swan
#

those names are so good, like the last letter of one word is the first letter of the next

boreal ravine
#

arent threads free?

untold token
#

Private threads require Level 2 nitro boosting in a Guild

#

iirc

boreal ravine
#

isn't it public

#

by default

boreal ravine
#

how do I change it to public then

untold token
#

There should be a kwarg for it

#

Look at docs

boreal ravine
#

hm

vocal hollow
#

is there a way for my bot to check if a bot is verified or not

boreal ravine
#

yes

vocal hollow
#

how?

slate swan
boreal ravine
#

check if it has the verified bot flag

slate swan
#

or you mean in code

vocal hollow
#

no but like

#

iom code

#

yes

boreal ravine
vocal hollow
untold token
#

Do you get any errors in terminal?

vocal hollow
#

like say i want it to ban any bots that join my server that are not verified

vocal hollow
#

yes

slate swan
#

i think you can only check if it's a bot

#

idk about if it's verified or not

vocal hollow
#

ok ty

slate swan
#

checking if it's a bot is fairly simple

boreal ravine
vocal hollow
#

how would i do that

boreal ravine
#

!d discord.Member.public_flags

unkempt canyonBOT
#

property public_flags```
Equivalent to [`User.public_flags`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.public_flags "discord.User.public_flags")
boreal ravine
#

hm

#

Idk man the command worked for me

untold token
#

Does the command

#

Like !purge 8

#

And it responds?

boreal ravine
#

yes

#

Β―_(ツ)_/Β―

untold token
#

Show your whole bot code

#

Its probably a wrong indentation

#

No

#

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

untold token
#

Make sure you remove your token and other credentials

boreal ravine
#

DMing people is cringe just do it here

#

where the purge command

untold token
#

You had an on_mesage event

#

that's why

boreal ravine
#

oh

#

use .listen() then

untold token
#

^

#

listen() is better than .event as .event overrides a certain event but a listener is a external asynchronous event listener, that you make it listen to certain events and you use many of them

vocal hollow
#

ooh ik this one in ur on message event do this

await bot.process_commands(message)

#

thas how i do it

untold token
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

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

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

Example...
vocal hollow
#

k

random sleet
#

i've noticed that my bot has that moon icon. how do i set it to normal online "green"

vocal hollow
boreal ravine
#

check it the bot has a verified bot flag

vocal hollow
#

how thooo

boreal ravine
#

!d discord.Status.idle

unkempt canyonBOT
vocal hollow
boreal ravine
#

hm

slate swan
#

its not suggested to do it in on_ready

boreal ravine
#

add what?

slate swan
#

just do it when defining the bot object

boreal ravine
#
@bot.listen()
async def on_message(a):
  #ur code
untold token
#

Don't change statuses or make API calls in an on_ready event

slate swan
#

!d discord.Client , it takes a activity arg iirc

unkempt canyonBOT
#

class discord.Client(*, loop=None, **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/master/api.html#discord.Client "discord.Client").
slate swan
#

use it

untold token
#

why discord.Client

slate swan
#

( you can do it with commands.Bot too)

untold token
#

!d discord.ext.commands.Bot.activity

unkempt canyonBOT
#

property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
The activity being used upon logging in.
slate swan
vocal hollow
untold token
#

You can use this kwarg to set activities

untold token
# vocal hollow y

on_ready event is a dispatch event that can be called multiple times when your Bot connects to Discord Gateway, and changing statuses and making API calls the moment your bot connects to the Gateway has high chance that your bot gets disconnected from the Gateway entirely

boreal ravine
#

@vocal hollow

if member.public_flags.verified_bot:
  return True
else:
  return False
``` something like this
vocal hollow
#

always workd for me

boreal ravine
#

k

untold token
untold token
vocal hollow
#

bs

#
@bot.event
async def on_member_join(member):
    if not member.public_flags.verified_bot:
        await member.ban()

@boreal ravine would this work

vocal hollow
#

kty

untold token
#

But you can make it more sophisticated

#

By checking if its bot and not verified

untold token
vocal hollow
#

nothin

valid galleon
#

so i was adding stuff to my server info command, and i added the features field. but it shows up like this. how can i remove the single quotes, underscores, brackets and make them all lower case?

boreal ravine
valid galleon
#

alright i'll try that

boreal ravine
#

those are examples

vocal hollow
#

any way to get the owner of a bot

#

s it just bot.owner

boreal ravine
#

yes

#

print(bot.owner)

vocal hollow
#

kk

boreal ravine
#

kk

vocal hollow
#
@bot.event
async def on_member_join(member):
    if not member.public_flags.verified_bot:
        await member.ban()
        await member.owner.ban()
        channel = discord.utils.get(member.guild.channels, name='alerts')
        await channel.send(f':warning: NUKE ATTEMPT :warning:\n\nBot Owner: <@{member.owner.id}>\nBot: <@{member.id}>')

member has no attribute owner

boreal ravine
#

!d discord.Guild.owner

unkempt canyonBOT
#

property owner: Optional[discord.member.Member]```
The member that owns the guild.
vocal hollow
#

noi dont want the guild owner i want the bots owner

boreal ravine
#
if bot.owner:
  return
``` then
dusky girder
vocal hollow
#

its a python server lmao

boreal ravine
dusky girder
#

cool

#

didn't that go out of business?

vocal hollow
hardy yoke
boreal ravine
vocal hollow
#

no but like bot is the antinuke bot i dont want to ban that

#

i want to ban the member variable if its a nonverified bot and its owner

#
@bot.event
async def on_member_join(member):
    if not member.public_flags.verified_bot:
        await member.ban()
        await member.owner.ban()
        channel = discord.utils.get(member.guild.channels, name='alerts')
        await channel.send(f':warning: NUKE ATTEMPT :warning:\n\nBot Owner: <@{member.owner.id}>\nBot: <@{member.id}>')

member has no attribute owner

boreal ravine
#

hm

#

@vocal hollow read the docs first for bot attr's

vocal hollow
#

ok

bitter perch
#

There's so many problems with what you're doing I'm not sure where to start

vocal hollow
#

who

bitter perch
#

You.

vocal hollow
#

k

#

tellme thenwhats wrong with m code

bitter perch
#

Better hope that no users wanna join

vocal hollow
#
@bot.event
async def on_member_join(member):
    if member.bot:
        if not member.public_flags.verified_bot:
            await member.ban()
            await member.owner.ban()
            channel = discord.utils.get(member.guild.channels, name='alerts')
            await channel.send(f':warning: NUKE ATTEMPT :warning:\n\nBot Owner: <@{member.owner.id}>\nBot: <@{member.id}>')

hb now

bitter perch
#

I mean it's still a horrible idea

vocal hollow
#

why

boreal ravine
#

read the bot attr's

#

check for owner

bitter perch
#

anyone I inviting bots should have a reasonable idea of what that bot will do

vocal hollow
#

bro no one gonna use this bot except for me

#

thought u meant something wrong with the code

dusky girder
bitter perch
#

either way iirc you can't query application info

vocal hollow
#

i jus wanna know how to do it cuz why not

#

y u care why i wanna do it

dusky girder
#

πŸ€·β€β™‚οΈ

vocal hollow
#

wdym

reef shell
vocal hollow
#

damn

#

can u check the person who invited the bot at least?

slate swan
#

I love how you check for unverified bot as if it's always a nuke attempt, while most of the DM ads and nukes come from verified bots or selfbots

vocal hollow
#

with code i mean

slate swan
#

Still audit logs

vocal hollow
#

u can check audit log with code??

slate swan
#

Yes??????

#

Google is your friend

reef shell
unkempt canyonBOT
#

class discord.AuditLogAction```
Represents the type of action being done for a [`AuditLogEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.AuditLogEntry "discord.AuditLogEntry"), which is retrievable via [`Guild.audit_logs()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.audit_logs "discord.Guild.audit_logs").
reef shell
#

Check this out

slate swan
#

Then check for the correct action

vocal hollow
#

k ty

slate swan
#

But do you realize most of the malicious bots are verified right?

#

Like your "anti nuke" thingy, it's useless

vocal hollow
#

my friends server got nuked a bunch and it was always with a randomunverified bot

#

that like deleted all the channels and pinged a bunch

slate swan
#

Well then that's a trust issue

#

Only admins can add bots :)

reef shell
slate swan
#

Just never give Admin perms

#

Give ban, kick, etc.

#

But never admin

vocal hollow
#

bro chill i know im talking bout my friend

reef shell
#

I'd give only bot command kick/ban perms

boreal ravine
slate swan
#

^^

#

^^

vocal hollow
#

y u telling me this

slate swan
#

Because he invited a bot with admin perms

#

Or gave someone admin perms and invited a bot to nuke his server

#

Bots don't join by themselves 🀑

#

The least he could've done is invite it on a test server before adding it to his main server

vocal hollow
#

ok why are u telling me this tho im not the one who invited the bot with admin perms

slate swan
#

Or don't give admin perms to a, for example, giveaway bot 3HC_DiscoKek

reef shell
slate swan
#

Yeah πŸ˜‚

boreal ravine
#

hm

dusk pumice
#

Can I change role color with my bot?

slate swan
#

Yes

dusk pumice
#

I don't have any role id

#

Still yes?

slate swan
#

What do you have/want to do

dusk pumice
#

?

#

Wdym

slate swan
#

What information about the role do you have

#

What do you want to do

dusk pumice
slate swan
#

Then use utils.get

dusk pumice
#

Hmm

slate swan
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
slate swan
#

Give the roles list in the guild as first parameter, and second parameter check for name="role name"

#

There's an example for getting a member by it's name, do the same for role

dusk pumice
#

like

@bot.command()
async def test(ctx):
  a = get(name="test")
  await a.edit_role(color=ff0000)

like this?

slate swan
#

Please read the documentation

dusk pumice
#

kk

#

tnx

slate swan
#

And what do you want to do?

dusk pumice
#

change role color

#

i wanna do that

slate swan
#

Yeah but any role?

tardy lagoon
#

@waxen palm

slate swan
#

Like a command to change the role color based on the name you gave?

dusk pumice
#

Bot crates role,. after restart edit it

slate swan
#

So like !color rolename newcolor

dusk pumice
#

Yes

slate swan
#

Then use parameters

#

And type hint it to a role

#

role : discord.Role

dusk pumice
#

Hmm?

#

Okay I will try

slate swan
#

Add a command argument/parameter

dusk pumice
#

Any sample codes?

slate swan
#

Then you can do !color @Role or RoleId or RoleName

slate swan
#

No sample needed

dusk pumice
#

Okay tnx

tardy lagoon
#

@waxen palm

slate swan
#

Can you do your testing somewhere else @tardy lagoon ?

#

Thanks.

tardy lagoon
#

No uhm this guy needs discord py help

slate swan
#

Are you this guy?

tardy lagoon
#

No

boreal ravine
#

this guy

slate swan
#

Then, why do you send random stuff

tardy lagoon
#

@waxen palm

#

Im using the id for mention

boreal ravine
#

stop pinging random people

slate swan
#

Cool

#

Now maybe stop

tardy lagoon
#

K

tardy lagoon
slate swan
#

Funni var

tardy lagoon
#

I'll change my nickname

stark hearth
#

what are some ways of making a help command because i have a commands.group then have a help.command under it and i think thats really time consuming

slate swan
#

^

stark hearth
slate swan
#

@client.command(name = "echo")
async def say(ctx, test):
await ctx.send(test)

Will this cmd respond if another bot said ".echo hi" ?

#

No

#

Ok thanks

boreal ravine
#

what the

#

wdym

slate swan
#

Maybe read the question first

#

Because the answer you gave is completely irrelevant

boreal ravine
#

πŸ—Ώ ^

steep estuary
#

how to check given parameter is a member or channel ?

slate swan
#

Use a typehint

steep estuary
#

:/

#

try except ?

slate swan
#

no

#

typehint

steep estuary
#

ok trying

slate swan
boreal ravine
steep estuary
#

i am passing that from a function

slate swan
#

Doesn't matter

steep estuary
#

modlogs(target=user or channel)

slate swan
#

Use union

steep estuary
#

async def modlog(target: Union[discord.Member, discord.ChannelType]) ?

#

then how i can check what is that target in if condition

#

if target == ?

slate swan
#

Why ChannelType?

slate swan
steep estuary
#

okk

slate swan
#

an error appears when selecting from the list

torpid dew
#

does anyone know how to code a connect 4 discord bot

#

i just finished with a tictactoe bot

#

if yes

#

ping me

boreal ravine
torpid dew
slate swan
#

@boreal ravine

slate swan
boreal ravine
#

idk how

slate swan
# slate swan

I recommended using a fork instead of a 3rd party lib

#

And asking in their server as you have more chances of getting help with their lib there

reef shell
reef shell
slate swan
#

They're clearly using a 3rd party lib

#

.send doesn't have the options kwarg

#

i use discord_components

reef shell
#

mmhm

slate swan
#

Or a fork

#

discord_components is the worst 3rd party lib

reef shell
unkempt canyonBOT
#

class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.

This is usually represented as a drop down menu.

In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").

New in version 2.0.
reef shell
#

Use this

tawdry perch
#

so, if you want to create a wrapper, you are making these kinds of requests?

reef shell
#

Why need an extension when it is already in the lib

slate swan
tawdry perch
#

and you make request with something like aiohttps? (not sure if this is even correct lib)

#

or just request

reef shell
reef shell
#

Make sure you install dpy v2.0

tawdry perch
#

hmm

#

I guess you first need to authenticate(or login) the application before being able to make these requsts

waxen granite
#

How do i overcome the embed char limit?

reef shell
tawdry perch
#

so if you create a super simple code that authenticates the bot, you could alrd start making requests?

slate swan
#

If you don't know what you're doing I recommend not doing it

tawdry perch
#

I don't, and I'm not going to do anything for a while

slate swan
#

Alr

#

Please help me.

boreal ravine
slate swan
#

Also you don't have a message anywhere in that code

boreal ravine
#

why're u using message but u already have ctx

tawdry perch
# slate swan Alr

I'm just trying to find out how it works so I could understand the code somehow

reef shell
#

Show your imports

slate swan
#

METHOD can be put, get, etc, you can see them all in aiohttp's docs

tawdry perch
#

so it would be something like response.request?

slate swan
#

No, async with session.METHOD is where you do your request

tawdry perch
#

ooh

slate swan
#

response is what's being returned from the request

#

!d aiohttp.ClientSession.get

unkempt canyonBOT
#

coroutine async-with get(url, *, allow_redirects=True, **kwargs)```
Perform a `GET` request.

In order to modify inner `request` parameters, provide kwargs.
trail sparrow
#

ok

tawdry perch
#

then you use the response to get the data you want, eg. message id or something from the json

slate swan
#

response is an object, you can do await response.json() to make it into a json format

tawdry perch
#

ooh

slate swan
#

Like requests

#

aiohttp is basically like requests only that it's async which is better

tawdry perch
#

I see

slate swan
#

Make sure you stop the script when running the bot again

#

You have a second instance of your bot running in the background

#

This is normal

#

Give it a few seconds to make it appear offline

#

You have a second instance running in the background

#

That doesn't matter

#

Your script is still running

slate swan
#

how do i make simple message event like if i send ping bot responds pong

boreal ravine
slate swan
boreal ravine
#

yes

slate swan
# boreal ravine yes

i can add more than one right?
like one with ping = response "ping"
then another
like pong = response "pong"

boreal ravine
#

sure

slate swan
#

thanks

valid galleon
#

so ive made a command by using commands.is_owner(), but when i try to run those commands, i get this error:
discord.ext.commands.errors.NotOwner: You do not own this bot. This is the code in the main file:

client = commands.Bot(command_prefix = get_prefix, intents = discord.Intents.all(), owner_ids = owners, case_insensitive = True)```
valid perch
#

Assuming you made the bot on the discord dev portal you don't need to specify that

boreal ravine
valid galleon
#

so what do i need to change?

#

oh

#

sorry i didnt see the single quotes

rain olive
boreal ravine
#

same thing as it is in a normal file I guess

graceful axle
wintry shore
#

You should have shared that with a relevant server :p

graceful axle
#

Please guys fill it

inner girder
slate swan
graceful axle
boreal ravine
#

@slate swan like replying to the author of the message?

slate swan
#

1min lagging bad

boreal ravine
slate swan
#

anyways this is off-topic so go with your forms in some off-topic channel

graceful axle
#

please be polite guys

inner girder
#

..

boreal ravine
#

I just did #Flex 😎 jkjk

slate swan
#

πŸ˜‚

inner girder
slate swan
#

i mean if i want it to respond "ping" to the message 1234 the 1234 is what i send and "ping" is what bot responds to 1234

#

where do i put the 1234

inner girder
#

So like β€œ!say hi” the bot would respond with hi, copying the message?

boreal ravine
inner girder
#

@_@

slate swan
#

no i mean just like if it's for ex. just "hi" bot responds "hello"

#

like this

boreal ravine
graceful axle
#

if we make it

boreal ravine
#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of β€˜recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
graceful axle
#

person = hi
bot = responds somethin cool

inner girder
slate swan
#

oh

boreal ravine
#
@bot.listen()
async def on_message(message):
  if message.author == bot.user:
    return
  if message.content == 'hi':
    await message.channel.send("Hello!")
``` something like this will suffice
slate swan
#

thanks

inner girder
#

Would this work?

boreal ravine
#

yes

inner girder
#

Pog

#

Thanks

slate swan
#

no

#

discord.Bot aint a thing

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

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

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

Ye it is

slate swan
#

huh?

valid perch
boreal ravine
#

oh

boreal ravine
inner girder
#

I know

boreal ravine
slate swan
boreal ravine
#

he realizes that

inner girder
#

It’s my planning

slate swan
boreal ravine
valid perch
slate swan
#

oh

boreal ravine
#

im in his server

valid perch
slate swan
#

if im not wrong , swas.py is the developer of pycord ryt?

boreal ravine
#

not really his friend made it

slate swan
#

or maybe on of the dev

#

oh

valid perch
#

I like to think of him as more of the marketing side

boreal ravine
#

^

inner girder
#

That better?

slate swan
#

shipit well , i shifted to hikari so i dont know much about any fork other than disnake

boreal ravine
slate swan