#discord-bots

1 messages ยท Page 537 of 1

slate swan
#

Why do you need to do that in 2 separate events?

harsh mirage
#

idk

slate swan
#

Just put everything in one

harsh mirage
#

i just coped first and pasted and changed add to removes

slate swan
#

Anyways

#

So, your issues are the following

boreal ravine
slate swan
#

one might be overriding the other

#

have it all in one event

boreal ravine
slate swan
#

You use guilt instead of guild, you use add_rremoves instead of remove_roles and you didn't defined member before your check

slate swan
harsh mirage
#

i fixed rremove and i did member = None

slate swan
harsh mirage
#

fixed guild

boreal ravine
slate swan
#

Define member before checking..........

harsh mirage
#

i domt get it

slate swan
#

Here , define member to none

harsh mirage
#

k

slate swan
#

I doubt you coded any of what you have by yourself

harsh mirage
#

member not found

slate swan
#

Do you have members intent enabled

harsh mirage
#

whats that

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

Enable the members intent

#

And please READ the entire message, don't just look at the piece of code and copy paste it like everything you've did so far

slate swan
# slate swan

get rid of all these lines by using

obj = {"item": "fish", "amount": amount}
users[str(user.id)].setdefault("inventory", [])
users[str(user.id)]["inventory"].append(obj)

I get what you're trying to make but there's something you need to be aware of, each "fish" you append will be in its own dict so you have to increase the amount instead of appending the same item

slate swan
#

What did you do

harsh mirage
#

seen messsage and enabled that for my bot

slate swan
#

Okay now try again

harsh mirage
#

k

#

when i said enabled for bot i didnt mean paste the code

#

lemme do that now

#

member not found

slate swan
#

What's your code now

#

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

#

Hey @harsh mirage! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
#

oh god

harsh mirage
#
import discord


from discord import Intents
from discord.ext import commands

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




client = discord.Client()
member = None

@client.event
async def on_ready():
	print("Logged in.")
	
@client.event
async def on_raw_reaction_add(payload):
	message_id = payload.message_id
	if message_id == 898312112944865302:
		guild_id = payload.guild_id
		guild = discord.utails.find(lambda g : g.id == guild_id, client.guilds)
		
		
		if payload.emoji.name == 'yen':
			role = discord.utils.get(guilt.roles, name = 'Yellow Team')
		elif payload.emoji.name == "euro":
			role = discord.utils.get(guild.roles, name = 'Blue Team')
		else:
			role = discord.utils.get(guild.roles, name = payload.emoji.name)
			member = None
		if role is not None:
			member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
		if member is not None:
			await member.add_roles(role)
		else:
			print("Member not found.")
	else:
		print("Role not found")
		
@client.event
async def on_raw_reaction_add(payload):
	message_id = payload.message_id
	if message_id == 898312112944865302:
		guild_id = payload.guild_id
		guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
		
		
		if payload.emoji.name == 'yen':
			role = discord.utils.get(guilt.roles, name = 'Yellow Team')
		elif payload.emoji.name == "euro":
			role = discord.utils.get(guild.roles, name = 'Blue Team')
		else:
			role = discord.utils.get(guild.roles, name = payload.emoji.name)
			member = None
		if role is not None:
			member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
		if member is not None:
			await member.add_removes(role)
		else:
			print("Member not found.")
	else:
		print("Role not found")
		
@client.event
async def on_raw_reaction_remove(payload):
	pass
	

client.run')```
#

bruh srry

slate swan
harsh mirage
#

lemme change token

#

i did but idk how to sent it

slate swan
#

You're missing the intents

#

In the message you were supposed to read ^

#

Wrong indentation, align it same as the if

harsh mirage
#

bruh whats wrong there

slate swan
#

Okay so first

#

Fix the guilt things

harsh mirage
#

and i AGAIN changed guilt

slate swan
#

Then compare these two pictures

#

Just look at the parameters

#

Something with "intents"

#

And lastly, align this to the if

#

And don't forget to learn Pytho n before doing a bot, it's always better than copy pasting code without knowing what you do

harsh mirage
#

im beghiner in bots, thats hoe i start ehen i lwarn something new. i copy n paste and at the end i rewatch the vid to see what he said for definitions

slate swan
#

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

harsh mirage
slate swan
#

== not =

harsh mirage
#

try both with '==' and '=' still error

harsh mirage
slate swan
#

and I said to align not replace

harsh mirage
#

oh

#

what align means... my forst language isnt English

slate swan
harsh mirage
#

ty

slate swan
slate swan
#
  • means all
#

ehhh

#

You normally never really do that

#

You only import what you need

#

So no don't use *

#

unless what you need is everything

#

Which is never the case

harsh mirage
#

aligned, still 'None' error

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

harsh mirage
slate swan
#

Why did you changed your code

#

Keep the code from before omg

harsh mirage
#

i did

slate swan
harsh mirage
#

oh wait...

slate swan
#

No you didn't.......

harsh mirage
#

ye

#

you just got me confused

slate swan
#

Not my fault if you don't have the Python basics with you

serene lynx
#
# code
extensions = [
    "cogs.event",
    "cogs.fun",
    "cogs.information",
    "cogs.leveling",
    "cogs.manageserver",
    "cogs.mod",
    "cogs.modmail",
    "cogs.music",
    "cogs.other",
    "cogs.owner",
    "cogs.search",
    "cogs.set_prefix",
]


if __name__ == "__main__":
    for ext in extensions:
        bot.load_extension(ext)

#error
$ d:/ditttt2044/env/Scripts/python.exe d:/ditttt2044/adit.py
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "help" is not found
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "help" is not found```
#

why this error?

slate swan
#

you probably removed the help command with bot.remove_command or by setting help_command=None in commands.Bot

slender river
serene lynx
#
import discord
from discord.ext import commands

bot, token = (
    commands.Bot(
        command_prefix="d1t ", help_command=None, intents=discord.Intents().all()
    ),
    "...",
)

extensions = [
    "cogs.event",
    "cogs.fun",
    "cogs.information",
    "cogs.leveling",
    "cogs.manageserver",
    "cogs.mod",
    "cogs.modmail",
    "cogs.music",
    "cogs.other",
    "cogs.owner",
    "cogs.search",
    "cogs.set_prefix",
]


if __name__ == "__main__":
    for ext in extensions:
        bot.load_extension(ext)

bot.run(token)
slender river
slate swan
#

aint it obvious that if you help_command = None there will be no help command?

slate swan
# slate swan WDYM

you need to write it again , it often happens when you copy paste code from other files

slate swan
#

what cog is it in?

slate swan
#

show the cog

#

I was coding and my restarted automatically

#

Perfect

fallow mauve
#

i have a question

#

so im trying to get it so my bot will delete it's message when i react to it with a specific emoji, how does that work?

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesnโ€™t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itโ€™s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
slate swan
#

!d discord.on_raw_reaction_add

dapper cobalt
#

Check if the reaction.emoji is equal to the emoji you want, and that if the user.bot is Fale.

flint isle
#

I am using the colored text in the console for debugging my bot

harsh mirage
#
import discord


from discord import Intents
from discord.ext import commands

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




client = discord.Client()
member = None

@client.event
async def on_ready():
	print("Logged in.")
	
@client.event
async def on_raw_reaction_add(payload):
	message_id = payload.message_id
	if message_id == 898312112944865302:
		guild_id = payload.guild_id
		guild = discord.utails.find(lambda g : g.id == guild_id, client.guilds)
		
		
		if payload.emoji.name == 'yen':
			role = discord.utils.get(guild.roles, name = 'Yellow Team')
		elif payload.emoji.name == "euro":
			role = discord.utils.get(guild.roles, name = 'Blue Team')
		else:
			role = discord.utils.get(guild.roles, name = payload.emoji.name)
		if member:
			if condition:
				pass
		if role is not None:
			member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
		if member is not None:
			await member.add_roles(role)
		else:
			print("Member not found.")
	else:
		print("Role not found")
		
@client.event
async def on_raw_reaction_add(payload):
	message_id = payload.message_id
	if message_id == 898312112944865302:
		guild_id = payload.guild_id
		guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
		
		
		if payload.emoji.name == 'yen':
			role = discord.utils.get(guild.roles, name = 'Yellow Team')
		elif payload.emoji.name == "euro":
			role = discord.utils.get(guild.roles, name = 'Blue Team')
		else:
			role = discord.utils.get(guild.roles, name = payload.emoji.name)
		if member:
			if condition:
				pass
		if role is not None:
			member = discord.utils.find(lambda m : m.id == payload.user_id, guild.members)
		if member is not None:
			await member.add_removes(role)
		else:
			print("Member not found.")
	else:
		print("Role not found")
		
@client.event
async def on_raw_reaction_remove(payload):
	pass
	

client.run('TOKEN ')```
slate swan
#

Please

#

Are you being serious now?

#

Or you're just trolling at this point

harsh mirage
#

guess

slate swan
#

I don't help you anymore, you don't do what I say. You copy paste code you don't even understand. You don't know Python basics.
I'm sorry but at this point you should learn Python before doing a bot.

dapper cobalt
slate swan
#

I already explained him that over 6 times

dapper cobalt
#

Man got so frustrated, I believe you were extra stupid or something.

slate swan
#

Good luck on making him understand Python's basics when he probably never really heard about programming before copying the code

harsh mirage
#

nvm... ill figure it by myself. yall will see when i became the best programmer in the future

dapper cobalt
#

It's okay, Krypton.

slate swan
#

Anyways, you both have a great day ^^

harsh mirage
#

...

dapper cobalt
harsh mirage
#

i dont have humor, i will became top 10 programmer

#

i did

#

oh wait

harsh mirage
#

i didnt

slate swan
#

You never did, I already explained you so many times

dapper cobalt
#

role was None; therefore, member was never defined.

harsh mirage
slate swan
#

And you also haven't added the intents as I've told you also around 3-4 times

harsh mirage
fallow mauve
#

why wont this work?

1  @Bot.command()
2  async def test(ctx):
3    user = ctx.author
4    if user.id == (853991571702939668):
5      message = await ctx.send('testing')
6      @Bot.event
7      async def on_reaction_add(reaction, user):
8        if reaction.emoji == (':EBup:'):
9          await message.delete
10       else:
11        await ctx.send("you can't use that command")
dapper cobalt
slate swan
#

Please read when I try to help you

slate swan
#

If you don't do what we tell you to do we can't help you out

fallow mauve
dapper cobalt
gray gazelle
slate swan
#

Naming conventions momentum

dapper cobalt
#

@Bot.event is inside your command's function.

gray gazelle
#

in the 4th line he/she uses user that's not defined

dapper cobalt
gray gazelle
boreal ravine
harsh mirage
#

ive got an idea

harsh mirage
#

i will just use carl bot's reaction role

boreal ravine
#

cool

gray gazelle
#
@Bot.command()
async def test(ctx):
    user = ctx.author
    if user.id == (853991571702939668):
        message = await ctx.send('testing')

@Bot.event
async def on_reaction_add(reaction):
    if reaction.emoji == (':EBup:'):
        await message.delete
    else:
    await ctx.send("you can't use that command")
``` this may work
dapper cobalt
#
@Bot.command()
async def test(ctx):
  if ctx.author.id == 853991571702939668:
    message = await ctx.send('testing')
    reaction, user = await Bot.wait_for("reaction_add", check=lambda r: r.user == ctx.author and r.emoji == '<:EBup:THE_EMOJI_ID_HERE>')
    await message.delete()
  else:
    return

@fallow mauve spoonfed. I'm having a good day.

boreal ravine
#

double spoonfeed

#

bruh.exe

dapper cobalt
#

But yours is partially correct.

#

It's correct from the code part, but not what he wants to do.

gray gazelle
gray gazelle
gray gazelle
dapper cobalt
#

I've practiced a lot to understand what a one wants to do from just a broken code by working with many newbies. kekw

slate swan
dapper cobalt
#

Errors?

#

Or actually, show me your code.

#

I'm pretty sure I know where the issue is.

fallow mauve
#

yeah there are no errors given

odd pendant
#

probably indentation

dapper cobalt
#

Do you get any errors?

fallow mauve
#

no

dapper cobalt
#

So what exactly "doesn't work"?

odd pendant
#

has the bot even started

fallow mauve
fallow mauve
#

it is online, it sends the message

boreal ravine
#
badwords = ["kayle"]

@commands.Cog.listener()
async def on_message(msg):
    for word in badwords:
        if word in msg.content:
            await msg.channel.send('hm')
    await bot.process_commands(msg)
``` any ideas why this doesnt work? the console doesnt give any errors
odd pendant
#

self

boreal ravine
#

oh

#

wait oops

odd pendant
#

and you probably want to put badwords in your class init, not just floating

fallow mauve
#

ive been trying to get this kinda thing to work with a friend of mine and it just wont

dapper cobalt
slate swan
#

help me.

dapper cobalt
#

Code?

boreal ravine
odd pendant
#

yeah sure

boreal ravine
#

hm

fallow mauve
boreal ravine
odd pendant
#

yeah you do you then, it really doesnt matter

boreal ravine
#

okay

fallow mauve
#

i gtg do school, b back later

dapper cobalt
slow cove
#

anyone wanna hop in a VC and help a total noob out ๐Ÿ˜„

slate swan
#

ok i fixed error

#

i was too idiotic

boreal ravine
#

How do people hyper link text in titles without it turning blue

slate swan
#

^

#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

url

#

not icon_url?

boreal ravine
#

Wait I didn't know you could set url's in the .set_author part of an embed instead of icon_url

slow cove
#

Dont know whats going on here and why its saying this module is no callable

slate swan
#

It's commands.Bot

slate swan
#

๐Ÿฆœ

slow cove
#

Okay, next query, as Im following a tutorial just to get a grasp of how to make a button in my server and im receiving this

#

im presuming im likely missing a line somewhere to define the @button is actually a command?

surreal creek
#

Yo

slate swan
#

yes

#

but we dont talk about that

dapper cobalt
#

!pypi disnake is a pretty great fork.

unkempt canyonBOT
dapper cobalt
slate swan
#

Isn't it faster to write the normal github repo KEKL

dapper cobalt
#

Don't focus too much. Lmao.

slate swan
#

xD

boreal ravine
#

how do i use functions in my cog if the function was like this? i tried it earlier but it says "Command raised an exception: AttributeError: 'Events' object has no attribute 'h1_append'"

class Events(commands.cog):
  def __init__(self, bot):
    self.bot=bot
    self.test = []
  def h1_append(self, value):
    self.test.append(value)

  @commands.command()
  async def append(self, ctx, value):
    await self.h1_append(value)
ripe jackal
#

Hello, I'm trying to create level event, but when I send 1 message at 0 exp, I instantly level up. How should I make it more like Mee6- I would need to send amount of messages, so I can level up to level 1. The code :python @client.event async def on_message(message): if message.author.bot == False: with open('users.json', 'r') as f: users = json.load(f) await update_data(users, message.author) await add_experience(users, message.author, 1) await level_up(users, message.author, message) with open('users.json', 'w') as f: json.dump(users, f) await client.process_commands(message) async def update_data(users, user): if not f'{user.id}' in users: users[f'{user.id}'] = {} users[f'{user.id}']['experience'] = 0 users[f'{user.id}']['level'] = 1 async def add_experience(users, user, exp): users[f'{user.id}']['experience'] += exp async def level_up(users, user, message): with open('levels.json', 'r') as g: levels = json.load(g) experience = users[f'{user.id}']['experience'] lvl_start = users[f'{user.id}']['level'] lvl_end = int(experience ** (1 / 5)) if lvl_start < lvl_end: await message.channel.send(f'{user.mention} has leveled up to level {lvl_end}') users[f'{user.id}']['level'] = lvl_end

strong moon
slate swan
boreal ravine
#

so Events isnt defined yet

#

i think thats how that works

slate swan
#

so you want to use the function in the command in the cog

boreal ravine
#

yes

slate swan
#

then do this in the command ```py
self.h1_append(value)

boreal ravine
#

hm

slate swan
#

if its a async function then you await it

#

If Im making a discord bot taht requires a database use..do I ask help here or on #databases pithink

boreal ravine
slate swan
#

hmm

#

it looks like my brain is smoking

boreal ravine
#

hm

lament mesa
boreal ravine
#

hm

slate swan
#

I don't think you need self as a param there

#

its in a cog

#

noticed that

#

still

#

probably havent touched dpy in a hot min

#

it's still just a class function

boreal ravine
#

oh

#

you mean the function

slate swan
#

in the def

boreal ravine
#

its a function tho

#

every attribute of a class needs self

slate swan
#

hm

lament mesa
boreal ravine
#

hm

thick sigil
boreal ravine
thick sigil
#

Too far

slate swan
#

no

boreal ravine
#

it isnt too far

thick sigil
#

ok and how do you call it

slate swan
#

?

boreal ravine
thick sigil
#

Show me your code, im not asking how to call a class func

slate swan
boreal ravine
#
  async def append(self, ctx, value):
    await ctx.send('e')
    self.hl_append(value)
slate swan
#

wait why hl

boreal ravine
#

hl_append is the name of the function

thick sigil
#

you defined h1 and calling hl

boreal ravine
#

no

#

its hl

slate swan
#

it's both h1 in the code you've sent above

boreal ravine
#

1 hl look

#

its similar

thick sigil
#

I do see the difference there

boreal ravine
#

1 l

#

oh

#

let me change the function name

#

its confusing

slate swan
#

I don't see any difference

#

both being 1

thick sigil
#

the number has an inclined line

#

l doesnt

boreal ravine
#

wait I think its because of a typo..

slate swan
#

I see the l at value

thick sigil
#

Thats what im saying lol

boreal ravine
#

it works now

thick sigil
#

๐Ÿ‘

boreal ravine
#

thanks ๐Ÿ—ฟ

slate swan
brazen seal
#

where i can find tutorial to unban command with ID users not nickname

kindred epoch
#

why do you need a tutorial when theres docs

brazen seal
#

can you send me that?

lapis lintel
#

!d discord.User

reef shell
#

!d discord.Member.ban

unkempt canyonBOT
#

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

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

Oops

#

You said Unban?

brazen seal
#

ye

#

!d discord.Member.unban

unkempt canyonBOT
#

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

Unbans this member. Equivalent to [`Guild.unban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban "discord.Guild.unban").
fresh quiver
#
import discord 
#client 
client = discord.client()
#do somtching idiot 
clint.run```
#

whats wrong here ?

brazen seal
#

XDDDDD

fresh quiver
#

4th line

pale zenith
#

run is a method that takes a token

brazen seal
#

is a joke?

reef shell
#

client.run("yourbottoken")

fresh quiver
#

i did that lol

#

who shows their token

brazen seal
#

"clint"

reef shell
#

pepega

slate swan
#

why not use bot tho

reef shell
#

cuz pepega pepega

fresh quiver
#

clint

#

wtf is wrong with me

slate swan
#

we dunno

fresh quiver
#

okie

pale zenith
fresh quiver
#

sayonara

slate swan
#

but atleast we know what's wrong with the code

pale zenith
#

?

slate swan
#

discord.Client, not client

#

what does that mean

pale zenith
#

Client capital c, not client lowercase c

slate swan
#

oh nice

fresh quiver
#

tf

#

๐Ÿคฃ ๐Ÿคฃ ๐Ÿคฃ ๐Ÿคฃ

#

i was getting fucked by that

pale zenith
#

Kek .

fresh quiver
#

wow

reef shell
#

๐Ÿ—ฟ.

pale zenith
#

full stop chad.

fresh quiver
#

nice

#

i have a question big dug

#

can bots run on while loops

dawn wasp
#

Hi guys , I have a bot hosted with replit and it logs when a message is deleted or edited ... ., but when I restart it ,
it cannot log changes for messages that were sent before the restart

pale zenith
reef shell
fresh quiver
#

i mewn

#

can a bot run on a
while True:

pale zenith
#

.run() has a reconnect kwarg that you can set.

fresh quiver
#

i wanna spam ping people

reef shell
#

bot logins and stays connected with discord in the asyncio event loop

#

Wdym

reef shell
unkempt canyonBOT
#

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

fresh quiver
#

not here m8

#

i wanna try it on my friends

pale zenith
#

wherever.

#

Spam ping breaks discord's ToS and rate limits

reef shell
pale zenith
#

and can probably get you API banned.

reef shell
reef shell
fresh quiver
#

haha

fresh quiver
pale zenith
#

what?

#

no. your token gets invalidated and when you try to reconnect it will prompt you to contact discord's Trust and Safety to reinstate your bot iirc

#

but bans can also be temporary and per-ip

fresh quiver
#

hod

#

god*

#

tq for telling

#

dat building nuclear weapins is illiagle

pale zenith
still tiger
#

How do to a person by their id?

pale zenith
#

bot.get_user(id) or guild.get_member(id)

still tiger
pale zenith
#

bot.get_user(id)

#

then user.send(...)

slate swan
still tiger
still tiger
rich sphinx
#

Guys I want to make a discord bot all rounder using python and with web control who has interest dm me

slate swan
still tiger
#

Show the code @slate swan

vestal owl
#
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\minua\Downloads\ex.py", line 59, in translation
    language = language[0]
TypeError: 'NoneType' object is not subscriptable
order completed!
spanish
<class 'str'>
Final text: Translated(src=en, dest=es, text=spanish, pronunciation=spanish, extra_data="{'translat...")
order completed!
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\minua\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\minua\Downloads\ex.py", line 59, in translation
    language = language[0]
TypeError: 'NoneType' object is not subscriptable```
#

what am I doing wrong?

#

it was working before

#
language = cur.fetchone()
    language: list
    language = language[0]
    print(language)
    print(type(language))```
signal canopy
#

Guys, i need help, when you make a bot in one file and you create an on_message event, it stops command processing and you have to initialize it yourself, i don't know how to recreate the same behavior using an event inside a discord.Cog

slate swan
#

And it doesnโ€™t work when someone @ someone else, but itโ€™s supposed to

still tiger
#

its definitely not in the code you provided, there must be a decorator at the top specifying the permissions

dapper cobalt
#

!e

array = None
print(array[0])
unkempt canyonBOT
#

@dapper cobalt :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | TypeError: 'NoneType' object is not subscriptable
vestal owl
maiden fable
#

Yo, anyone here knows how dpy sends events? I ain't able to understand lol

dapper cobalt
#

Oh, wait. It was just your print().

maiden fable
#

Can we stop this now?

dapper cobalt
#

Lmao, alright.

maiden fable
#

But I ain't kidding. Do u know how it handles events?

vestal owl
pliant gulch
#

So basically, internally they connect to a websocket

maiden fable
#

Okay?

pliant gulch
#

This websocket sends back messages

dapper cobalt
maiden fable
#

Mhm

pliant gulch
#

You read those messages, if it's the dispatch type it has an event name and event data

maiden fable
#

Mhm

vestal owl
# dapper cobalt Can you show your code?
cur.execute('SELECT id FROM flashcards_test ORDER BY id DESC')
    print('order completed!')
    cur.execute('SELECT Language FROM flashcards_test WHERE User = (?)', (user,))
    language = cur.fetchone()
    language: list
    language = language[0]
    print(language)
    print(type(language))```
pliant gulch
#

You could dispatch it etc again

worldly trench
dapper cobalt
slate swan
#
channel_entry = 862766760741699615

channel = bot.get_channel(channel_entry)
x = input()
await channel.send(x)```
how can i make this work so it doesnt only send the input once and i can reuse it without restarting the bot each time?
maiden fable
#

BTW @pliant gulch your wrapper has got supports for events or it is still a WIP?

dapper cobalt
pliant gulch
maiden fable
#

Ah okay cool

dapper cobalt
worldly trench
pliant gulch
dapper cobalt
maiden fable
slate swan
vestal owl
slate swan
#

@dapper cobalt any tips?

vestal owl
#

your missing the arguement ctx

slate swan
#

so ctx.channel.send?

dapper cobalt
slate swan
#

ohokay

dapper cobalt
#

I think you mean list(language).

slate swan
#

e
Task exception was never retrieved
exception=AttributeError("'NoneType' object has no attribute 'send'")>
Traceback (most recent call last):
await channel.send(x)
AttributeError: 'NoneType' object has no attribute 'send'

dapper cobalt
#

And also, print language right after you define it, and see what it returns.

vestal owl
dapper cobalt
slate swan
#

channel exists

dapper cobalt
#

Do you have intents enabled?

slate swan
#

yes

#

it worked before, but now that im trying to loop it so it can be used multiple times instead of once it doesnt want to work for some reason

dapper cobalt
#

Are you starting the loop before the bot starts?

slate swan
#

before the bot.run?

dapper cobalt
#

Is it inside an on_ready event or even under a await bot.wait_until_ready()?

vestal owl
#
order completed!
language ('spanish',)
spanish
<class 'str'>
Final text: Translated(src=en, dest=es, text=!change, pronunciation=!change, extra_data="{'translat...")
order completed!
language None```
#

I see now

slate swan
vestal owl
#

lmao

dapper cobalt
# slate swan

Yep, the loop starts before the bot does. Which means, the bot's cache has not loaded yet.

#

Start the loop inside the on_ready event.

slate swan
#

alright

dapper cobalt
#

Or under await bot.wait_until_ready().

slate swan
#

@bot.event
async def on_ready():
    await bot.change_presence(status=discord.Status.idle, activity=discord.Game(f"with {len(bot.guilds)} servers | ^help"), afk=True)
    print("Bot running with:")
    async def input_echo():
        print("Username: ", bot.user.name)
        print("User ID: ", bot.user.id)

        channel_entry = 862766760741699615

        channel = bot.get_channel(channel_entry)
        x = input()
        await channel.send(x)
        pass
    bot.loop.create_task(input_echo())
``` i doubt this is proper lmao
slow cove
#

What have i done wrong here, from everything i can see it should be fine but obviously im missing something

autumn bone
#

Hello, i have an error :

AttributeError: 'NoneType' object has no attribute 'get_channel'

My code :
initFunction.py :

async def editChannel(discordGuildID, discordChannelID, dataNotif):
    guild = bot.get_guild(discordGuildID)
    getChannel = guild.get_channel(discordChannelID)

    await getChannel.edit(name=f"{dataNotif}")

main.py :

await editChannel(discordGuildID,discordChannelID,dataNotif)
dapper cobalt
slate swan
#

ohh

#

okay

#
async def input_echo():
    print("Username: ", bot.user.name)
    print("User ID: ", bot.user.id)
    channel_entry = 862766760741699615

    channel = bot.get_channel(channel_entry)
    x = input()
    await channel.send(x)
    pass

@bot.event
async def on_ready():
    await bot.change_presence(status=discord.Status.idle, activity=discord.Game(f"with {len(bot.guilds)} servers | ^help"), afk=True)
    print("Bot running with:")
    bot.loop.create_task(input_echo())
#

like this?

pale zenith
autumn bone
#

No ^^

#

I only use Python since multiple year now.

slate swan
#

Bot is not ready yet

autumn bone
#

And my mistake, it worked very well until a few weeks ago.

dapper cobalt
autumn bone
slate swan
#

does anyone know how i can limit the amount of times a command can raise CommandOnCooldown

dapper cobalt
wicked atlas
dapper cobalt
unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
slate swan
dapper cobalt
#

Is it the same issue?

slate swan
#

ye

dapper cobalt
#

Can I see the error again?

slate swan
#
e
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<input_echo() done, defined at D:\This PC (Pre 07-31-2021)\desktop\vaclav\Vaclav\bot.py:89> exception=AttributeError("'NoneType' object has no attribute 'send'")>
Traceback (most recent call last):
  File "D:\This PC (Pre 07-31-2021)\desktop\vaclav\Vaclav\bot.py", line 94, in input_echo
    await channel.send(x)
AttributeError: 'NoneType' object has no attribute 'send'
Bot running with:
Username:  Atheon
User ID:  890318171817537577```
slate swan
# dapper cobalt !d discord.ext.commands.cooldown

i know how to put a cooldown what im asking is how would i limit the amount of times a command will respond i.e. command is on cooldown retry after 69 seconds because the user could just spam this and it will send a cooldown message for every time the user sends the command

dapper cobalt
unkempt canyonBOT
#

exception discord.ext.commands.CommandOnCooldown(cooldown, retry_after, type)```
Exception raised when the command being invoked is on cooldown.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
slate swan
slim whale
#
await canal.set_permissions(ctx.guild.default_role, send_messages=True)```how i can use this to change cooldown?
slate swan
#

canal?

#

how to get the current time for UTC + 2

       testembed.set_footer(
            text=f"๐Ÿ’ฌ โ€ข {ctx.author} -  {time}"
#

never heard that one before

slim whale
#

i defined it before

#

canal = ctx.message.channel

slate swan
#

ah

slim whale
#

someone knows?????

slate swan
dapper cobalt
#

!d discord.Embed.timestamp

unkempt canyonBOT
#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

slate swan
dapper cobalt
slate swan
dapper cobalt
dapper cobalt
unkempt canyonBOT
slate swan
dapper cobalt
reef shell
#

why

dapper cobalt
#

testembed.timestamp = datetime.datetime.now()

reef shell
#

^

brave flint
#

did muting/deafening someone with cmds is possible?

dapper cobalt
#

That's for the date, and the footer is just the emoji and ctx.author.

slim whale
dapper cobalt
brave flint
#

but idk if it work

dapper cobalt
#

I think you can toggle the member's VoiceState.mute to True.

#

!d discord.VoiceState.mute

unkempt canyonBOT
brave flint
#

oops

dapper cobalt
#

Something like

ctx.VoiceStatue.mute = True
#

I'm completely unsure and I doubt that this is correct.

brave flint
slate swan
dawn wasp
#

Hi guys , I have a bot hosted with replit and it logs when a message is deleted or edited ... ., but when I restart it ,
it cannot log changes for messages that were sent before the restart

harsh cradle
#
    @commands.command()
    @commands.has_role('- Hi Owners')
    async def givelevel(self, ctx: commands.Context, member: discord.Member=None, *, lvl:int):
        if member == None:
            return
        if ctx.guild == None:
            return
        result = await self.find_or_insert_user(member)

        user_id, guild_id, xp, level = result
        print(xp, level)

        level = lvl
        
        cursor = await self.db.cursor()
        await cursor.execute('Update users set xp=?, level=? where user_id=? and guild_id=?', (xp, level, user_id, guild_id))
        await self.db.commit()
        await ctx.send(f"{member.mention} level changed to {lvl}")
``` i have givelevel it works fine on users but when i try to give my self level it says its changed but its not
dawn wasp
dapper cobalt
dapper cobalt
slate swan
#

!d sqlite3

unkempt canyonBOT
#

Source code: Lib/sqlite3/

SQLite is a C library that provides a lightweight disk-based database that doesnโ€™t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. Itโ€™s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.

The sqlite3 module was written by Gerhard Hรคring. It provides a SQL interface compliant with the DB-API 2.0 specification described by PEP 249, and requires SQLite 3.7.15 or newer.

slate swan
#

@dawn wasp ^

#

if im not mistaken

reef shell
#

postgresql is better

#

i guessthrinking

dapper cobalt
#

!d pymongo though.

unkempt canyonBOT
boreal ravine
#

Whats the difference between mongodb and pymongo

slate swan
#

is it possible to have an event that runs whenever someone adds an emoji to a message, and get me the message ID AND the user ID AND the emoji added? is there something similar for when someone removes and emoji? My goal is giving a user a role whenevr they react with a specific emoji'

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesnโ€™t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itโ€™s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
slate swan
#

ooo i see

dapper cobalt
boreal ravine
slate swan
#

Ty

boreal ravine
#

!d discord.on_reaction_remove

unkempt canyonBOT
#

discord.on_reaction_remove(reaction, user)```
Called when a message has a reaction removed from it. Similar to on\_message\_edit, if the message is not found in the internal message cache, then this event will not be called.

Note

To get the message being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

Consider using [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") if you need this and do not want to enable the members intent.
dapper cobalt
#

Try printing channel.

slate swan
#

wdym

slate swan
#

yes the channel exists

boreal ravine
#

it says nonetype

slate swan
#

ill try and copy the channel id again ig

wraith bay
#

I need help
One category help?

boreal ravine
slate swan
#

do print(channel)?

boreal ravine
slate swan
#

before or after the input statement

boreal ravine
slate swan
boreal ravine
slate swan
#

nothing printed

#

ยฏ_(ใƒ„)_/ยฏ

pale zenith
unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the memberโ€™s data.

Depending on the parameter passed, this requires different permissions listed below...
pale zenith
#

mute/deafen kwargs @brave flint
note that they must be connected to a voice channel or you will get discord.errors.HTTPException: 400 Bad Request (error code: 40032): Target user is not connected to voice.

boreal ravine
#

show code

slate swan
#

the print(channel) is above the x definitive

boreal ravine
#

hm

dawn wasp
brave flint
pale zenith
#

np

slow cove
#

Currently running into something strange. have the following code and I can get the bot to generate the button (practicing with buttons)

#

but then my interaction fails, any clues?

slate swan
#

delete system 32

slow cove
#

Ah yes! perfect

#

let me do that qui----

pale zenith
#

discord.py has them already in v2.0, which you install from github

#

of course its all up to you though. ๐Ÿ˜„ - hope you get someone here that knows discord-components, all i know is the official way with Views

slow cove
#

Yeah I tried importing the discord.py v2.0 just seemed to break everything hahaha

slate swan
#
async def input_echo():
    channel_entry = 862766760741699615

    channel = bot.get_channel(channel_entry)
    x = input()
    await channel.send(x)
``` how can i make it so that every input i make into the console gets sent to this channel? currently it only works once per startup
pale zenith
slate swan
pale zenith
#

they have (both) a discord server - see channel topic

slow cove
#

Im still getting used python so changing my libraries might be tossing myself right back into the tumble dryer

broken igloo
#

How would you send success/error messages.

  1. Create exceptions CommandSuccess and CommandFailure and catch them in on_command_error event.
  2. Create utility functions success_embed and error_embed and write return await ctx.send(embed=success_embed(โ€œmessage text")

Custom context class isnโ€™t a good solution for me.

pale zenith
#

ah, makes sense. well good luck with discord-components OwO_Script

slate swan
slow cove
#

If i can get this part to work might see how to convert what ive done into V2

slate swan
#

is there anyway to kinda put a cooldown on a on cooldown error???? to prevent this from happening

slow cove
#

especially if a lot of the commands are already in the library ๐Ÿ˜„

slate swan
#

!d asyncio.sleep

unkempt canyonBOT
#

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

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

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

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

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

Example of coroutine displaying the current date every second for 5 seconds:
boreal ravine
slate swan
#

i knoww

slate swan
slow cove
#

maybe thats why V2 is better hahahaha

slate swan
#

i dont think its local tho,i think it affects all users from using that command while its in CD

#

could be wrong but

#

ยฏ_(ใƒ„)_/ยฏ

#

anyone have any projects i can collaborate on, i'm bored as hell

slate swan
slate swan
#

just for the bit that sends the cooldown message is all i need

#
@client.listen()
async def on_command_error(ctx: Context, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send("this command is on cooldown, retry after {} seconds.".format(round(error.retry_after, ndigits=2)))
slow cove
#

could you put all those imports in a dictionary to then collapse it to make the code a bit neater?

slate swan
#
async def on_command_error(ctx: Context, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send("this command is on cooldown, retry after {} seconds.".format(round(error.retry_after, ndigits=2)))
        asyncio.sleep({}.format(round(error.retry_after))```
#

try that, lmk if it works

#

ok

slate swan
#

thats very weird

slow cove
#

wondering if you put them in a dictionary if it would interfere with the commands accessing them

slate swan
#

lemme look at mine and see if i can compare

slender river
slate swan
#

oh

#

what did you expect its just sleeping

#

i see what i did wrong lmao

#
@client.listen()
async def on_command_error(ctx: Context, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send("this command is on cooldown, retry after {} seconds.".format(round(error.retry_after, ndigits=2)))
        await asyncio.sleep({}.format(round(error.retry_after))```
#

try that

#

there is no differece

#

yes there is

boreal ravine
#

there isnt

slate swan
#

ive added 'await' to the final line

#

and i fixed it you were missing '' with the {} and a ending )

boreal ravine
#

hm

slate swan
#

ok

slate swan
slate swan
#

it does nothing

slate swan
boreal ravine
slate swan
fallow mauve
#

why no work?

autumn bone
#

I have a problem, when I put some functions outside my main.py file and put in initFunction.py, it doesn't work anymore, it doesn't find information like guild name, etc...
I use async def.

initFunction.py :

from discord.ext import commands,tasks
import discord
import requests
from xml.dom import minidom
import time
from os.path import exists
from asyncio import sleep


intents = discord.Intents()
intents.members = True
bot = commands.Bot(command_prefix='!', intents =intents)

async def editchannel(discordGuildID):
    print(type(discordGuildID))
    discordGuildID = int(discordGuildID)
    print(type(discordGuildID))
    print(discordGuildID)
    guild = bot.get_guild(817398581005647872)
    print(guild)

main.py :

[...]

await editchannel('9595959')

Any solution ?

#

This worked very well until a fortnight ago.

dawn wasp
slate swan
#

im not the right person to ask

stiff nexus
#

help??```py
@commands.Cog.listener()
async def on_message(self,message):

  msg=message.jump_url.split('/')
  chann=self.bot.get_channel(msg[-2])
  mess=await chann.fetch_message(msg[-1])
  await message.channel.send(mess.content)
  await message.channel.send(mess.author)
dawn wasp
hasty iron
reef shell
slate swan
hasty iron
#

you use raw events when an object isnโ€™t cached or youโ€™re not sure

reef shell
#

so message caching is the reason behind it thinkingpensive

royal zenith
#

how tf do i fix this shit

hasty iron
#

so many imports that you probably dont use

royal zenith
#

it worked b4

#

and i do use most of them

fallow mauve
#

so i moved my commands to separate files within the repl so i could categorize them, and now they wont work

#

why?

reef shell
#

did you use cogs for that?

#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
reef shell
#

check this out if you haven't yet

royal zenith
#

can anyone help me pls

slate swan
#

I am using on_reaction_add put when i try to print reaction, Reaction.message, user nothing happens

#

any clues?

#
@client.event
async def on_reaction_add(user, reaction):
    print(user)
    print(Reaction.message)
    print(reaction)```
brazen raft
#

First of all, it should be a lowercase r. Secondly, are you sure that's the right order of parameters? Thirdly, this works only for new messages being reacted, I think.

slate swan
#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

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

Note

This doesnโ€™t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itโ€™s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
slate swan
#

it says Reaction.messsage whit a higher case "R"

#
@client.command()
async def ban(ctx):
	await ctx.message.delete()
	if ctx.message.author.id==488004314334494722:
	    user=client.get_user(883626833545920542)
	    await ctx.guild.ban(user, delete_message_days=0, reason="OwO bot scamming do not unban")
	    await ctx.channel.send("Done", delete_after=3.0)```

error:```
AttributeError: Nonetype object has no attribute id```
#

anyways

#

its not doing anything at all

royal zenith
#

anyone how how 2 fix this?

reef shell
slate swan
brazen raft
#

@slate swan, the order of parameters is wrong. And no, it's not 'Reaction.message', they expect you to replace the word "Reaction" with your parameter's name.

reef shell
royal zenith
slate swan
reef shell
royal zenith
#

hm lemme try dat

reef shell
#

try it out

brazen raft
#

You forgot to put another backslash after C

royal zenith
#

ah shit

slate swan
#

it's still doing nothing

royal zenith
#

it workedddddddddd

royal zenith
slate swan
#
@client.event
async def on_reaction_add(reaction, user):
    print(user)
    print(reaction.message)
    print(reaction)```
brazen raft
#

@royal zenith Two things:
How is this discord-bots related?
And can you please tell me about your project in my DMs? It looks really interesting.

brazen raft
#

Try to react to a newly created message.

slate swan
#

okie

brazen raft
#

After the bot starts, I mean.

slate swan
#

yea ofc

reef shell
reef shell
#

then use on_raw_reaction_add

slate swan
#

ohhhh ok

brazen raft
#

For that you'd have to use what Sherlock here said

reef shell
#

!d discord.on_raw_reaction_add

unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

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

i see

reef shell
#

this takes only the payload as a parameter

fallow mauve
slate swan
#

how do get the data from it?

reef shell
unkempt canyonBOT
#

class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
reef shell
#

the payload is an instance of discord.RawReactionActionEvent

brazen raft
#

It has the reaction, the user, and guild & channel IDs I think

slate swan
#

so payload.reaction and so on?

brazen raft
#

Oh there you go

slate swan
#

Hi, I can't seem to get it to give a role when someone puts in their bio, .gg/***
Can you help me?

#

aight ty guys

brazen raft
#

Funny enough I think member and member_id are invalid for add events.

fallow mauve
slate swan
#

also.... is there any ways i can return the emoji as :emoji:

#

instead of ASCII or whatever?

fallow mauve
slate swan
fallow mauve
#

also i have imported cogs

reef shell
# fallow mauve

that seems fine, but i would recommend you to use bot instead of Bot as the variable name

reef shell
#

it's the standard naming convention for variables ig

reef shell
fallow mauve
reef shell
#

!d discord.ext.commands.Bot.load_extension

unkempt canyonBOT
#

load_extension(name, *, package=None)```
Loads an extension.

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

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

you need to load the extension

#

to use the cog

fallow mauve
reef shell
#

what's the issue now

fallow mauve
#

what do you mean

wise tulip
reef shell
#

except that annoying variable name 'Bot'

fallow mauve
#

lmao

reef shell
#

send the traceback

fallow mauve
#

like the error?

reef shell
#

yes

fallow mauve
#

thats all it says

reef shell
#

are you sure a command named rps is defined?

slate swan
#

its a common error ive had that sometimes

reef shell
#

yep

slate swan
#

check your indention in the cog

fallow mauve
slate swan
#

if its. cog

#

hmm

#

try @bot

#

not @Bot

reef shell
#

you need to use @commands.command() decorator inside cogs

#

not @bot.command()

fallow mauve
#

lol

#

nicknames

#

they annoying

reef shell
#

also your indentations are wrong

#

you need to define commands inside the subclassed commands.Cogs class

wise tulip
reef shell
#

I'm pretty sure these are not inside that class

fallow mauve
#

how do i put them in the class

reef shell
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

reef shell
#

and when you define any functions inside a class , you need to pass self as the first parameter

fallow mauve
#

ok i indented things and it says my variable notchoice is not defined

reef shell
#

can you paste the code ?

#

instead of sending ss

boreal ravine
reef shell
#

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

fallow mauve
#

ill try

unkempt canyonBOT
#

Hey @fallow mauve!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

fallow mauve
#

-_-

reef shell
fallow mauve
#

wait

#

had to fix smth

reef shell
#

first of all , remove that line 119

fallow mauve
#

how

reef shell
#

seems like you are not familiar with OOP

#

consider learning that first

fallow mauve
#

oop?

#

i dont want to learn something completely new

reef shell
#

object oriented programming

harsh cradle
#
    @commands.command()
    @commands.has_role('- Hi Owners')
    async def givelevel(self, ctx: commands.Context, member: discord.Member=None, *, lvl:int):
        if member == None:
            return
        if ctx.guild == None:
            return
        result = await self.find_or_insert_user(member)

        user_id, guild_id, xp, level = result
        print(xp, level)

        level = lvl
        
        cursor = await self.db.cursor()
        await cursor.execute('Update users set xp=?, level=? where user_id=? and guild_id=?', (xp, level, user_id, guild_id))
        await self.db.commit()
        await ctx.send(f"{member.mention} level changed to {lvl}")
``` i have the givelevel command and its working fine but when i try to give level to my self is says it changed but its not can someone tell me what the problem
fallow mauve
#

how about i just dont categorize them until i know more about cogs?

slate swan
#

it's a good thing to learn everything with starting new projects

boreal ravine
slate swan
#

cogs are just inherited classes

boreal ravine
#

^

reef shell
#

Corey Schafer's OOP tutorials are good for beginners

boreal ravine
#

^

reef shell
#

you can try following those

slate swan
#

even other languages that are oop based would help

#

Java, C#

#

but like... you don't learn another language to program in python

#

๐Ÿ‘ถ python

wheat moth
#

Hey, is it possible to send this msg and if some_arg == true don't delete it at all?

msg = await ctx.send(embed=embed,delete_after=5)
if some_arg == True:
  await msg.edit(embed=embed, delete_after=None)
reef shell
#

what?

boreal ravine
#

i think he means he wants to delete a msg if there was no input/args

wheat moth
#

Main purpose is that I send my embed which says like loading... and later after computing which takes a few sec fill all the values in by editing it.
Problem with that is when there occurs an error you see on the chat embed with loading... and error message which I don't want. I would like to delete this embed if there's an error. That's why I try to use delete_after and after computing if there is no error just cancel delete_after.

slate swan
#

don't use delete_after

#

just use try-except and use msg.delete() in except

wheat moth
#

well, I can't because I user error handler

#

so i need to access msg from error handler

slate swan
#

no

#

try-except overwrites the error handler

valid niche
harsh cradle
#

hi can i have help

slate swan
#

don't ask to ask

valid niche
slate swan
#

ofc you can

harsh cradle
# slate swan ofc you can
    @commands.command()
    @commands.has_role('- Hi Owners')
    async def givelevel(self, ctx: commands.Context, member: discord.Member=None, *, lvl:int):
        if member == None:
            return
        if ctx.guild == None:
            return
        result = await self.find_or_insert_user(member)

        user_id, guild_id, xp, level = result
        print(xp, level)

        level = lvl
        
        cursor = await self.db.cursor()
        await cursor.execute('Update users set xp=?, level=? where user_id=? and guild_id=?', (xp, level, user_id, guild_id))
        await self.db.commit()
        await ctx.send(f"{member.mention} level changed to {lvl}")
``` my give level command is working fine but when i try use it ony my self is not work it says level changed but its not but is work on users
slate swan
#

oh

#

hm

wheat moth
#

@valid niche this could possibly work

slate swan
#

what did you type in dc?

harsh cradle
slate swan
#

how did you invoke the command

harsh cradle
#

i type !givelevel @harsh cradle 60 @slate swan

#

selfmention is not work with me i dont know why

slate swan
#

seems like you fetched level or something

#

don't you have to dump it back or smth

valid niche
#

like that's super counter productive

#

just remove that if member == None and that default value for member

harsh cradle
slate swan
#

author

harsh cradle
#

author

valid niche
harsh cradle
slate swan
#

oh me dumb

valid niche
#

also it's not what i said to do

harsh cradle
valid niche
#

i literally typed part of your code

#

please read what i typed

ripe jackal
#

Hello, I am trying to create a fun IQ command. The thing is I want to add current time that fetches the user's region and tells him his time rn. This is the code rn, but don't want to use datetime.datetime.utcnow(), here it is:python @client.command() async def iq(ctx): a=random.randint(0,200) time = datetime.datetime.utcnow() embed=discord.Embed(title=f":brain:{ctx.author}'s IQ", description=f"**Your IQ is: `{a}`**",color=0xfc0000) embed.set_footer(text = f"Icy Bot's IQ Test โ€ข {time}") embed.set_thumbnail(url="https://media.giphy.com/media/l44QzsOLXxcrigdgI/giphy.gif") await ctx.send(embed=embed) And I want the footer to look like that:

harsh cradle
valid niche
#

that's the default value

slate swan
#

hey, how can I check if a user has a certain role using the role's id?

#

what's self.find_or_insert_user(member)

harsh cradle
#

sry for being stupid

valid niche
#

i said remove the default value

harsh cradle
#

still the same

valid niche
#

show your new code

harsh cradle
# valid niche show your new code
    @commands.command()
    @commands.has_role('- Hi Owners')
    async def givelevel(self, ctx: commands.Context, member: discord.Member, *, lvl:int):
        if ctx.guild == None:
            return
        result = await self.find_or_insert_user(member)

        user_id, guild_id, xp, level = result
        print(xp, level)

        level = lvl
        
        cursor = await self.db.cursor()
        await cursor.execute('Update users set xp=?, level=? where user_id=? and guild_id=?', (xp, level, user_id, guild_id))
        await self.db.commit()
        await ctx.send(f"{member.mention} level changed to {lvl}")
slate swan
slate swan
slate swan
slate swan
#

the client doesnt seem its able to

#

role = guild.get_role(role_id)

harsh cradle
slate swan
#

ty

#

you're welcome

valid niche
slate swan
#

also I'm playing so I might afk between messages

harsh cradle
# slate swan can I see the definition?
        result = await self.find_or_insert_user(member)

        user_id, guild_id, xp, level = result
        print(xp, level)

        level = lvl
        
        cursor = await self.db.cursor()
        await cursor.execute('Update users set xp=?, level=? where user_id=? and guild_id=?', (xp, level, user_id, guild_id))
        await self.db.commit()
valid niche
#

answer that question

harsh cradle
#

its search member in database

slate swan
#

How to get user from id??

harsh cradle
#

and replace new level

#

and commit

valid niche
harsh cradle
#

i didnt get you

slate swan
#

where the def find_or_insert_user is

harsh cradle
slate swan
#
def find_or_insert_user(self, member_place):
    #much code
valid niche
#

since they awaited it

harsh cradle
#

@valid niche @slate swan i dont have def

slate swan
#

oh actually

harsh cradle
#

i use self

valid niche
slate swan
#

you made the function

#

inside of the cog

valid niche
#

python doesn't posses telepatic powers and knows what you want magically

#

your pc is a dumb rock that needs explicit instructions

#

so you wrote those instructions somewhere

harsh cradle
#

@valid niche so how to slove my problem

valid niche
#

answer our question

#

how is find_or_insert_member defined

slate swan
#

maybe something doesn't match in the database with the other people's stuff

valid niche
#

what is the code of that function

slate swan
#

as I see, it doesn't really matter

#

the only thing that matters is result

harsh cradle
# valid niche how is find_or_insert_member defined
    @commands.command()
    @commands.has_role('- Hi Owners')
    async def givelevel(self, ctx: commands.Context, member: discord.Member, *, lvl:int):
        if ctx.guild == None:
            return
        result = await self.find_or_insert_user(member)

        user_id, guild_id, xp, level = result
        print(xp, level)

        level = lvl
        
        cursor = await self.db.cursor()
        await cursor.execute('Update users set xp=?, level=? where user_id=? and guild_id=?', (xp, level, user_id, guild_id))
        await self.db.commit()
        await ctx.send(f"{member.mention} level changed to {lvl}")
``` There is no Def i USE self i dont know what you mean
slate swan
#

doesn't matter

#

put print(result) after getting the result

#

maybe something is different

harsh cradle
slate swan
#

p u t

#

make it be there

valid niche
harsh cradle
valid niche
#

so you have somewhere in your code

async def find_or_insert_user(self, member):
  # code
slate swan
#

now use the command

valid niche
#

show us that whole bit

slate swan
#

on you and on somebody else

#

and we'll either solve your problem or we won't be able to

harsh cradle
#

when i use it on my self

#

and still

#

not wwrok

slate swan
#

and when on somebody else?

harsh cradle
#

work

slate swan
#

what does it print

harsh cradle
#

nothing happen

#

thats my problem

slate swan
#

what's ur language

harsh cradle
sonic lark
#
    header = {"authorization": token}
    req = requests.post('https://discordapp.com/api/v9/users/@me/channels', headers=header, json={'receipients': user})
    req = json.loads(req.text)

hey can someone help me out i'm trying to make a self bot that creates a dm with someone else via requests but it only makes a solo group chat

slate swan
#

oh okay

unkempt canyonBOT
#

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

slate swan
#

well I really don't know

#

if it works on somebody else

valid niche
#

self bots are strictly forbidden by discord

fallow mauve
#

self bots?