#discord-bots

1 messages ยท Page 496 of 1

maiden fable
#

these are my inports for the http part

#

sorry, didn't notice that

drifting arrow
#

All g hombre

#

๐ŸŽฉ

slate swan
#

big oof

drifting arrow
dusk pumice
#

Guys. I got to go now. see you later!

#

Bye

drifting arrow
#

Cya @dusk pumice

dusk pumice
#

Cya

maiden fable
dusk pumice
#

Cya

maiden fable
#

IQ 100 :stare:

slate swan
#

lol

maiden fable
maiden fable
slate swan
#

googol translate

maiden fable
slate swan
#

but whats wrong there

maiden fable
#

see the BASE_URL

slate swan
#

did you need self there

#

nvm

#

BASE_URL = BASE_URL

#

whats wrong with that

#

drakeyeah

maiden fable
#

๐Ÿคฃ dude

slate swan
#

no i literally have no idea

maiden fable
#

your nickname suits u @slate swan

slate swan
#

ikr

#

i kept this when i joined the server

#

since i know who i am

lament mesa
#

it doesnt need self

slate swan
#

yeah i was thinking of __init__

boreal ravine
#

Is it possible to send videos inside of embeds

maiden fable
#

Sure, ig

#

Just like u do GIFs?

#

idk

slate swan
#

I think set_image can do that

#

!e discord.Embed.set_image

unkempt canyonBOT
#

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

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

oh

#

rip lol

#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

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

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
boreal ravine
#

can we set videos tho

maiden fable
#

U can try

boreal ravine
#

ok brb

maiden fable
#

What else to add to my AI Bot

slate swan
#

nothing

#

๐Ÿ‘

boreal ravine
slate swan
#

๐Ÿ‘

maiden fable
slate swan
#

voice commands?

#

unless you make a fork with voice receiving

maiden fable
#

Yea

#

I was thinking of adding vc commands but no voice receive till now

slate swan
steep estuary
#

how to check if a user is mentioned

velvet mason
#

How can I block all another links without allowed? I tried but with no result

maiden fable
maiden fable
unkempt canyonBOT
slate swan
#

yep

steep estuary
#
if discord.Member.mentioned_in(message):
                (stuff)

??

#

@maiden fable

slate swan
#

bro

#

I'm getting this error now

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\user\OneDrive\Desktop\Profanity Blocker\main.py", line 924, in on_message
    embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) != 0})
  File "c:\Users\user\OneDrive\Desktop\Profanity Blocker\main.py", line 924, in <dictcomp>
    embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) != 0})
TypeError: 'Message' object is not callable```
steep estuary
#

then?

slate swan
#

how many times do we have to say

#

replace discord.Member with an instance

#

of discord.Member

maiden fable
#

why do u have that???

valid niche
#

ah yes calling a message instance

steep estuary
#

ctx.author.mentioned_in(message.content) ??

#

;-;

slate swan
valid niche
maiden fable
valid niche
#

word: message(word)

steep estuary
slate swan
#

value = {word: message(word) for word in test2}

slate swan
#

makes no sense to me already

steep estuary
#

message.author.mentioned_in(message.content) ??

valid niche
#

you're making the variable word, which you're typehinting to a call of a message instance with the argument word

slate swan
valid niche
#

it's just the biggest mess ever

slate swan
steep estuary
#

k

slate swan
#

but that only works if

#

you ping yourself

steep estuary
#

yes i want to use it in if

slate swan
#

@slate swan

slate swan
valid niche
slate swan
#

Oh

mint chasm
#

been sent here from a help channel, want to build a similar function to the help system on here just scaled to a couple of channels, how would i do thart

steep estuary
#

it will work?

slate swan
#

yes

steep estuary
#

k :)

#

ty

slate swan
supple plume
#

how can i make it so only admins can see a channel?

slate swan
#

if I do @slate swan it works

slate swan
supple plume
#

no

boreal ravine
#

What does ```py
Command raised an exception: HTTPException: 413 Payload Too Large (error code: 40005): Request entity too large

slate swan
#

in discord

supple plume
#

bro

#

wtf

#

i mean in dpy

#

lmfaooo

slate swan
#

get the role and set a channel's permissions for that role

#

!d discord.TextChannel.set_permissions

unkempt canyonBOT
#

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

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

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

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

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

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

instead of message.author

valid niche
# slate swan So how should I fix it?

so what you're doing here is making a dictionary with a key word and an invalid value of message(word), which is invalid because message is an instance of discord.Message and not a fuction, for every word in the variable test to if the regex_match_true finds anything in message.content

steep estuary
slate swan
#

then good job I guess?

slate swan
#

it will only work with the person that you put instead of message.author

valid niche
#

this is what @unkempt canyon does

valid niche
slate swan
#

Oh okay

mint chasm
boreal ravine
#

How do i check if someones a bot or not

slate swan
unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
slate swan
#

or discord.User.bot

boreal ravine
#

thanks

hollow mortar
#

hello

#

i want ask a question

#

i want to make an like upgrade for my bot

#

i want to do like this !id @hollow mortar and i want it to give me my id anyone know how i can make it ?

#

it take the mention and give me the id of that guy

#

and send me the id in chat

slate swan
unkempt canyonBOT
#

property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
steep estuary
#

how to fix this ?

cloud dawn
#

What is mention_everyone?

steep estuary
#

idk

#

i never used it

cloud dawn
#

How did you come up with it?

steep estuary
#

i made a afk command

#

it is working fine

#

but the problem is if someone ping a afk member

#

bot is not telling him that he is afk

#

:/

slate swan
#

what's a cd

cloud dawn
slate swan
maiden fable
#

if u mean the one in a command prompt

cloud dawn
#

compact disk

maiden fable
#

:stare: Stop

slate swan
maiden fable
#

@cloud dawn can u stop trolling please?

valid niche
maiden fable
#

:stare: I mean, a person won't ask what is a CD in discord bots channel lol

cloud dawn
last moss
#

Hey what happened to discord.py? I heard it was going down

slate swan
#

read the pins

maiden fable
last moss
#

lol everything seems to be working for me

maiden fable
#

I know

#

It will work for some time

#

till a breaking change comes

last moss
#

"breaking change"

#

?

maiden fable
#

like member.avatar.url instead of member.avatar_url

last moss
#

What are you talking about

maiden fable
#

that is a breaking change in 2.0

valid perch
#

It'll work fine till discord api changes

maiden fable
#

u cannot do member.avatar_url in dpy 2.0

#

u have to do member.avatar.url

This is an example of breaking change

last moss
#

ive been using member.avatar_url

#

and its working fine on my running bot

maiden fable
#

Cz u never updated to 2.0

#

it is only on github

last moss
#

My whole computer science project is on this module lmao

valid perch
#

What he's tryna say is dpy is perfectly fine until discord changes

last moss
#

i might be fucked

valid perch
#

Or until something changes discord side

maiden fable
#

Yea

valid perch
#

Despite him not saying that haha

last moss
#

lol

maiden fable
last moss
#

That makes sense

maiden fable
last moss
#

not very specific

#

What exactly are forks?

#

like forks in github?

maiden fable
#

Yea

valid perch
maiden fable
#

Oh, I thought member.avatar.url was a discord change pithink

hollow mortar
#

hey i have question
if i do this does it work

#
await ticket_channel.set_permissions(payload.member, read_messages=True, send_messages=True)```
#

i replace payload.member with the id of that member

#

does it give him the perms ?

cloud dawn
valid niche
#

!d discord.abc.GuildChannel.set_permissions

unkempt canyonBOT
#

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

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

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

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

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

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

this is how you set permissions

hollow mortar
#

what he mean with member ? member id ?

torn wagon
#

hello, so my bot needs to run .addaccess to add a user to the ticket, but the coding is trying to add a role instead.

valid perch
valid niche
hollow mortar
#

so the thing i said wont work right ?

hollow mortar
#

wont work if i replace the payload.member with the id of the member

#

but it will work if i do this right ?

#
memmber = "member id "
await ticket_channel.set_permissions(memmber.member, read_messages=True, send_messages=True)
#

does this work ?

torn wagon
#

when user runs command .new it creates a ticket,

#

and adds the user that entered command to ticket

valid niche
#

read the documentation

torn wagon
#

but as soon as i run my .addaccess (userid) command

#

it says "invalid role" which shows its attempting to add roles instead of users

hollow mortar
valid niche
#

!d discord.abc.GuildChannel.set_permissions

unkempt canyonBOT
#

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

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

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

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

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

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

whai not working

valid niche
torn wagon
valid niche
cloud dawn
hollow mortar
slate swan
#

?

#

๐Ÿ˜ฉ Plis tell me

valid niche
valid niche
valid niche
#

what i said is if you want to import a folder the folder needs to contain a valid __init__.py

slate swan
#

__init .py contain

torn wagon
#
@client.command()
async def addaccess(ctx, role_id=None):

    with open('data.json') as f:
        data = json.load(f)
    
    valid_user = False

    for role_id in data["verified-roles"]:
        try:
            if ctx.guild.get_role(role_id) in ctx.author.roles:
                valid_user = True
        except:
            pass
    
    if valid_user or ctx.author.guild_permissions.administrator:
        role_id = int(role_id)

        if role_id not in data["valid-roles"]:

            try:
                role = ctx.guild.get_role(role_id)

                with open("data.json") as f:
                    data = json.load(f)

                data["valid-roles"].append(role_id)

                with open('data.json', 'w') as f:
                    json.dump(data, f)
                
                em = discord.Embed(title="Jayys", description="You have successfully added `{}` to the list of roles with access to tickets.".format(role.name), color=000000)

                await ctx.send(embed=em)

            except:
                em = discord.Embed(title="Jayys Tickets", description="That isn't a valid role ID. Please try again with a valid role ID.")
                await ctx.send(embed=em)
        
        else:
            em = discord.Embed(title="Jayys Tickets", description="That role already has access to tickets!", color=000000)
            await ctx.send(embed=em)
    
    else:
        em = discord.Embed(title="Jayys Tickets", description="Sorry, you don't have permission to run that command.", color=000000)
        await ctx.send(embed=em)
cloud dawn
slate swan
#

ohk

torn wagon
#

is the current code thats adding roles, i need it changed to adding users.

valid niche
#

but it makes a folder a valid library

#

you can either import a file which just works

#

if you import a folder containing multiple .py files, and you want to import that folder, python needs to know what to import and how, so you need a valid __init__.py to tell it how and what to import

slate swan
#

@valid niche can u tell me more

outer violet
torn wagon
#

@valid niche

hasty iron
torn wagon
#

do u know anything abt changing this code to add users instead of role?

#
@client.command()
async def addaccess(ctx, role_id=None):

    with open('data.json') as f:
        data = json.load(f)
    
    valid_user = False

    for role_id in data["verified-roles"]:
        try:
            if ctx.guild.get_role(role_id) in ctx.author.roles:
                valid_user = True
        except:
            pass
    
    if valid_user or ctx.author.guild_permissions.administrator:
        role_id = int(role_id)

        if role_id not in data["valid-roles"]:

            try:
                role = ctx.guild.get_role(role_id)

                with open("data.json") as f:
                    data = json.load(f)

                data["valid-roles"].append(role_id)

                with open('data.json', 'w') as f:
                    json.dump(data, f)
                
                em = discord.Embed(title="Jayys", description="You have successfully added `{}` to the list of roles with access to tickets.".format(role.name), color=000000)

                await ctx.send(embed=em)

            except:
                em = discord.Embed(title="Jayys Tickets", description="That isn't a valid role ID. Please try again with a valid role ID.")
                await ctx.send(embed=em)
        
        else:
            em = discord.Embed(title="Jayys Tickets", description="That role already has access to tickets!", color=000000)
            await ctx.send(embed=em)
    
    else:
        em = discord.Embed(title="Jayys Tickets", description="Sorry, you don't have permission to run that command.", color=000000)
        await ctx.send(embed=em)
slate swan
#

@valid niche

#

@hasty iron @cloud dawn

valid niche
#

it's not in the right location

#

and i have a feeling it isn't structured well either

hollow mortar
#

hey i need help here any one know how i can get channel id

slate swan
valid niche
slate swan
cloud dawn
#

doesn't mean you can just put it in 1 folder and expect it to work.

valid niche
#

an empty __init__.py doesn't do anything, you need to do things

hasty iron
valid niche
hasty iron
#

if you wrote that code and you cant even edit it that means its just copied

hollow mortar
#

i want my bot to get me the id of the channel that the msg sent on

hasty iron
hollow mortar
#

wont work i tried it

slate swan
hollow mortar
valid niche
slate swan
#

yes

hollow mortar
#

thanks

valid niche
slate swan
hasty iron
slate swan
#

src:

@bot.command()
async def afk(ctx, reason="No reason provided"):
  if "@" in reason:
    return await ctx.send("Please don't include mentions in your AFK reason.")
  with open("afk.json", "r") as f:
    load = json.load(f)
  load[str(ctx.author.id)] = reason
  with open("afk.json", "w") as f:
    json.dump(load, f, indent=4)
  await ctx.send(f"I set your AFK to: {reason}")

@bot.event
async def on_message(message):
  with open("afk.json", "r") as f:
    load = json.load(f)

  if str(message.author.id) in load.keys():
    load.pop(str(message.author.id))
    with open("afk.json", "w") as f:
      json.dump(load, f, indent=4)

  await message.channel.send(f"Welcome back {message.author.mention}! I removed your AFK.")
  return

  if len(message.mentions) > 0:
    target = message.mentions[0]
    try:
      msg = load[str(target.id)]
    except KeyError:
      return
    await message.reply(f"**{target}** is AFK: {msg}")```
`json src`

{

}```

#

can anyone help? sry for flood

hasty iron
#

dont use json

slate swan
#

its ohk ur bot is spamming right

slate swan
slate swan
hasty iron
#

a database

#

dont use mysql when there are better alternatives like postgresql

slate swan
#

how would i do that exactly? cuz json files and db files arent exactly my specialty

slate swan
#

send ss = screenshot

valid niche
#

like why

slate swan
#

like i said, json isnt my specialty ๐Ÿ˜ญ

#

same with db

hollow mortar
#

now i still have anther problem

hasty iron
#

then dont use it

#

learn how to use databases

hollow mortar
#

how do i make a code that give a member a perm and i have the channel id and the member id

hasty iron
#

json will waste your time if you're planning to use it like this

slate swan
hasty iron
#

and get_member to get the member

hollow mortar
#

i have all that

hasty iron
#

Guild.get_member*

hollow mortar
#

i have the channel id and the member id

hasty iron
#

ok

slate swan
hollow mortar
#

yes

brazen seal
#

ye prints is only for debug testing

hollow mortar
#

it worked

hasty iron
#

i know you do, i just told you how to use them

slate swan
hollow mortar
#

lmao

#

but the problem now i want to know how to give perm for a guy in channel

brazen seal
#

someone can help me?

slate swan
#

roles u need roles

slate swan
hasty iron
unkempt canyonBOT
#

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

Edits the channel.

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

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
hasty iron
#

overwrites kwarg

slate swan
hollow mortar
brazen seal
hollow mortar
# unkempt canyon

i all ready have the id of everything i want to do i only didnt understand this

#

this channel edit not channel perm add and leave

hasty iron
#

you pass in a mapping of Role or Member and PermissionOverwrite to the overwrites kwarg

#

it edits the permissions

torn wagon
slate swan
torn wagon
slate swan
hollow mortar
#

cause you didnt give the channel id there

slate swan
slate swan
brazen seal
valid niche
hasty iron
slate swan
torn wagon
hollow mortar
#

its too op for me lol

slate swan
hasty iron
#

!d discord.Client.get_channel

unkempt canyonBOT
slate swan
#

lol

hasty iron
#

use that to get the channel

#

and then

#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 1.4: The `type` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
hasty iron
#

pass in the overwrites kwarg

brazen seal
valid niche
hollow mortar
valid niche
#

if you don't have that i'm sorry but you'll have to wait for that friend who made that code

hasty iron
#

keyword argument

hollow mortar
#

bro im beginner not advance

hasty iron
hollow mortar
#

bruh everyone learned from scratch even you its okay if i didnt understand and asked

slate swan
brazen seal
#

so someone can help me?

hasty iron
slate swan
hasty iron
#

i am?

slate swan
#

yes

hollow mortar
hasty iron
#

How much Python do I need to know?

discord.py is ultimately a complicated Python library for beginners. There are many concepts in there that can trip a beginner up and could be confusing. The design of the library is to be easy to use -- however the target audience for the library is not complete beginners of Python.

With that being said, beginners tend to use this library quite liberally anyway and while I appreciate the endeavour and tenacity it should be noted that asking for help here does take up the valuable time of volunteers. As a result certain knowledge is required before you can actively participate in the help channels:

  • The difference between instances and class attributes.
  • How to use data structures in the language.
    • dict/tuple/list/str/...
  • How to solve NameError or SyntaxError exceptions.
  • How to read and understand tracebacks.

This list is not exhaustive

If these concepts are confusing -- please feel free to complete a smaller and simpler project first before diving into the complexities that is asynchronous programming in Python. The Python help channel (python-help) or the Python server (https://discord.gg/python) could also be a place to go for basic Python help.

hollow mortar
hasty iron
#

read that

hollow mortar
#

i will report you

hasty iron
#

that isnt from me

#

that is from the creator of dpy lol

slate swan
#

slowly step by step

hasty iron
#

they need to learn python not dpy

hollow mortar
hasty iron
#

it's like trying to run before even walking

hollow mortar
#

and thats what i did and he doesnt want help and dont want me to learn it bruh

slate swan
hasty iron
#

?????

spring flax
#

!resources @hollow mortar this is useful for learning python

unkempt canyonBOT
#
Resources

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

slate swan
#

u help lol

#
import discord
import datetime
import asyncpg
from datetime import datetime
from discord.ext import commands

class afk(commands.Cog, name="afk"):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def afk(self, ctx, *, note=None):
        print("executed")
        data = await self.bot.db.fetchrow("SELECT * FROM afknote WHERE guild_id = $1 AND user_id = $2",
                                     (ctx.guild.id, ctx.author.id))
        if note == None:
            note = "No reason provided"
        if data is None:
            await self.bot.db.execute("INSERT INTO afknote(guild_id, user_id, note) VALUES ($1,$2,$3)",
                                 (ctx.guild.id, f"[{ctx.author.id}]", note))
            em = discord.Embed(
                title=f"**MEMBER AFK**",
                description=f"""{ctx.author.name} has gone afk\nAFK Note: {note}""",
                timestamp=datetime.now(),
                color=discord.Color.blurple()
            )
            em.set_thumbnail(url=ctx.author.avatar_url)
            await ctx.send(embed=em)
            name = f"[AFK]{ctx.author.name}"
            await ctx.author.edit(nick=name)
        print("something went wrong")


def setup(bot):
    bot.add_cog(afk(bot))

error: data = await self.bot.db.fetchrow("SELECT * FROM afknote WHERE guild_id = $1 AND user_id = $2", AttributeError: 'Bot' object has no attribute 'db'
can anyone help me with this?

slate swan
hollow mortar
#

kk

hasty iron
slate swan
#

sh

hasty iron
#

and now you have a full code about afk that requires you to have postgres

spring flax
#

@slate swan have you done bot.db = in your main file under bot construction?

pearl knot
#

bro im so annoyed rn

#

legit

hasty iron
#

ok

pearl knot
#

my bot's role is higher then my alts, and my alt is still able to ban someone higher then it

slate swan
cloud dawn
hasty iron
slate swan
#

learn it

slate swan
pearl knot
#

ik what hierarchy is ๐Ÿ˜ญ

cloud dawn
slate swan
pearl knot
slate swan
spring flax
slate swan
#

XD

slate swan
hasty iron
#

no

spring flax
#

And yes it'd be better if you ask for references here instead or copying code where you don't know what you are doing

outer violet
hasty iron
#

you need to: install postgresql -> setup postgesql -> setup afknote table -> connect to the db with asyncpg

trail breach
#

can i direct a user to a category of channels

outer violet
hasty iron
#

dont put it anywhere

#

its wrong and wont work

outer violet
#

oh

spring flax
#

!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.
slate swan
spring flax
#

Define msg as what message you want the bot to react to
And then do await msg.add_reaction(emoji)

#

@slate swan its wrong.

slate swan
spring flax
#

No

slate swan
#

this guy lol

spring flax
#

Read the error? It is when you invoke a command without the proper argument needed

hasty iron
#

also datetime objects are not callable iirc

#

yes you cant do utils.utcnow()(...)

#

create a timedelta and substract it from the current time

#

but you dont even use end so idk why you need it

spring flax
#

!d discord.ext.commands.Context.message

unkempt canyonBOT
spring flax
slate swan
river walrus
hollow mortar
#

hello

#

any one know what this problem mean

#
    raise InvalidArgument('target parameter must be either Member or Role')
discord.errors.InvalidArgument: target parameter must be either Member or Role
c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py:83: RuntimeWarning: coroutine 'GuildChannel.set_permissions' was never awaited
  ctx.channel.set_permissions(user, read_messages=True, send_messages=True)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
#

i use this code

hasty iron
#

you didnt await it

hollow mortar
#

thanks

slate swan
#

@spring flax

slate swan
hasty iron
#

ctx.message.add_reaction isnt ctx.add_reaction

slate swan
#

lol sorry

void flare
#

hello, does discord.FFmpegOpusAudio.from_probe have better audio quality than FFmpegPCMAudio ?

outer violet
trail breach
#

<#category_id> any examples for this there literally nothing online

#

???

hollow mortar
#

hello

#
 await ctx.channel.set_permissions(user, read_messages=True, read_messages_history=True, send_messages=True)```
#

got it working

trail breach
#

error?

hollow mortar
#

ty

trail breach
#

k gr8

slate swan
#

indents?

slate swan
fresh sparrow
#

Hi

slate swan
#

the command has to be in the class

fresh sparrow
#

Guys

slate swan
#

lol

slate swan
fresh sparrow
#

I want a system bot project

slate swan
#

ok

fresh sparrow
#

Ahh anyone have it?

brazen seal
#

someone can help me?

slate swan
#

just like this

fresh sparrow
#

Where i can find one?

slate swan
#

no

#
import discord
from discord.ext import commands
import json
import pathlib

afk_path = pathlib.Path(__file__).parent / "afk.json"

class afk(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

@commands.command(aliases=['afk'])
async def Afk(self, ctx, *, reason):
    await ctx.message.delete()

    if reason == None:
        reason2 = 'I set your AFK'
        reason = ''
    else:
        reason2 = f'I set your AFK, status: {reason}'
    with open(afk_path, "r") as f:
        data = json.load(f)

    if ctx.author.id in (data[str(ctx.guild.id)]['AFK']):
        await ctx.channel.send('You\'re a little to quick here', delete_after=5)
        return

    data[str(ctx.guild.id)]['AFK'][str(ctx.author.id)] = reason
    await ctx.channel.send(f'{ctx.author.mention} {reason2}', delete_after=15)

    with open(afk_path, "w") as f:
        json.dump(data,f, indent = 4)
    try:
        await ctx.author.edit(nick='[AFK]'+ctx.author.name)
    except:
        pass

def setup(bot):
    bot.add_cog(afk(bot))```
main file: ```py
#imports blah blah blah
bot.load_extension('cogs.afk')
#src here blah blah blah```
error: `discord.ext.commands.errors.CommandNotFound: Command "afk" is not found
`
anyone know how to fix?
hasty iron
#

indents

slate swan
#

indents

#

whats wrong with the indents

hasty iron
#

re-look at them

slate swan
#

like, which area

#

before of after the command definitive

hasty iron
#

its the whole command

slate swan
#

oh

#

alright

soft galleon
#

how to get animated emoji from another server?
i have no nitro so i cant use the :emoji: thing

slim valve
#

Anyone using on_ย message ?

high flame
#

we all do-

wanton pebble
#

this is gonna be worded abysmally but uhm can someone help like uh

ctx.guilds would be for guild in bot.guilds

guild being the key word

can i get the value to be number of letters in an embeds description?

peak salmon
#

how can i wait_for a message from members in a member list in any order?

msg = await self.bot.wait_for('message', check=lambda message: message.author == member1)
wanton pebble
#

and i thought my question made no sense lmao

peak salmon
wanton pebble
#

ohh

peak salmon
#

i have found something like this

pending_tasks = [self.bot.wait_for('message',check= lambda message: message.author == member1), self.bot.wait_for('message',check= lambda message: message.author == member2)] 
wanton pebble
#

couldnt you do like an if statement before the wait for message saying

if member in listname:
the wait for function

peak salmon
#

and how check should look like

check = lambda message: message.author == ????

member from if maybe

wanton pebble
#
apple = await bot.wait_for("message", 
    check=lambda m: m.channel == ctx.channel and ctx.author == user, timeout=50.0)
wanton pebble
#

user would be defined as ctx.author already when he checks the author before the wait for

slate swan
#
import discord
from discord.ext import commands
import json
import pathlib

afk_path = pathlib.Path(__file__).parent / "afk.json"

class afk(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command(aliases=['afk'])
    async def Afk(self, ctx, *, reason):
        await ctx.message.delete()
        if reason == None:
            reason2 = 'I set your AFK'
            reason = ''
        else:
            reason2 = f'I set your AFK, status: {reason}'
        with open(afk_path, "r") as f:
            data = json.load(f)

        if ctx.author.id in (data[str(ctx.guild.id)]['AFK']):
            await ctx.channel.send('You\'re a little to quick here', delete_after=5)
            return

        data[str(ctx.guild.id)]['AFK'][str(ctx.author.id)] = reason
        await ctx.channel.send(f'{ctx.author.mention} {reason2}', delete_after=15)

        with open(afk_path, "w") as f:
            json.dump(data,f, indent = 4)
        try:
            await ctx.author.edit(nick='[AFK]'+ctx.author.name)
        except:
            pass

def setup(bot):
    bot.add_cog(afk(bot))```
main file: ```py
#imports blah blah blah
bot.load_extension('cogs.afk')
#src here blah blah blah```
error: ```Ignoring exception in command Afk:
Traceback (most recent call last):
    if ctx.author.id in (data[str(ctx.guild.id)]['AFK']):
KeyError: '821722608767598663'

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

Traceback (most recent call last):
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: '821722608767598663'

can anyone help?

boreal osprey
#

how to i make it not display as a link?

wanton pebble
#

@cloud dawn

names = {"yes", "kid"}
if ctx.author.display_name in names:
    user = ctx.author
    apple = await bot.wait_for("message", 
    check=lambda m: m.channel == ctx.channel and ctx.author == user, timeout=50.0)
else:
    pass
slate swan
boreal osprey
slate swan
cloud dawn
#

kinda useless

wanton pebble
boreal osprey
#

ok

#

thanks

wanton pebble
slate swan
#

member = ctx.author if not member else member

boreal osprey
#

:D

cloud dawn
wanton pebble
#

wait what? i never said ctx.author == ctx.author

wanton pebble
#

where?

boreal osprey
wanton pebble
#

OH you mean in the function

cloud dawn
boreal osprey
wanton pebble
#

@cloud dawn

names = {"yes", "kid"}
if ctx.author.display_name in names:
    user = ctx.author
    apple = await bot.wait_for("message", 
    check=lambda m: m.channel == ctx.channel and m.author == user, timeout=50.0)
else:
    pass
#

better?

wanton pebble
wanton pebble
cloud dawn
#

No worries i was curious.

boreal osprey
#

like this?

wanton pebble
#

emb.set_image(url=f"{member.avatar_url}")

wanton pebble
cloud dawn
twin thicket
#
import discord
from discord.ext import commands
import os

class Events(commands.Cog):

    def __init__(self, client):
        self.client = client

    @self.client.event
    async def on_ready():
        print('Bot is now online!')

def setup(client):
    client.add_cog(Events(client))
twin thicket
#

Why am I getting error

wanton pebble
#

but he said it didnt work for him

twin thicket
#

ty

wanton pebble
#

try that instead of @self.client.event

twin thicket
#

object 'Cog' has no attribute 'Listener'

#

oh

#

the L

wanton pebble
#

not capital l

#

lol

cloud dawn
#

abboutta say

wanton pebble
#

@cloud dawn can you friend me? lol

#

im unable to friend anyone

twin thicket
#

Works now lol

wanton pebble
cloud dawn
twin thicket
#

he wants u bro

wanton pebble
twin thicket
#

or she we never know

wanton pebble
twin thicket
#

I identify as a f16 missile ready

wanton pebble
#

lmao

cloud dawn
#

seal

wanton pebble
#

@twin thicket you friend me too if you want

#

@cloud dawn HOW OLD ARE YOU-

#

ur acc is like older than my sister

#

;-;

#

speak of the devil, my family is home

twin thicket
#

Yo um

#

how do I modify the help command, it looks dumb

cloud dawn
wanton pebble
#

where you defined client

twin thicket
#

how do I get the descriptions, usages and that kinda shit tho

wanton pebble
#

do , help_command=None

cloud dawn
twin thicket
#

like I have my categories and stuff

wanton pebble
cloud dawn
#

I'm 18 though

wanton pebble
#

i probably got the commands.Bot wrong

cloud dawn
#

commands.Bot()

wanton pebble
twin thicket
#

you know what I mean

wanton pebble
twin thicket
#

so I dont have to manually add the commands to the help command

twin thicket
wanton pebble
#

dosent ctx.commands or smth exist

twin thicket
#

huh

cloud dawn
wanton pebble
cloud dawn
#

But you can also just subclass the help command. <- i recommend this

wanton pebble
#

yes but thats boring

cloud dawn
twin thicket
#

How dehel do I subclass

cloud dawn
wanton pebble
#

a command is more effort

#

its more work and customisation

cloud dawn
cloud dawn
wanton pebble
#

1992 days (my time zone)

wanton pebble
#

yes

cloud dawn
#

!e ```py
print(1992/365)

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

5.457534246575342
cloud dawn
#

nice

wanton pebble
#

lol

cloud dawn
#

bit young for my taste but she'll get there

wanton pebble
#

!e

print("a")
unkempt canyonBOT
#

@wanton pebble :white_check_mark: Your eval job has completed with return code 0.

a
wanton pebble
#

;)

wanton pebble
#

im 1320

hollow mortar
#

hey i have question do i can make a bot that can check the channels in the category if the name of t he channel all ready exsist send a msg saying its there ?

wanton pebble
#

sorry but i didnt understand a word you just said

#

if you're asking if a bot can scan a category for channels, idk if it can do category but it can do server

twin thicket
#

class Utility(commands.Cog):

    def __init__(self, client):
        self.client = client

    #Commands
    @commands.command()
    async def ping(self, ctx):
        """Pings the bot"""
        await ctx.send('Pong!')

    @commands.command()
    async def load(ctx, extension):
        self.client.load_extension(f'cogs.{extension}')

    @commands.command()
    async def unload(ctx, extension):
        self.client.unload_extension(f'cogs.{extension}')
cloud dawn
unkempt canyonBOT
#

property channels: List[GuildChannelType]```
Returns the channels that are under this category.

These are sorted by the official Discord UI, which places voice channels below the text channels.
twin thicket
#

anyone know why self.client is not defined?

wanton pebble
twin thicket
#

nvm I just didnt add self as a parameter

wanton pebble
#

LMAO-

#

i feel the pain dw

cloud dawn
#

Naming it client but using it as a bot pithink

wanton pebble
cloud dawn
#

exactly

twin thicket
#

FFFFFFFFFFFFFFFFFFFFFF

#

too late to turn back tbh

wanton pebble
#

@twin thicket you not gonna make it owner only command?

twin thicket
#

ye I am

wanton pebble
cloud dawn
wanton pebble
#

lol

twin thicket
wanton pebble
cloud dawn
wanton pebble
#

nono it dosent work unless you click alt+f4 and enter, fast

#

||save menu always spoils it otheriwse||

#

ahem-

#

i wonder if eval can do a whole command

cloud dawn
wanton pebble
#

!e

import discord
from discord.ext import commands
bot=commands.Bot(command_prefix="a.")

@bot.event
async def on_ready():
    print("e")
unkempt canyonBOT
#

@wanton pebble :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
wanton pebble
#

rip

cloud dawn
#

Hate to break it but someone already made a bot inside a bot inside a bot inside a bot inside a bot ...

wanton pebble
#

XD

heavy heath
#

Hey guys, does anyone know how i can ask the user for input in discord from a bot please?

cloud dawn
#

I can't wait for the day my discord account exists 18 years then i can verify myself instantly on any 18+ server.

cloud dawn
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**...
wanton pebble
cloud dawn
#

Don't you spoonfeed the guy

wanton pebble
wanton pebble
cloud dawn
#

How else will they learn?

wanton pebble
#

xD

#

people say giving someone something instead of making them work for it wont make them learn, its a misconception, think of it like this, if you do it enough, they'll remember ;)

#

anyway imma go make dinner/tea/food/whatever lmao

cloud dawn
heavy heath
cloud dawn
wanton pebble
heavy heath
#

I think i've done it now, just tested and everything looks good

cloud dawn
slate swan
#

How do I make my bot add a reaction to a message does anyone know. Also does anyone know how I can make certain commands to only work for certain roles?

wanton pebble
slate swan
#

ok

bold dawn
#

Downloaded all the modules I can. It still says no module named discord.app

#

Any help?

slate swan
#

what module's?

#

to be exact

bold dawn
#

from discord.app import option

slate swan
#

Idk then

torn wagon
#

how do i host my discord bots to never go offline

slate swan
#

Leave your pc on 24/7

torn wagon
#

r u sped the discord bot isnt running through my pc

#

lol

slate swan
#

How @ a role in an embed.

bold dawn
slate swan
torn wagon
#

nothing

#

i jus made it and tested on repl and it worked

#

so now i jus needa host it

slate swan
#

Oh you used replit

#

I think you have to just play the code and it should stay up?

#

How do I @ a role in an embed.

#

Please dm me on how to do it.

slate swan
#

dont add the spaces , its just to demonstrate

#

ok

#

hello ! , does anyone know any nsfw api i could use ?

slate swan
wanton pebble
wanton pebble
hasty iron
#

it adds the reaction to the message

slate swan
#

oh

hasty iron
#

which includes the embed

slate swan
#

ok

slate swan
wanton pebble
#

title can just do name anywayz or set_author so it isnt really needed

slate swan
wanton pebble
slate swan
#

yes will do

wanton pebble
#

no await = discordpy intensely screams

slate swan
#

lmao pepe_shrug

slate swan
#

oh still going

wanton pebble
#

o

slate swan
#

making some nsfw commands, fixing some stuff

#

so in theroy this code should work

wanton pebble
slate swan
#

can we see ?

#

U want a good api?

#

@bot.command(name='gamerules')
async def Gamerules(context):

embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
embed.add_field(name="Vote for an ssu",value="@cyan sealโ€โ€โ€Ž", inline=False)
embed.add_reaction("")

await context.send(embed=embed)
#

yes pleaseee

slate swan
slate swan
wanton pebble
wanton pebble
#

also put it after the send

#

you cant react to a mssage that dosent exist

slate swan
#

He using context ahhhhh

wanton pebble
#

LMFAO

slate swan
#

ctx > everything

wanton pebble
#

replace context with ctx @slate swan

#

context hurts my head

wanton pebble
slate swan
#

Discord should have an api key system

wanton pebble
#

and normal java screams for not having a capital S in print LMAO

slate swan
#

.....

wanton pebble
#

how lmfao

#

its literally default with discordpy

slate swan
#

in the brackets of a sync def gamerules change it to ctx

#

instead of context

slate swan
wanton pebble
#

@bot.command()
async def apple(ctx):

slate swan
#

^

slate swan
#

!code

#
@bot.command(name='gamerules')
async def Gamerules(context):

    embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
    embed.add_field(name="Vote for an ssu",value="@cyan sealโ€โ€โ€Ž", inline=False)

    await cxt.send(embed=embed)

    await embed.add_reaction("")
#

So that should work

slate swan
#

i feel bad for laughing

wanton pebble
#

also if you wanna make embed easier
at the top

from discord import Embed

and do

embed=Embed(title="yes",
description="no")

slate swan
#

ok

wanton pebble
#
@bot.command(name='gamerules')
async def Gamerules(ctx):

    embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
    embed.add_field(name="Vote for an ssu",value="@cyan sealโ€โ€โ€Ž", inline=False)

    await ctx.send(embed=embed)

    await embed.add_reaction("")
slate swan
slate swan
slate swan
wanton pebble
#

i was abt to explain it lmao

slate swan
wanton pebble
#

@slate swan line 2, you said (context), ctx is what you need. always do ctx instead of context.

name isnt really needed imo

you misspelled ctx.send you said cxt.send

slate swan
#

Ah ok

wanton pebble
#

@slate swan tbf at least hes using bot and not client

hasty iron
#

why are you doing embed.add_reaction

slate swan
slate swan
slate swan
hasty iron
#

kira the first answer you sent was the correct one

wanton pebble
#

oops thats my fault i said to use embed not thinking hed axtually use embed variable

wanton pebble
#

i said that first and assumed when i said embed he'd knew to make embed into a diff var as it was sending

slate swan
wanton pebble
slate swan
#

ok

wanton pebble
#

what would be cool is if they added it so each field could have a different embed colour on the side of the field

#

lmao

slate swan
#

now for me i think I should have started by just making it say hello world in a message.

wanton pebble
#

lmfao

#

at least pushing yourself gives you room to learn ig but yeah try not to jump too far

slate swan
#

@slate swan are you familiar with OOP ? or python basics ?

#

decorators etc

#

for me I went
steep 1. make the bot
step 2. download everything I need
step 3. Don't follow the tutorial and just go into it
step 4. realise I know nothing about python.

hollow mortar
#

hey i want to ask do i can make a bot that triger if a channel named snkrs is in the category and if yes it doesnt make ppl create it again

hollow mortar
#

like a bot that triger if a channel called snkrs is in category nike a guy cant make new snkrs channel using the bot untile he close the first one

wanton pebble
slate swan
hollow mortar
slate swan
wanton pebble
wanton pebble
#

i recommend asking a yt vid how to understand docs cuz if not it'll only get harder

hollow mortar
#

lmao thats not a normal dock right

#

you mean docs is a programing thing ?

#

like i need to learn it first ?>

wanton pebble
hasty iron
#

docs arenโ€™t only in programming

#

itโ€™s documentation

hollow mortar
#

yeah i know but i dont understnad the discord.py ones cuz its not a code and kinda hard

#

to understand

slate swan
# wanton pebble stack overflow is literally my lifes saviour

stack overflow destroyed my life , they share terrible code , not all the time , but most let me show you a example, look at this code here https://stackoverflow.com/questions/55742719/is-there-a-way-i-can-unban-using-my-discord-py-rewrite-bot
and what i wrote
its a unban command

    @commands.command()
    @commands.has_permissions(ban_members=True)
    @commands.cooldown(1,5,BucketType.member)
    async def unban(self,ctx,* , member: typing.Union[discord.Object,discord.User]):
        await ctx.guild.unban(member)
        embed = discord.Embed(title=f"",description=f'{member} have been unbanned for\n CHEERS !')
        await ctx.send(embed=embed)``` ![Get_dead_by_cat](https://cdn.discordapp.com/emojis/867534573802094612.webp?size=128 "Get_dead_by_cat")
hasty iron
#

what do you mean "not a code"

#

do you expect them to just give you code

#

thats not how documentation works

hollow mortar
#

like how do i can make of docs ?

slate swan
hollow mortar
#

like i dont understand how you can make a code out of doc

hasty iron
#

you search the methods you need

hollow mortar
#

i know its a stupid one lmao

hasty iron
#

look at the arguments, return type, etc

#

the errors it can raise

#

you dont make a code out of documentation

#

itโ€™s a reference

hollow mortar
wanton pebble
#

i get sometimes the code can be untrustworthy but thats why you should know python basics before so you can gauge what the code would do before using it

hasty iron
#

videos that are related to dpy are a no-go

#

most of them are bad vids that teach bad practices

slate swan
# wanton pebble i dont see the issue?-

that one doesnt take a user id , and only checks the tag , also it using a for loop which will takes more time , and checking it that user matches the statement which is more time , and finally its fetching the bans which is even more time n_pepesweatin

wanton pebble
hollow mortar
hasty iron
#

ah yes, unbanning a member, the classic

slate swan
hasty iron
#

how are you going to get the member if theyโ€™re not even in the guild

wanton pebble
slate swan
hasty iron
#

and also euclid is using the User converter which works just fine

hollow mortar
slate swan
hasty iron
#

what is the "basic converter"

#

typehinting as discord.User is the same as doing commands.UserConverter

slate swan
#

How do I make it so that only specific roles can use a command?

wanton pebble
#

@commands.has_role
?-

#

@bot.command
@commands.has_role("ROLE NAME")
async def...

slate swan
#

ok.

high flame
#

has_roles

#

plural

wanton pebble
#

role works too for singular

high flame
#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

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

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

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
slate swan
high flame
#

breh ok

wanton pebble
#

see lmao

hasty iron
#

so it basically never fails

wanton pebble
#

@high flame

hasty iron
#

!d discord.ext.commands.has_any_role

unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
wanton pebble
#

who deleted-

high flame
hasty iron
#

there isnโ€™t an event for that

high flame
#

no event

hasty iron
#

you need to track the serverโ€™s activness yourself

wanton pebble
slate swan
#

Yes?

wanton pebble
#

look at that

slate swan
#

ok

hasty iron
#

an event isnโ€™t a command

high flame
#

i'd use on_message and some other stuff

wanton pebble
#

you can list guilds its in i think but not event and idk abt most active

high flame
#

and a database

wanton pebble
#

you can use db to count messages, joins, ect.. and define it as the guild username then order by size

wanton pebble
slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

tall agate
#

can you get the user that banned another user from a guild

dapper cobalt
#

!d discord.BanEntry

unkempt canyonBOT
#

class discord.BanEntry```
A namedtuple which represents a ban returned from [`bans()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.bans "discord.Guild.bans").
dapper cobalt
#

It only returns the reason and the banned user.

#

Actually, you can.

#

!d discord.Guild.audit_logs yields a discord.AuditLogEntry which has user attribute (who did the action), action attribute (the action done), target attribute (the user/channel/etc.. whom the action was done to).

unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guildโ€™s audit logs.

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

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print(f'{entry.user} did {entry.action} to {entry.target}')
```...
slate swan
#

How do i specify how many messages can be cached at once?

slate swan
#

to limit how much ram is being used, etc

reef shell
#

max_messages

whole spindle
#

Hi! I am current making a discord bot and am working on an auto moderation system. I am including an "alias letter" detectopn system to prevent people from being creative and bypassing the filter using lookalike letters/characters. Is there a chance anyone here has a large dictionary of these that i could use?

reef shell
#

You can set it when making an instance of bot

reef shell
#

Default is 1000

slate swan
#

alr ty

dapper cobalt
#

snipe_message_author doesn't have a key of this channel's ID.

#

Al 'afw!

slate swan
reef shell
#

Np

misty stream
#

this code ```py
async def updateLoop():
print(f"\n", end='')
print(f"\nStarting update loop...", end='')

await bot.wait_until_ready()
channel = bot.get_channel(STREAMER_CHANNEL)

while(True):
    today = datetime.datetime.today()
    weekday = today.weekday()
    now = datetime.datetime.now()
    value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]
    if (value != "" and value != None):
        await channel.purge()
        sleep(1)
        await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
        MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
        writeToFile()
        await updateImage()
        updatestreamerweb()
        channel = bot.get_channel(878637135337492502)
        await channel.send('@everyone Make sure to check out our awesome website and watch our featured streamers on it to earn points so you can unlock the request feature role on discord by buying it with the points you earn https://www.so-network.blackbullstudio.eu')
    else:
        print("randomfeature")
    future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)
    await asyncio.sleep( (future-today).total_seconds() )
returns this
#

how can i execute this only once but reactivate it when its false again

kindred epoch
#

i just got an error that shows a nontype on a if statement

#

and im confused

little ether
kindred epoch
#
if result['card_amount'] > 1:
                            await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount - 1 WHERE user_id = $1 AND cardid = $2",ctx.author.id,id)
                        if result['card_amount'] == 1:
                            await self.client.pg_db.execute("DELETE FROM pokesetspc WHERE user_id = $1 AND cardid = $2",ctx.author.id,id)
                        if result3['card_amount'] is None or result3 is None:
                            await self.client.pg_db.execute("INSERT INTO pokesetspc(user_id,cardid,pc,card_rarity_card_set_name) VALUES($1,$2,$3,$4,$5)",ctx.author.id,id2,result2[0],result2[3],result2[4])
                        if result3['card_amount'] > 1:
                            await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount + 1 WHERE user_id = $1 AND cardid = $2",ctx.author.id,id2)
                        if result2['card_amount'] > 1:
                            await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount - 1 WHERE user_id = $1 AND cardid = $2",member.id,id2)
                        if result2['card_amount'] == 1:
                            await self.client.pg_db.execute("DELETE FROM pokesetspc WHERE user_id = $1 AND cardid = $2",member.id,id2)
                        if result4['card_amount'] is None or result4 is None:
                            await self.client.pg_db.execute("INSERT INTO pokesetspc(user_id,cardid,pc,card_rarity,card_set_name) VALUES($1,$2,$3,$4,$5)",member.id,id,result[0],result[3],result[4])
                        if result4['card_amount'] > 1:
                            await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount + 1 WHERE user_id = $1 AND cardid = $2",member.id,id)
little ether
# kindred epoch

that means result3 is None, also you have an await outside of an async function

kindred epoch
kindred epoch
little ether
kindred epoch
#
result = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",ctx.author.id,id)
            result2 = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",member.id,id2)
            result3 = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",ctx.author.id,id2)
            result4 = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",member.id,id)
#

dont mind the indents

#

@little ether

misty stream
#

is there someone who can help me out by any chance ?

little ether
kindred epoch
misty stream
#

Xd okey

misty stream
#

this code ```py
async def updateLoop():
print(f"\n", end='')
print(f"\nStarting update loop...", end='')

await bot.wait_until_ready()
channel = bot.get_channel(STREAMER_CHANNEL)

while(True):
    today = datetime.datetime.today()
    weekday = today.weekday()
    now = datetime.datetime.now()
    value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]
    if (value != "" and value != None):
        await channel.purge()
        sleep(1)
        await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
        MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
        writeToFile()
        await updateImage()
        updatestreamerweb()
        channel = bot.get_channel(878637135337492502)
        await channel.send('@everyone Make sure to check out our awesome website and watch our featured streamers on it to earn points so you can unlock the request feature role on discord by buying it with the points you earn https://www.so-network.blackbullstudio.eu')
    else:
        print("randomfeature")
    future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)
    await asyncio.sleep( (future-today).total_seconds() )
returns this
#

how can i execute this only once but reactivate it when its false again

#

instead of it spamming randomfeature i want it to execute it only once if the function is called

#

no no one knows Xd

outer violet
#

i made a buttons calculator command and was hoping that it'll work but then i got this error and now idk what to do

#

wait nvm i fixed it

slate swan
#

i need help

#

@azure tendon

#

@tight obsidian

#

help

little ether
#

uh why are you pinging random staff members

slate swan
#

i need help

slate swan
#

look

#

how do i make a warn system

#

help

tight obsidian
#

Please don't ping random people for help.

slate swan
#

BUT can you help

#

please please please

outer violet
#

okay i need help again

slate swan
outer violet
#

now its saying this

slate swan
#

that's like asking as to make a bot for you

outer violet
#

and whenever i try the command, it returns with this

stoic galleon
#

!eval {len(self.client.commands)}

unkempt canyonBOT
#

@stoic galleon :x: Your eval job has completed with return code 1.

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

no like you know ctx.whatdoitypehere("Username")

#

just what

slate swan
misty stream
outer violet
#

can someone help .-.

slate swan
#

whta

slate swan
icy seal
#

why are you in a hurry

outer violet
slate swan
#

send me da code

#

how can i make a ban event keep chats instead of deleting them?

outer violet
slate swan
outer violet
slate swan
#

is that for the cogs file? or the main one as well

outer violet
#

cogs only

#

main file has from discord_components import *