#discord-bots

1 messages · Page 800 of 1

sick birch
#

if vscode is what's telling you that, then you have to reload the window for it to realize it's installed

#

CTRL + SHIFT + P, then reload window

#

or just close it and open it, whatever you prefer

distant pike
#

nope

slate swan
#

thats not a disnake issue, your field value is empty

slate swan
distant pike
final iron
#

Are you using a venv?

#

Using a virtual environment can pretty much fix this issue

slate swan
#

plz help me

#

components need a label, or atleast an emoji ( for buttons)

slate swan
final iron
#

Can we see your code?

slate swan
#

thx

timid wagon
#

I've had that sort of trouble since I installed 3.10 as well thonk

#

I think the packages are still being installed to the older version while the IDE uses 3.10 - they've changed the location where Python installs now dead

slate swan
#

ohhh, well then using a venv would be the best option

final iron
#

I personally use anaconda but I've heard people say it's bad

#

I've never had any issues

visual island
#

flag class:

class ItemFlag(commands.FlagConverter):
    flags: list[str] = commands.flag()

command:

    @commands.command()
    async def setitems(self, ctx: commands.Context, *, items: ItemFlag):

error:

disnake.ext.commands.errors.MissingRequiredFlag: Flag 'flags' is required and missing

So, I got an issue with flags, I invoked the command with <prefix>setitems a=1 b=2 it raised an error. Any thoughts?

nimble thorn
#
@commands.command(help = "Ratio a worthy foe")
  async def ratio(self,ctx,msg_id):
    for channel in ctx.guild.channels:
      try:
        msg = await channel.get_message(id)
      except NotFound:
        continue

I am trying to get a msg object when a message id is passed into the command. The end goal is then to have the bot react and "ratio" the message. But in order to add the reaction, i.e. msg.add_reaction() I need the message object, and I am struggling to get it

cloud bison
#
print('Bot: ' + get_response(input('You: ')))

I'm trying to get the bot to take every message and then reply to it, Same code above

@client.event
async def on_message(message):
    if message.channel.id == 877066533250166824 :
        channel = 877066533250166824
        author = str(message.content)
        while True :
            await get_response(author)
            await channel.send(get_response)
    await client.process_commands(message) 

and it's still not working

cloud bison
nimble thorn
echo wasp
cloud bison
slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
quick gust
#

@echo wasp Don't handle the error, it should raise one then

#

Remove your error handler for that command

echo wasp
cloud bison
quick gust
#

also, in your code you have 2 args, but you only provided one

#

You need to give it a role and a member

#

while invoking

slate swan
#

how to add slowdown

quick gust
#

!d discord.ext.commands.cooldown

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
quick gust
#

oh

#

just edit the TextChannel then

slate swan
echo wasp
slate swan
#

!d discord.TextChannel.slowmode_delay

unkempt canyonBOT
quick gust
#

this will make the member arg not a required arg

echo wasp
#

ok so if i want to give someone else a role i can still do that

slate swan
quick gust
#

yes if they provide an ID, then member will be the member they gave

quick gust
#

tf is kayle typing

slate swan
#

fr

echo wasp
#

lol

slate swan
#

he writing a whole paragraph

azure scroll
#
async def makenotes(ctx, *, args):
    #try:
        if (len(list(db.NoteBoyNotes.find({'_id':'{}'.format(ctx.author.id)}))) == 0):
            NotesUpdateDict = {'_id':'{}'.format(ctx.author.id), 'notes':[]}
            NotesUpdateDict['notes'].append(args)
            NBNotes.update(NotesUpdateDict)
            x = notesCol.insert_one(NBNotes)
            await ctx.send("Ok, Noted")
        else:
            pass```

I am recieving the following error

```TypeError: 'AsyncIOMotorCursor' object is not iterable```
slate swan
quick gust
#

use fetchall or something

#

idk

azure scroll
echo wasp
#

i restarted my bot and i still get this error

quick gust
#

show code, you didn't give it a member

boreal ravine
#

You are missing a required argument when invoking the command

echo wasp
# quick gust show code, you didn't give it a member
@commands.command()
    @commands.has_role(893308556596641792)
    async def addrole(self, ctx, role: discord.Role, member: discord.User):
        member = None or ctx.author
        roles = [933104091066941530, 936481481113632839, 936712347211419708, 936712664950931476, 842254098266718219, 842253873376264222, 842254463309316136, 842260259417489448, 842260429044842572, 893308041699680337, 816838497159610369, 826636738306506794, 841144860966125568]
        if role.id in roles:
            await member.add_roles(role)
            await ctx.channel.send(f"You have added {role} to your role list!")
    #@addrole.error
    #async def addrole_error(self,ctx,error):
     #   if isinstance(error, commands.RoleNotFound):
      #      await ctx.send("I Can't give you that role because either it is not on the list or it is not a role")
    ```
slate swan
unkempt canyonBOT
#

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

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | TypeError: function() missing 1 required positional argument: 'name'
quick gust
#

well u didn't do what I said

echo wasp
#

i did half i am thinking

boreal ravine
quick gust
slate swan
#

what was that just add a defualt value in params?

quick gust
#

don't judge me it's hard on mobile

slate swan
#

!e

def a(name: str = "bob") -> str:
    return name

a("pepe")
a()
unkempt canyonBOT
#

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

[No output]
slate swan
#

it would return pepe and then bob lol

echo wasp
#
@commands.command()
    @commands.has_role(893308556596641792)
    async def addrole(self, ctx, role: discord.Role, member: None):
        member = None or ctx.author
        roles = [933104091066941530, 936481481113632839, 936712347211419708, 936712664950931476, 842254098266718219, 842253873376264222, 842254463309316136, 842260259417489448, 842260429044842572, 893308041699680337, 816838497159610369, 826636738306506794, 841144860966125568]
        if role.id in roles:
            await member.add_roles(role)
            await ctx.channel.send(f"You have added {role} to your role list!")
``` Please explain when i added what i thought you ment and it is still requireing member
quick gust
#

why did u typehint it

slate swan
#

name as a str?

velvet tinsel
slate swan
#

hi

quick gust
velvet tinsel
#

go touch grass

slate swan
quick gust
#

maskuh typehinted member to None

fervent shard
velvet tinsel
#

it's like, what, 3 am at yours

slate swan
quick gust
#

lol

velvet tinsel
echo wasp
#

10 30 pm here

slate swan
quick gust
#

12 pm

slate swan
#

kayle stop typing already😭

echo wasp
velvet tinsel
#

6:30am

quick gust
slate swan
quick gust
#

why would u remove evreything then

#

..?

echo wasp
# quick gust what bar...?
async def addrole(self, ctx, role: discord.Role, member: None):  ``` this bar and remove member typehint
quick gust
#

I'm gonna go attend my class

slate swan
slate swan
#

i mean you do but not like that

#

youre just saying member is expected as None

#

to add a default value it would be as so

member: discord.Member = None
quick gust
#

member: discord.Member = None

member = member or ctx.author

echo wasp
#

i had py async def addrole(self, ctx, role: discord.Role, member: discord.User):

echo wasp
fervent shard
#

what would go in the reactrole.json file? i dont know what to start help.

@bot.command()
@commands.has_permissions(administrator=True)
async def reactionrole(ctx, emoji, role: discord.Role, *, message):
  embedVar = discord.Embed(description=message)
  msg = await ctx.channel.send(embed=embedVar)
  await msg.add_reaction(emoji)
  
  with open('reactrole.json') as json_file:
    data = json.load(json_file)

    new_react_role = {
      'role_name':role.name,
      'role_id':role.id,
      'emoji':emoji,
      'message_id':msg.id
    }

    data.append(new_react_role)

  with open('reactrole.json', 'w') as j:
    json.dump(data,j,indent=4)```
slate swan
#

nothing

#

you shouldnt use json as a db

quick gust
fervent shard
echo wasp
echo wasp
fervent shard
quick gust
slate swan
#

removes msg

fervent shard
fervent shard
slate swan
#

lol

quick gust
fervent shard
quick gust
#

deletes all messages

i only sent it once!!

boreal ravine
#

guys stop fighting

quick gust
#

sure i go to my class lol

fervent shard
slate swan
#

there is always random bullshit in this channel

#

ikr

quick gust
#

true

boreal ravine
slate swan
#

what isnt?

pine crown
#

how to make so that after the user uses a command, the next message they sent will be set to a veriable

slate swan
#

using json as a db

fervent shard
echo wasp
#

YOU FIXED IT THANK YOU!!!

slate swan
quick gust
boreal ravine
slate swan
rapid turret
#

How can i learn to build gpt 3 bots as a complete beginner?

echo wasp
# quick gust np

also i want it to delete the 2 messages after like 10 seconds how would i do that i think with asyncio.sleep(10) then await ctx.message.delete(2) or something like that

slate swan
#

im going to go to sleep gn guys have a lovely day or night❤️

pine crown
#

for a message

#

not a reaxtion

slate swan
#

var = await bot.wait_for()

pine crown
#

oh

echo wasp
#

hey okimii can you answer my question above?

slate swan
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
pine crown
slate swan
#

or?

slate swan
#

IIRC

steep ocean
#

yo

pine crown
slate swan
pine crown
steep ocean
#

yo anyone good at python

#

?

echo wasp
steep ocean
#

can do basic stuff

#

like strghings html

#

boolean

echo wasp
#

wait html is a python library

steep ocean
#

idk

#

i just said random stuff but like the basqics

#

loops, functions, if else

#

boolean

echo wasp
slate swan
boreal ravine
steep ocean
#

i tried already

#

ngl

#

i pretty much need like someone to carry me thourgh a few coding lessons on code hs so i can get rid of my d

slate swan
echo wasp
boreal ravine
#

you don't need an example on how to use kwargs.. you should've learnt that before using d.py

slate swan
unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

echo wasp
#

nice

pine crown
slate swan
#

depends what guild is

steep ocean
#

okimii do you have spare time to help a poor little soul get a better grade in his computer hardware class that he currently has a D in and his last effort to do this is tohinght by 12 am

slate swan
#

not really im failing math😭

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
#

might help

steep ocean
#

?

slate swan
#

website for beginners etc

steep ocean
#

i would love to look at this but i am in a panick, and i need this done like soon and im too dumb to understand this stuff

#

ive tried for weeks and cant do it

slate swan
steep ocean
#

umm sure

slate swan
#

just ping me in one

steep ocean
#

what is ot channel

quick gust
#

!OT

steep ocean
#

oh

quick gust
#

!ot

unkempt canyonBOT
slate swan
quick gust
nimble plume
#

i have a members id list i want to check if member.mentioned_in(message)

visual island
#

flag class:

class ItemFlag(commands.FlagConverter):
    flags: list[str] = commands.flag()

command:

    @commands.command()
    async def setitems(self, ctx: commands.Context, *, items: ItemFlag):

error:

disnake.ext.commands.errors.MissingRequiredFlag: Flag 'flags' is required and missing

So, I got an issue with flags, I invoked the command with <prefix>setitems a=1 b=2 or <prefix>setitems a:100 b:200 it raised an error. Any thoughts?

timid wagon
#

If the "member list" you have is just a few elements, then the first method would be preferable

nimble plume
#

@timid wagon i have user id

#

i want member.mentioned_in(message):

#

member .

#

member = id

timid wagon
#

So you use the first method

nimble plume
#

id is in AFK = []

timid wagon
#

Fetch the member via the ID in the list first

nimble plume
nimble plume
#

ya

#

``py

#
      for member in AFK_PPL:
       user = bot.fetch_user(AFK_PPL)
       if user.mentioned_in(message):
          await message.reply(f"||{member}|| | is AFK")
slate swan
timid wagon
timid wagon
slate swan
timid wagon
timid wagon
slate swan
#

no error

timid wagon
#

Is it printing aca or not?

#

Also, check if you have set a system channel for your test guild - otherwise guild.system_channel shall return None (though that would also give an error)

slate swan
#

but still its now what i wanted

#

the heart emojis arent showing up

nimble plume
#

@timid wagon discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In user_id: Value "[852911179450023976]" is not snowflake.

nimble plume
#

that need to be checked

slate swan
maiden fable
#

Code

nimble plume
maiden fable
#

Then use indexing

visual island
#

how to allow FlagConverter to take any flag name and value?

echo wasp
#

it is nice when you can copy pasta your command you built above and just change like 5 words and it does the opposite of the command you copy pasta does

nimble plume
#

@maiden fable i use

#

user = await bot.fetch_user(AFK_PPL[0])

maiden fable
#

user = await bot.fetch_user(AFK_PPL[0][0])

nimble plume
maiden fable
#

Cz AFK_PPL[0] returns a list

nimble plume
#

oh..

#

@maiden fable'int' object is not subscriptable

maiden fable
#

Weird

nimble plume
#
  File "c:/Users/hp/Desktop/bot/sluppy.py", line 289, in on_message
    user = await bot.fetch_user(AFK_PPL[0][0])
TypeError: 'int' object is not subscriptable
maiden fable
#

Try printing AFK_PPL[0]

nimble plume
#

that are afk

#

many people

nimble plume
maiden fable
#

Okay

nimble plume
#

@bot.command(name="L")
async def n(ctx):
await ctx.send(AFK_PPL[0])

#

hmm

maiden fable
#

It can simply be print(AFK_PPL[0])

nimble plume
#
@commands.guild_only()
@bot.command(name="afk")
async def afk(ctx, * , reason=None):
     afk = f"[AFK] {ctx.author.name}"
     try:
          try:
             await ctx.author.edit(nick=afk)
             ids = ctx.author.id
             AFK_PPL.append(ids)
             await ctx.reply(f"||{ctx.author.mention}||| Set u AFK Reason : {reason}")
          except:
               ids = ctx.author.id
               AFK_PPL.append(ids)
               await ctx.reply(f"||{ctx.author.mention}||| Set u AFK Reason : {reason}")
     except discord.DiscordException:
          path
@bot.listen()
async def on_message(message):
 if message.author == bot.user:
     return
 elif message.author.bot: return
 else:
      for member in AFK_PPL:
       user = await bot.fetch_user(AFK_PPL[0][0])
       if user.mentioned_in(message):
          await message.reply(f"||{member}|| | is AFK")
@bot.listen()
async def on_message(message):
 if message.author == bot.user:
     return
 elif message.author.bot: return
 else:
      for member in AFK_PPL:
       if member == message.author.id:
           try:
                AFK_PPL.remove(message.author.id)
                await message.author.edit(nick=None)
                await message.channel.send(f"||{message.author.mention}|| | I removed u AFK")
           except discord.DiscordException:
                path
#

full afk command(nvmd)

#

779990652149825537

#

is the list

maiden fable
#

Mhm

nimble plume
#
@bot.listen()
async def on_message(message):
 if message.author == bot.user:
     return
 elif message.author.bot: return
 else:
      for member in AFK_PPL:
       user = await bot.fetch_user(AFK_PPL[0][0])
       if user.mentioned_in(message):
          await message.reply(f"||{member}|| | is AFK")
#

causing error

#

if i ping the afk user

#

it return this

maiden fable
#

Why fetching?

nimble plume
maiden fable
#

user = bot.get_user(AFK_PPL[0])

#

JS code

nimble plume
maiden fable
nimble plume
#

i was alsi thinking why fetch

unkempt canyonBOT
#

Hey @slate swan! 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!

maiden fable
#

!communities

#

!guilds

unkempt canyonBOT
#

Communities

The communities page on our website contains a number of communities we have partnered with as well as a curated list of other communities relating to programming and technology.

nimble plume
#

get_user

maiden fable
#

There, join a JS server

#

!d discord.ext.commands.FlagConverter

unkempt canyonBOT
#

class discord.ext.commands.FlagConverter```
A converter that allows for a user-friendly flag syntax.

The flags are defined using [**PEP 526**](https://www.python.org/dev/peps/pep-0526) type annotations similar to the [`dataclasses`](https://docs.python.org/3/library/dataclasses.html#module-dataclasses "(in Python v3.9)") Python module. For more information on how this converter works, check the appropriate [documentation](https://discordpy.readthedocs.io/en/master/ext/commands/commands.html#ext-commands-flag-converter).

iter(x) Returns an iterator of `(flag_name, flag_value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.

New in version 2.0.
maiden fable
#

This is a Python support server, not JS

nimble plume
#

same error

#

with get user

maiden fable
#

Show @nimble plume

#

!guilds

unkempt canyonBOT
#

Communities

The communities page on our website contains a number of communities we have partnered with as well as a curated list of other communities relating to programming and technology.

nimble plume
#

full
console
Ignoring

#

TypeError: 'int' object is not subscriptable

maiden fable
#

Ah

#

AFK_PPL[0]

#

Do this, not another [0]

nimble plume
#

huh?

visual island
nimble plume
#

await ctx.send(AFK_PPL[0])

nimble plume
maiden fable
#

Wait

#

Try doing *args: FlagConverter

nimble plume
#

instead of emty list it show error discord.ext.commands.errors.CommandInvokeError: Command raised an exception: IndexError: list index out of range

visual island
nimble plume
#

[] why not sending

#

@maiden fable its working fine now

nimble plume
nimble plume
#

working fine now

maiden fable
maiden fable
nimble plume
#

hmm

#

!e print("hello world")

unkempt canyonBOT
#

@nimble plume :white_check_mark: Your eval job has completed with return code 0.

hello world
visual island
# maiden fable Yes

<prefix>cmd a:100 b:200 tried to invoke using this, but when I print the arg, it returns empty stuff

nimble plume
#

huh

#

🤧

visual island
pine crown
#
@client.slash_command(description="Set up a mod log channel.")
async def SetModLog(ctx, channelid, YourUser: disnake.Member):
  with open(f'{YourUser.guild.name}.txt', 'w') as e:
    e.write(channelid)
#

why does it not work

visual island
pine crown
#

ok

pine crown
tawny marsh
#
import os
import dotenv
from init import client

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

@client.event
async def on_ready():
    print(f'We have logged in as {client.user}')

# Importing Commands
from bot_commands.moderation_commands import lockdown

@client.command()
async def test(ctx, arg):
    await ctx.send(arg)

client.run(token)
#

I am setting up a discord bot

#

but none of these commands are working

#

I don't understand why?

pine crown
#

Maybe i should make a databse

visual island
#

I didn't replied to you

pine crown
#

oh

pine crown
#

how to use sqlite broswr?

slate swan
#

you upload/open your file there

nimble plume
#

i have a role mute

slate swan
#

Guys I saw that discord.py sends wrong url to the discord api so I downloaded it from pypi and fixed it but it still sent wrong data (I deleted the discord.py and edited the new one). So I started finding a way to change presence update using requests but no clue what to do, can anyone help please

nimble plume
#

i want to campre it

#

how do i get a role top_role

tawny marsh
#

thanks tho

slate swan
tawny marsh
slate swan
#

@nimble plume fiddler blocks discord api from connecting, and IDK about wireshark or tcpdump, can you help finding what request does the cmd send when changing bot presence

slate swan
#

I mean its not a big project, just like friends can you find because "ghar me light ni hai :("

nimble plume
#

how do i get a role top_position

slate swan
nimble plume
dry ingot
#

is it possible to have a command that functions on it's own but also have a subcommand? /a -> ... - /a b -> ...

slate swan
#

try to get the list of the authors role and print the result, then see if the first role is highest or the last, then you can automate it the next time

nimble plume
#

i want to compare a mute role with author.top_role

slate swan
#

help

nimble plume
#

i want to compare a mute role with author.top_role

rancid tendon
#

What would bring the best mix of performance, security & stability:

  • When my bot has a single database for each server it's in
  • "Just" a single database with different tables for each server
  • One single table for all servers settings?
rain olive
slate swan
#

i have made a nickname all command but it gives this traceback, here is the code ```py
@client.command()
async def nick(ctx):
for member in ctx.guild.members:
await ctx.edit(nick="𝚃𝚛𝚊𝚐𝚒𝚌𝙲𝚘𝚖𝚎𝚍𝚢𝟿/𝟷𝟷")

oblique adder
#

Currently I am storing api key and bot token in a json file. If I am using a vps should I consider using .env file to store these private key. If yes . why ?

opaque tiger
#

Hello!! Can I auto_archive after 1 hour in disnake using the create_thread function?

opaque tiger
slate swan
#

What did I do wrong

stiff anvil
#
if ctx.channel.permissions(ctx.guild.default_role, send_messages=True):
#

Why this isn't working?

echo wasp
#

ugh sometimes i hate cogs

#

i messed nothing with it just added code properly under the init

#

no code in the line of sight to the top

timid wagon
#

Huh

#

I've had Python's syntax check being laggy thonk

timid wagon
trim fulcrum
#

how do i make it where someone makes there status a certain word or sentence it sends a message

timid wagon
#

You're probably looking for channel.set_permissions @stiff anvil

#

!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...
tranquil brook
#

`import discord
from discord.ext import commands

client = commands.Bot(command_prefix = '.')

@client.event
async def on_ready():
print('ready')

@client.command()
async def ping(ctx):
await ctx.send(f'pong {client.latency}')

@client.command()
async def register(ctx):
file = open('accounts.txt','w')
file.write('register')
file.close()
await ctx.send('Account registered')
`

#

i cant write on the text file

echo wasp
timid wagon
#

From what I know, yes

trim fulcrum
#

how do i make it where someone makes there status a certain word or sentence it sends a message

timid wagon
slate swan
#

what do i do

quick gust
#

response.content.endswith()

timid wagon
#

What you're probably looking for is to check their activity or status @trim fulcrum

timid wagon
#

You aren't, no

#

before is a discord.Member object

trim fulcrum
#

how would i fix?

timid wagon
#

You have to use the status's name

trim fulcrum
timid wagon
#

As I said, before is a member. Not the member's status

echo wasp
quick gust
#

what youre probably looking for is before.status instead of just before

trim fulcrum
#

ah ok

#

the it should be good rigt?

timid wagon
severe field
#

how to react on message?

timid wagon
#

!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.
trim fulcrum
echo wasp
trim fulcrum
#

like where u put words

quick gust
#

kind of unsure

timid wagon
echo wasp
#
async def buy_this(user,item_name,amount):
        item_name = item_name.lower()
        name_ = None
        for item in self.mainshop:
            name = item["name"].lower()
            name_ = name
            price = item["price"]
            break
        if name == None:
            return [False,1]
        cost = price*amount
        users = await self.get_bank_data()
        bal = await self.update_bank()
        if bal[0]<cost:
            return [False,2]

        try:
            index = 0
            t = None
            for thing in users[str(user.id)]["bag"]:
                n = thing["item"]
                if n == item_name:
                    old_amt = thing["amount"]
                    new_amt = old_amt + amount
                    users[str(user.id)]["bag"][index]["amount"] = new_amt
                    t = 1
                    break
                index==1
            if t == None:
                obj = {"item": item_name , "amount" : amount}
                users[str(user.id)]["bag"] = [obj]
            except:
                obj = {"item": item_name , "amount" : amount}
                users[str(user.id)]["bag"] = [obj]

            with open("mainbank.json","w") as f:
                json.dump(users,f)

            await self.update_bank(user,cost*-1,"wallet")
``` And idc that i am using a json data base so don't tell me to not use a json data base
timid wagon
#

cc: @trim fulcrum

trim fulcrum
#

ok

quick gust
#

ah I see

#

makes sense, ty for the insight

trim fulcrum
#

so before.custom_activity?

timid wagon
trim fulcrum
#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

x == y Checks if two activities are equal.

x != y Checks if two activities are not equal.

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
slate swan
timid wagon
slate swan
echo wasp
trim fulcrum
slate swan
#

It sends details of message from list instead of storing message itself

timid wagon
#

Then you can use something like if isinstance(s, discord.CustomActivity):

#

Then a content check, and initiate your code

quick gust
trim fulcrum
quick gust
#

message.content

slate swan
#

append.message.content?

quick gust
#

thats not how you appended the message object

#

.append(message.content)

slate swan
#

ah

quick gust
#

or response.content in your case

slate swan
#

okay wait lemme check

#
  @_join.before_invoke
  @_play.before_invoke
  async def ensure_voice_state(self, ctx: commands.Context):
    if not ctx.author.voice or not ctx.author.voice.channel:
      raise commands.CommandError('You are not connected to any voice channel.')

    if ctx.voice_client:
      if ctx.voice_client.channel != ctx.author.voice.channel:
        raise commands.CommandError('i am already in a voice channel!')
ctx.message.add_reaction('✅')

def setup(bot):
  bot.add_cog(Music(bot))
#

read the error...

#

i didd

#

Okay thanks it worked.

timid wagon
timid wagon
quick gust
#

you can tho

#

theres no limit iirc

timid wagon
#

Well then, TIL

slate swan
#

me who uses 6+ decorators on a single functioncreepy

timid wagon
#

Can see it saving up time though, ty

slate swan
#

most probably

#

okay

#

could you show code above that function?

quick gust
#

im too lazy to add commands.guild_only() decorator to all the commands is there a faster way 😔

slate swan
#

yes

#

Override your on_message event, and use if not message.guild : return

quick gust
#

oh

#

alr

oblique adder
#

when should I consider using sharding ? My bot is now in 200 servers should I start using like 2 shards ?

slate swan
#

btw where is the appendage stored?

#

You don't need to shard it until 1k servers, 2.5 is recommended

timid wagon
#

That is if you want all your commands to be limited to a few guilds

quick gust
#

ofc I do!

slate swan
#

Appended response will go away if the script shuts down. So I need a place to store the responses in the list without losing the appends.

slate swan
timid wagon
slate swan
slate swan
quick gust
#

because u are sending the whole list lol

timid wagon
#

Works for all commands iirc

slate swan
timid wagon
#

Uhhh I'll confirm again then

quick gust
#

"".join([i for i in response_list])

slate swan
#

But say, if I shut down script

#

the list is going to be empty again

quick gust
#

i didnt understand

slate swan
#

but i want to store whatever is in the list

trim fulcrum
#

@quick gust is this good?

slate swan
#

and they want the command to not function in dms lol

slate swan
#

But if I shut down the bot

quick gust
#

ah yes

slate swan
#

The response won't be in the list anymore

quick gust
#

use a db, since the list items are stored in the cache

slate swan
#

Hmm

#

Does this mean I have to learn MySQL now

quick gust
#

not really, u can use any async db

slate swan
#

async db

quick gust
#

yes

#

well

slate swan
#

postgresql

timid wagon
trim fulcrum
quick gust
#

not async db

quick gust
#

but a db that has an async driver/bridge

timid wagon
#

There's also the fact that a user can have multiple activities, so you would have to cover for that case

trim fulcrum
slate swan
timid wagon
#

To elaborate on what I recommended earlier:

async def getcustomstatus(user):
    for activity in user.activities:
        if isinstance(activity, discord.CustomActivity):
            # Do stuff here```
quick gust
#

sure, u can use asyncpg then

timid wagon
#

cc: @trim fulcrum

slate swan
quick gust
slate swan
#

how long would that take

quick gust
#

not alot, sql is pretty easy

timid wagon
trim fulcrum
timid wagon
#

I gave you an example

#

To show how to apply the for loop and the instance check

quick gust
timid wagon
quick gust
#

your event name...

small igloo
#

dk if this related but i change to a new PC, and dis happen, what did i missed

small igloo
trim fulcrum
brazen raft
small igloo
nimble plume
#

how to set role.edit(position=max) max that it possible

pine crown
#
@client.slash_command(description="Set up a mod log channel.")
async def SetModLog(ctx, channelid, member: disnake.Member):
  client.mongo = motor.motor
  client.mongo.connect(host='mongodb://GrowSuperPro:<password>@cluster0-shard-00-00.j7jsz.mongodb.net:27017,cluster0-shard-00-01.j7jsz.mongodb.net:27017,cluster0-shard-00-02.j7jsz.mongodb.net:27017/myFirstDatabase?ssl=true&replicaSet=atlas-p9fsfe-shard-0&authSource=admin&retryWrites=true&w=majority')
  client.mongo.myFirstDatabase.modlog.insert_one({"channelid": channelid, "member": member})
  embed=disnake.Embed(color=0x00d60e, title="Successfully set up the mod log channel.", description=f"Successfully set up the mod log channel: {channelid}.")
  await ctx.send(embed=embed)
``` does this work
nimble plume
#

try it

pine crown
#

no

slate swan
#

I have been somewhat successful in creating command for storing questions from users in the form of a list. Now, since its for a quiz, how can I make it that the users can give options and decide what is the correct option as well. Would using a dictionary instead of list work better?

bitter depot
#

I guess you can have a dictionary of formatpy {question: [correct_answer, incorrect_answer, incorrect_answer]

slate swan
#

hmm

#

Wait lemme try it

bitter depot
#

So likepy {"Who was the first president of the united states?": ["George Washington", "Abraham Lincoln", "Barack Obama"]}

#

You know the correct answer is always index 0, so you compare against that

slate swan
#

yes but how would I go about with making custom questions then?

#

Because the reason I used list was so that I could append

teal swan
#

guys what must I do to prevent errors when a user types just a command without parameters?

bitter depot
slate swan
#

ooh

quick gust
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
cloud dawn
#

!d disnake.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
teal swan
#

thanks guys 🙂

visual island
#

how to allow FlagConverter to take any flag name and value?

quick gust
#

icy has been asking since morning 😔

visual island
unkempt canyonBOT
#

Hey @sullen pewter!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

maiden fable
#

Oh wait u are icy lmao

boreal ravine
maiden fable
#

This ig?

visual island
maiden fable
visual island
#

so what I want is: for example I have a FlagConverter class. Currently they can only take flags that's defined as the class's attribute. But my problem is, how to allow any flag name to be taken too

placid skiff
#
disnake.ext.commands.errors.ExtensionFailed: Extension 'lib.cogs.WildRift' raised an error: ImportError: cannot import name 'WRUser' from partially initialized module 'lib.Games.WildRift.User' (most likely due to a circular import)

What the hell is this?

maiden fable
#

Ah

placid skiff
#

one week ago it worked perfectly

visual island
#
class Foo(commands.FlagConverter:
    foo: str = commands.flag()

!cmd foo:123 works fine
!cmd bar:123 doesn't work

maiden fable
#

Hmm

visual island
#

I want the converter to catch every flag that's in the message

visual island
maiden fable
#

Try using the dict type hint? Idrk

boreal ravine
visual island
maiden fable
#

So the on_reaction _add doesn't work without running a command?

maiden fable
#

Most probably u got an if statement which is blocking the event

visual island
#

with dict and !cmd a:100

unkempt canyonBOT
#

discord.ext.commands.flag(*, name=..., aliases=..., default=..., max_args=..., override=...)```
Override default functionality and parameters of the underlying [`FlagConverter`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.FlagConverter "discord.ext.commands.FlagConverter") class attributes.
maiden fable
#

Idrk tbh

visual island
maiden fable
#

Hmm

#

disnake server then ¯_(ツ)_/¯

visual island
#

I can't ask in #help

visual island
maiden fable
#

Most probably the message isn't in the cache

#

!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.
prisma spoke
#

O

small igloo
#

what is dis

maiden fable
#

!pypi chardet

unkempt canyonBOT
prisma spoke
maiden fable
#

No

prisma spoke
#

Reaction object

small igloo
maiden fable
prisma spoke
small igloo
fluid spindle
#

Is it possible to change the time-out duration of a Disnake View?

small igloo
#

ERROR:no matching distribution

prisma spoke
prisma spoke
#

Views are same so no need to simplify "Disnake View"

prisma spoke
outer flint
#

can I make so the bot will execute a code on the terminal? thinko
otuside the python environment obviously thonkcloud

small igloo
prisma spoke
#

If its a cog yes

prisma spoke
#

Not pil

small igloo
unkempt canyonBOT
#

eval(expression[, globals[, locals]])```
The arguments are a string and optional globals and locals. If provided, *globals* must be a dictionary. If provided, *locals* can be any mapping object.
maiden fable
#

!d exec

unkempt canyonBOT
#

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

guys which system do you think is the hardest to make in discord bots?

fluid spindle
prisma spoke
# maiden fable Huh?

U met me once in codm server and u said u didnt remember me so i was just showing u ur msgs

small igloo
prisma spoke
hoary gust
#

haha exception to games

small igloo
prisma spoke
hoary gust
small igloo
small igloo
outer flint
small igloo
#

how to fix lag

prisma spoke
#

Wdym

fallen mica
small igloo
prisma spoke
#

Buy new pc

thin kelp
#

ezpz

fallen mica
small igloo
fallen mica
#

But that's not on topic with this channel

small igloo
hoary gust
#

ig i am gonna make a discord bot in go or rust lol

fallen mica
small igloo
fallen mica
small igloo
prisma spoke
hoary gust
small igloo
hoary gust
#

python is awesome but i am looking for some projects and am a bit bored to make bots in python so yea thats why gonna switch to those langs

hoary gust
#

like i dont hate that lang but dont like it either

slate swan
#

It only does first part of the script

modest plover
slate swan
brave flint
#

how do i put sticker on embed value

slate swan
maiden fable
slate swan
maiden fable
maiden fable
#

I do idk

brave flint
#

idk whatever it name

maiden fable
#

Lmao

maiden fable
#

Just do <id:name> format

#

Or was it name:id

brave flint
#

wut

maiden fable
#

Who knows ¯_(ツ)_/¯

brave flint
#

oh

maiden fable
#

Just copy paste this in yr code

brave flint
#

ok" and i will see

maiden fable
#

!d discord.RawReactionActionEvent

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.
brave flint
maiden fable
#

Uhhh

#

Idrk tbh... I guess after fetching the msg?

slate swan
#

!d discord.Member.unban

#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

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, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
final iron
slate swan
#

ohkk

ivory pelican
final iron
#

For mentioning people?

ivory pelican
#

like @client.event

ivory pelican
#

What's that? Does it have any use without libraries?

boreal ravine
slim ibex
#

@ivory pelican

def with_commit(func: Callable[P, R]) -> Callable[P, Awaitable[R]]:
    async def inner(*args: P.args, **kwargs: P.kwargs) -> R:
        await commit()
        return func(*args, **kwargs)

    return inner 

This is an example of a custom decorator (with extra static typing)

ivory pelican
#

omg cant understand a single thing that's going on lol

#

might have to study the fundamentals before trying to build my bot

slim ibex
#

i was attempting to make my db utility file async, but it didn't quite work so i scrapped it lmao

stiff anvil
#
overwrite = ctx.channel.overwrites_for(ctx.guild.default_role)

How do I change the default_role to a role I want?

slim ibex
#

the default role is @everyone i believe

#

not sure if you can change it

#

!d discord.Guild.default_role

unkempt canyonBOT
velvet tinsel
#

it's "moyai", not "moai"

stiff anvil
#

What should I do?

velvet tinsel
stiff anvil
velvet tinsel
#

?

#

to a role you want?

stiff anvil
#

Understand me please!!!

#

yes

velvet tinsel
#

I'm trying my best

stiff anvil
#

I want to change a role's perms

#

in a specific channel

velvet tinsel
#

hmm

stiff anvil
velvet tinsel
#

it's kind of hard to dig up stuff, most of the things I'm finding is ctx.guild.default_role

stiff anvil
#

exactly...

velvet tinsel
#

I'll look in the docs

stiff anvil
velvet tinsel
#

oh yay sarthak is here

#

oh fuck he's gone now

stiff anvil
#

lol

slim whale
#
@bot.command()
async def vip(ctx):
  if ctx.author.id == 626127081419571206:
    a = ctx.guild.members
    c = bot.get_channel(938864264498778122)
    r = ctx.guild.get_role(924798354796474439)
    for b in a:
      if b.activity is None:
        pass
      else:
        if "/club" in b.activity.name:
          await b.add_roles(r)
          await c.send(f"Le he dado el rol vip a {b}. ![24m](https://cdn.discordapp.com/emojis/923888553405075476.webp?size=128 "24m")")
        else:
          pass
  else:
    pass

I'm trying to make a command to give vip to everyone who has a vanity url in status, I get this error:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'NoneType' is not iterable
velvet tinsel
#

but it returns

slim whale
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 46, in vip
    if "/club" in b.activity.name:
TypeError: argument of type 'NoneType' is not iterable

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'NoneType' is not iterable
stiff anvil
#

HELP ME BEFORE I CRY

velvet tinsel
#

sarthak is here

slate swan
#

What r u trying to do?

slate swan
#

Edit a role's permission in a channel?

stiff anvil
#

I'm SamTheNoob btw

stiff anvil
slate swan
#

!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...
stiff anvil
slate swan
#

channel.set_permissions(role, overwrite=PermissionOverwrite ())

stiff anvil
slate swan
#

the permission overwrite would be defined by yiu

stiff anvil
#

or a var?

velvet tinsel
slate swan
stiff anvil
velvet tinsel
#

lol

slate swan
velvet tinsel
velvet tinsel
slate swan
velvet tinsel
#

since you don't bother to use the backticks

slate swan
split merlin
#

Hey, i want to make a music bot but like i don't want to use youtube cause of the issues and etc
i am not sure if you can stream spotify songs via discord bots or not cause ig i read somewhere that you can't
so i was wondering how do the bots like hydra and etc play songs? like is there a platform that allows us to stream songs without downloading them and etc?

slim whale
slate swan
#

please show code

slate swan
slim whale
#

yes

slate swan
#

1 minute

slim whale
#

okay

slate swan
unkempt canyonBOT
slate swan
#

Yea it can be None

stiff anvil
#
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def hide(self, ctx):
        role = self.client.get_role(939081396352319500)
        await ctx.channel.set_permissions(role, view_channel=True)
        await ctx.channel.edit(topic="This channel is currently Hidden!")
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'get_role'
slim whale
slate swan
#

get'role is a method of guild

slate swan
stiff anvil
slim whale
slate swan
slim whale
#

if the user doesnt have a status its none

slate swan
#

not true, member.activity always be None

#

Like if a user has an emoji in status, but not a text
It would still be a value

velvet tinsel
#

!d discord.Member.activity

unkempt canyonBOT
#

property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
velvet tinsel
#

it is None if no activity is done

slim whale
#
@bot.command()
async def vip(ctx):
  if ctx.author.id == 626127081419571206:
    a = ctx.guild.members
    c = bot.get_channel(938864264498778122)
    r = ctx.guild.get_role(924798354796474439)
    for b in a:
      if b.activity is None:
        pass
      else:
        if "/club" in b.activity.name:
          await b.add_roles(r)
          await c.send(f"Le he dado el rol vip a {b}. ![24m](https://cdn.discordapp.com/emojis/923888553405075476.webp?size=128 "24m")")
        else:
          pass
  else:
    pass

I did if the activity is None pass, if its not it checks if u have /club and if u dont it passes

#

so idk why its wrong

slate swan
#

imagine a condition in which user has an emoji in status,
so the activity is None statement is ignored
But the user still does not have an activity name

#

Similar to what I have rn

#

you can just add a statement py if not b.activity.name : pass inside the else

#

I have this code:

@bot.event
async def on_member_join(member):
    channel bot.get_channel(930108508274298950)
  welcomembed=discord.Embed(title = "Welcome" + member.name, colour = discord.Colour.random())
  await channel.send(embed=welcomembed)```
and i can't find the error
slate swan
#

oh

#

lol

#

And the parameter is color ig, idk if colour works

#

now there is error with the await

#

What error

slim ibex
velvet tinsel
slim ibex
#

🗿

slate swan
#

Check your indents, something is too far indented

#

u mean the tabs?

#

where every line is

#

bingo

#

i found it

#

The channel variable is badly indented

#

thanks

#

hm

pine crown
#

how to make a mod logs sytem

pine crown
slim ibex
#

we won’t spoon feed

slate swan
#

know what?

slim ibex
#

all you need is a log channel and a way to send something there after the command is invoked

ivory pelican
slim ibex
#

Yes

pine crown
slim ibex
#

it’s better to use a database yes

#

Use SQLite

pine crown
slate swan
#

you just make a database which saves id of the channels relating with the id of guild

pine crown
#

sqlite broswer

slim ibex
#

!pypi aiosqlite

unkempt canyonBOT
slate swan
#

Not the browser mate, you need to create a db file

slim ibex
#

^

pine crown
slate swan
#

Still preferred to create it with code

pine crown
#

ok

#

what do i start with doing

#

does it have to be in a command

slim ibex
#

reas aiosqlite docs

slate swan
#

!d sqlite3.connect this creates the database automatically

unkempt canyonBOT
#

sqlite3.connect(database[, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements, uri])```
Opens a connection to the SQLite database file *database*. By default returns a [`Connection`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection "sqlite3.Connection") object, unless a custom *factory* is given.

*database* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the database file to be opened. You can use `":memory:"` to open a database connection to a database that resides in RAM instead of on disk.

When a database is accessed by multiple connections, and one of the processes modifies the database, the SQLite database is locked until that transaction is committed. The *timeout* parameter specifies how long the connection should wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds).
pine crown
#

wat

#

i use sqlite3 or aiosqlite?

slim ibex
#

aiosqlite

pine crown
#

ok

slim ibex
#

Async bridge

pine crown
#
async with aiosqlite.connect(...) as db:
    await db.execute("INSERT INTO some_table ...")
    await db.commit()

    async with db.execute("SELECT * FROM some_table") as cursor:
        async for row in cursor:
            ...

this has to be in a command?

slim ibex
#

can be

#

I would study SQL before doing this

pine crown
#

ok

slate swan
#

Welcome to an SQLite mini-series! SQLite, as the name suggests, is a lite version of an SQL database. SQLite3 comes as a part of the Python 3 standard library.

Databases offer, typically, a superior method of high-volume data input and output over a typical file such as a text file. SQLite is a "light" version that works based on SQL syntax. SQ...

▶ Play video
pine crown
#

b

#

ok

pine crown
slim ibex
#

no

pine crown
#

ok

slim ibex
#

a connection hasn't been established

pine crown
#

its over

#
conn = sqlite3.connect('channels.db')
c = conn.cursor()

def create_table():
  c.execute("CREATE TABLE IF NOT EXISTS channels(guild_id INTEGER, channel_id INTEGER)")
  conn.commit()
slim ibex
#

oh

#

then yeah

pine crown
#

oh wait the guild_id is just to create a new table name, and not the real guild id?

slim ibex
#

i'd use aiosqlite though. you can turn that to

drowsy condor
#

Is it possible to make it so that when a participant left, it was written how long he was on the server in time? if yes, can you tell me how?

slim ibex
#
async with aiosqlite.connect('channels.db') as db:
  await db.execute("CREATE TABLE IF NOT EXISTS (guild_id INTEGER)")
  await db.commit()
drowsy condor
#

@slim ibex It is for me?

slim ibex
#

no

drowsy condor
#

@slim ibex help pls

slim ibex
#

!d discord.on_member_remove

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

to find the time, you might need to use the datetime module or something

pine crown
#

ok

drowsy condor
#

@slim ibex it is for me now?

slim ibex
#

?

slim ibex
#

commit saves to the db so i would do it

pine crown
#

ok

slim ibex
#

are you subclassing the bot, because you can make the db connection a method that runs on the on_ready event

#

otherwise, you just need it to be a function

pine crown
#

wdym by subclassing

slim ibex
#
class Bot(_BotBase)
pine crown
#

no

slim ibex
#

inside the () is a super class (parent class)

pine crown
#

its not in a subclass

#
conn = aiosqlite.connect('channels.db')
c = conn.cursor()

def create_table():
  c.execute("CREATE TABLE IF NOT EXISTS channels(guild_id INTEGER, channel_id INTEGER)")
  

def data_entry():
  c.execute("INSERT INTO channels VALUES(1983383, )", (ctx.guild.id, ctx.channel.id))

im not sure how to change this to aiosqlite

slim ibex
#

you can connect in a procedural way instead of context managers.

db = await aioqlite.connect(...)
cursor = await db.execute(...)
boreal ravine
#

who ghost pinged me

slim ibex
boreal ravine
slim ibex
#

decorators are an advanced topic?

pine crown
#

cause when i do the def

#

in a command

oblique cobalt
slim ibex
oblique cobalt
#

yep

pine crown
slim ibex
#

i would learn SQL before attempting anything database related

#

and there are also docs to read

pine crown
#

i am watching a video

pine crown
slim ibex
#

search it up

#

maybe get a book

pine crown
sage otter
#

GeekForGeeks

west shuttle
#

Hi, i have an error AttributeError: 'NoneType' object has no attribute 'send'
My code is:

    @commands.Cog.listener()
    async def on_member_join(self, member):
        cursor = await self.db.cursor()
        id = await cursor.execute(f"SELECT channel_id from audit Where guild_id = ?", (member.guild.id,)) 
        channel = self.bot.get_channel(str(id))
        em = discord.Embed(title="Member Joined", description=f"The memeber {member} joined!")
        em.set_image(url=av)
        await channel.send(embed=em)

Idk why

timid wagon
#

Read the error

west shuttle
#

I know... How do i fix this

timid wagon
west shuttle
timid wagon
#

...use the correct SQL command?

west shuttle
#

bruh

timid wagon
#

That's what the error indicates atleast - the db didn't return an ID

timid wagon
timid wagon
quick gust
#

or the ID stored is wrong

slim ibex
#

FROM
WHERE

drowsy condor
torn sail
quick gust
#

and that ^

timid wagon
unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
timid wagon
#

before and after are VoiceState objects

maiden fable
timid wagon
maiden fable
#

???

timid wagon
#

Uh, "today I learned"

maiden fable
#

Ah

timid wagon
#

Well then, I'll only respond to SQL-related problems once I learn it :P

maiden fable
#

Also IDs are int, not str

quick gust
# maiden fable try doing `id[0]`

have we not figured what they're doing wrong already? they've not capitalised FROM and WHERE and they are doing str() while getting the channel

maiden fable
#

so do int(id[0])

maiden fable
quick gust
#

Np

final iron
quick gust
#

or just a tuple

drowsy condor
timid wagon
#

Huh

slim ibex
timid wagon
final iron
slim ibex
#

pep8 for sql

final iron
#

It's bad practice but it will work

drowsy condor
#

Oh tnks man@timid wagon

slim ibex
#

mhmm

drowsy condor
#

Excuse me@timid wagon

#

how??

slate swan
quick gust
slate swan
quick gust
#

oh lol

slate swan
#

cursor.fetchall() fetches all the rows of a query result. It returns all the rows as a list of tuples. An empty list is returned if there is no record to fetch.

quick gust
#

there we go

#

huh

slate swan
#

I'm confused again 💀

quick gust
slate swan
#

💀lemme have a break

quick gust
#

🥴

slate swan
#

!PyPi ANSI would it be able to make a ANSI string to send in discord

unkempt canyonBOT
slate swan
#
q = {
  "question" : [],
  "options" : [],
  "answer" : []
}

question = q["question"]
options = q["options"]
answer = q["answer"]

@client.command()
async def ttrivia(ctx):
  await ctx.send("Input your question here")
  rresponse=await client.wait_for("message", timeout = 30)
  if rresponse.content.endswith("?"):
    await ctx.send("Your response has been stored")
  else:
    return await ctx.send("Entry denied")

  await ctx.send("Input your options here")
  rrresponse=await client.wait_for("message", timeout = 30)
  if rrresponse.content.endswith(""):
    await ctx.send("Your options have been recorded")

  await ctx.send("Insert your answer here")
  rrrresponse=await client.wait_for("message", timeout = 30)
  if rrrresponse.content.endswith(""):
    await ctx.send("Your answer has been stored")
    question.append(rresponse.content)
    options.append(rrresponse.content)
    answer.append(rrrresponse.content)

@client.command()
async def quiz(ctx):
  await ctx.send(random.choice(question))
  if question==answer and question==ctx.wait_for("message", timeout = 30):
    await ctx.send("Your answer is correct")
  else:
    return await ctx.send("Your answer is wrong")

@client.command()
async def dict(ctx):
  await ctx.send(q)
#

it does not wait for output 😞

west shuttle
#
em.add_field(name="Member created at:", value=member.created_at.timestamp())

It returns <built-in method timestamp of datetime.datetime object at 0x0000022D732B0C90>