#discord-bots

1 messages ¡ Page 471 of 1

hoary fog
#

how to fix it

spring flax
#

give the code and traceback

willow vine
#

oh wait nvm i forgot to give the bot the role

#

sorryy :/

spring flax
#

Lol

summer jungle
valid perch
#

Whats in music_bot?

valid perch
slate swan
dense swallow
#

the perm is unused?

#

or should i put that in the embed field

drifting arrow
#

yay my fun facts bot is basically g-2-g 😄

hasty iron
#

g2g?

silver wolf
maiden fable
dense swallow
silver wolf
#

show ur code

dense swallow
#
perms = []
        full_perms = member.guild_permissions
        key_perms = {
            'administrator': 'Adminstrator',
            'ban_members': 'Ban Members',
            'kick_members': 'Kick Members',
            'manage_guild': 'Manage Server',
            'manage_channels': 'Manage Channels',
            'view_audit_log': 'View Audits',
            'manage_messages': 'Manage Messages',
            'manage_nicknames': 'Manage Nicknames',
            'manage_roles': 'Manage Roles',
            'manage_permissions': 'Manage Permissions',
            'manage_webhooks': 'Manage Webhooks',
            'manage_emojis': 'Manage Emojis',
            'mention_everyone': 'Mention Everyone',
            'deafen_members': 'Deafen Members',
            'mute_members': 'Mute Members',
            'move_members': 'Move Members',
        }

        for permissions, user_perms in key_perms.items():
            if user_perms is True:
                perms.append(user_perms)
if perms:
            em.add_field(name='Key Permissions', value=', '.join(permissions), inline=False)
silver wolf
#
  • key_perms needs to be removed. and its in full_perms
  • permissions is what needs to be appended
hasty iron
#

you don’t need a dict you could just get the name of the permission, strip _ from it and call title on it

#

actually replace _ with a space

dense swallow
#

i think this is easier?

hasty iron
#

your method is not easier

dense swallow
#

this is what i did for server features

hasty iron
#

my method can get you the permissions in a simple list comp

#

no dict needed

hoary fog
#

yes

silver wolf
#

no, just full_perms

dense swallow
#

ok so should i change key_perms to what blanket said?

silver wolf
#

"perm" is the permission as a string. so u need to add the "perm" to a list

#

key_perms needs to be removed entirely. its not needed

dense swallow
#

my vars are different..

silver wolf
#

so change them accordingly...

dense swallow
#

is this needed

perms = []
silver wolf
#

yeah. thats where the string representation of the permissions will be stored

dense swallow
#
        perms = []
        full_perms = member.guild_permissions

        for permissions, value in full_perms:
            if value is True:
                perms.append(permissions)
silver wolf
#

exactly. that should work

#

then ull have to use str.title() like blanket said and remove the _

dense swallow
#

wtf lmfao

silver wolf
#

lmao. whatever u did...is not right LUL

dense swallow
#
perms = []
        full_perms = member.guild_permissions

        for permissions, value in full_perms:
            if value is True:
                perms.append(permissions)

if perms:
            em.add_field(name='Key Permissions', value=', '.join(permissions), inline=False)
valid perch
#

Why are you not joining perms?

dense swallow
#

oop

silver wolf
#

yeah. wrong variable

dense swallow
#

works now.. but there are some unwanted perms i want to remove... thats why i did the whole key_perms thing

slate swan
hoary fog
hasty iron
#

you still didn’t replace nor title the string

valid perch
silver wolf
hoary fog
summer jungle
#

How do you make your discord bot know when you've reacted to a message?

dense swallow
#

on_reaction_add

hoary gust
vale root
hoary gust
vale root
#

Well

#

Im not to good but is that what your trying to do?

hoary gust
vale root
#

everyone from what a website?

slate swan
#

That will fix your problem

round yarrow
#
import discord
from discord.ext import commands


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

    @commands.command()
    async def gunsmith(ctx, gun : str = None):

      if gun == None:
          await ctx.send(f"Please mention a gun, {ctx.author.mention}!")
      if gun == "kn44":
          embed = discord.Embed(
            title = ("KN44 GUNSMITH"),
            description = ("KN44"),
            colour = discord.Color.blue())
          embed.set_footer(text= "Gunsmith Credit : BLOOD OK#0588"),
          embed.set_thumbnail(url="https://pasteboard.co/Kiqk3UW.png")
          embed.set_image(url="https://media.discordapp.net/attachments/879390150227025921/882461739051012186/image0.png?width=904&height=678")
          await ctx.send(embed=embed)

def setup(bot):
    bot.add_cog(Gunsmith(bot))```
Where hv i gone wrong in intendation.
maiden fable
#

Ah hey there NotBugcat haha

sick talon
#

how to make a eval command
i wanted to make a command if i use ?eval ctx.send("hi") the bot should send hi

sick talon
maiden fable
#

Ah an eval

#

!d eval

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.10/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” in the Reference Manual). Be aware that the [`nonlocal`](https://docs.python.org/3.10/reference/simple_stmts.html#nonlocal), [`yield`](https://docs.python.org/3.10/reference/simple_stmts.html#yield), and [`return`](https://docs.python.org/3.10/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.10/library/functions.html#exec "exec") function. The return value is `None`.
maiden fable
#

u will have to use these

#

Also you will want to see R. Danny's eval

sick talon
#
@client.command(name='eval')
async def eval(ctx, *, arg:str):
  result = exec(arg)
  await ctx.send(result)

I have tried this but i am getting this error

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
maiden fable
lament mesa
maiden fable
#

Ah u saying that so that the code is evaluated in the physical console?

#

And not a virtual one?

#

cz I don't use those

lament mesa
maiden fable
#

cool. I don't think I am using those as of now tbh

abstract shoal
#

anyone know how to integrate twitch api to announce on discord when someone goes live?

lament mesa
#

!e ```py
import io
import contextlib

stdout = io.StringIO()

with contextlib.redirect_stdout(stdout):
exec("print('test')")

print(f"Values printed: {stdout.getvalue()}")```

unkempt canyonBOT
#

@lament mesa :white_check_mark: Your eval job has completed with return code 0.

Values printed: test
maiden fable
#

Hmm cool

round yarrow
sick talon
#

@lament mesa i am getting this error

discord.ext.commands.errors.UnexpectedQuoteError: Unexpected quote mark, '"', in non-quoted string```
#
@client.command()
async def evalo(self, ctx, *, body: str):
  stdout = io.StringIO()
  with contextlib.redirect_stdout(stdout):
    exec("body")
  print("Eval runned: {stdout.getvalue()}")

i am pretty new to this eval thing 😓

lament mesa
#

how did you invoke the command?

#

and exec("body") is wrong

round yarrow
#
import discord
from discord.ext import commands


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

    @commands.command()
    async def gunsmith(ctx, gun : str = None):

      if gun == None:
          await ctx.send(f"Please mention a gun, {ctx.author.mention}!")
      if gun == "kn44":
          embed = discord.Embed(
            title = ("KN44 GUNSMITH"),
            description = ("KN44"),
            colour = discord.Color.blue())
          embed.set_footer(text= "Gunsmith Credit : BLOOD OK#0588"),
          embed.set_thumbnail(url="https://pasteboard.co/Kiqk3UW.png")
          embed.set_image(url="https://media.discordapp.net/attachments/879390150227025921/882461739051012186/image0.png?width=904&height=678")
          await ctx.send(embed=embed)

def setup(bot):
    bot.add_cog(Gunsmith(bot))```
Where hv i gone wrong in intendation.
maiden fable
#

bro u still have it

#

the comma smh

lament mesa
#

and this line embed.set_image(...)

sick talon
round yarrow
boreal ravine
#

imagine using bot

sick talon
hasty iron
#

why is there self in the command args

lament mesa
trim frigate
#

hey guys i is anyone has a bot info code?

lament mesa
#

it needs to be awaited

sick talon
sick talon
lament mesa
#

sorry i dont know

sick talon
valid niche
#

client.command shouldn't be able to exist according to naming conventions

#

since discord.Client.command doesn't exist

#

commands.Bot.command exists, and commands.Bot should be named 'bot' for the instance

#

naming conventions are very important

valid niche
#

exactly

#

client = implies you use discord.Client

#

you use commands.Bot

#

according to correct naming you should be doing bot = commands.Bot

wicked jackal
#
#GRAPH
def graph(formula, x_range,plot='normal'):
    fig, ax = plt.subplots()
    
    x = np.array(x_range)
    y = eval(formula)
    if plot =='normal':
        ax.plot(x, y,label=f'y = {formula}')
    ax.legend()
    ax.grid()
    fig.savefig('figure.png') 
def graphIt(x=100,formula='x**3'):
    graphing_calc(formula.replace(" ","").replace("^","**").replace('y','x'),np.linspace(-x,x))
# class study(commands.Cog):
        
  @client.command()
    async def graph(self,ctx,*,args):
      file = discord.File("figure.png")
      if 'range' in args:
        arg=args.split('range')
        print(arg)
        graphIt(formula=arg[0],x=int(arg[1]))
      else:
        graphIt(formula=args)
      e = discord.Embed()
      e.set_image(url="attachment://figure.png")
      await ctx.send(file=file,embed=e)```can someone poitn out the error
wicked jackal
#

@valid niche

boreal ravine
valid niche
#

indentation

lament mesa
#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

boreal ravine
#

It does?

valid niche
#

pep 8

sick talon
valid niche
#

also get any random bit of code. doesn't have to be a discord bot. Name EVERY variable Xn with n being a random number

#

and then wait until you get a bug

#

good luck debugging that

wicked jackal
#

ok

valid niche
#

this is the same principle with client/bot

boreal ravine
#

What bug exactly

valid niche
#

but there's PEP 8 saying to follow correct naming convention

#

you did NOT follow correct naming conventions

#

client = discord.Client

bot = commands.Bot

#

that's correct naming

sick talon
waxen granite
#

!d discord.on_guild_remove

unkempt canyonBOT
#

discord.on_guild_remove(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild") is removed from the [`Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client").

This happens through, but not limited to, these circumstances...
tardy swallow
#

I have a problem with music bot:

@commands.command()
async def pause(self, ctx):
  await ctx.voice_client.pause()
  await ctx.send('Paused')

This command works, it pauses the audio but it won't send the message.

I see this in console: Command raised an exception: TypeError: object NoneType can't be used in 'await' expression

hasty iron
#

dont await it

surreal sierra
#

How do you put a delay after a command so the command cant be spammed, is it not just await asyncio.sleep(5) at the last line of the command?

hasty iron
#

use cooldowns

#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/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/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

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

A command can only have a single cooldown.
surreal sierra
#

thats for me?

hasty iron
#

yes

surreal sierra
#

oh okay XD thanks

tardy swallow
hasty iron
#

its the type of None

surreal sierra
#

but why does asyncio not work in this case?

hasty iron
#

!e ```py
print(type(None))

unkempt canyonBOT
#

@hasty iron :white_check_mark: Your eval job has completed with return code 0.

<class 'NoneType'>
waxen granite
#

can we check if the bot was kicked/left/banned for a guild?

hasty iron
#

dont think so

high flame
#

or wait

waxen granite
#

from the guild i am not in but my bot was kicked

high flame
#

it's the bot

boreal ravine
unkempt canyonBOT
boreal ravine
#

!d discord.AuditLogAction

unkempt canyonBOT
#

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

Oh sorry I thought he meant the audit log actions

visual island
#

huh

slate swan
#

not working whaiii??

visual island
#

on_guild_remove exists?

slate swan
#

How can my bot send automatic messages every 10 minutes? Python

slate swan
#

common

slate swan
#

make it

#

its ok search reminder command and watch on youtube

#

help meeeeeeee

#

its not working

boreal ravine
hasty iron
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
boreal ravine
slate swan
#

so i learn and then

boreal ravine
slate swan
visual island
#

user would definitely works

boreal ravine
#

I mean

slate swan
#

?

high flame
#

6 indents is weird

boreal ravine
#

Use 4 spaces for indents

slate swan
slate swan
high flame
slate swan
high flame
#

just use member.name and member.discriminator, or you can just do if user.id == member.id

high flame
slate swan
#

to discriminator

#

or name??

high flame
#

!e ```py
user = "test#test#8377"
user_name, user_discriminator = user.split("#")
print(user_name, user_discriminator)

unkempt canyonBOT
#

@high flame :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | ValueError: too many values to unpack (expected 2)
slate swan
#

?

high flame
#

this is what you'll get if a user had # in their name

#

meh bye

#

i need to do smth pithink

ionic ledge
#

can one bot delete the msg of other bot , if yes then how?

high flame
#

and then delete it like you do to a user message

valid niche
#

Like the bot isn't in a voice channel when using the command

ocean leaf
#

What is this?? :\

spring zealot
#

too large field value

#

reduce the size of ur field value

boreal ravine
#

Read da error

ocean leaf
spring zealot
#

wat

ocean leaf
#

means? all are long?

spring zealot
#

no wait

boreal ravine
#

what command did u use

visual island
#

5th field

ocean leaf
#

i have changed it to len()

spring zealot
#

on the values themselves

ocean leaf
#

yes i changed it to len() and it worked

#

thanks

boreal ravine
#

yes len returns the amount of things in a list or a dict etc

visual island
#

in an iterable*

fading harness
#

i ask the bot for joining my voice channel, but the conssole say this. i add import PyNaCl but they say that there isnt any module named PyNaCl. I am using repl.it. what should i do now>

hasty iron
#

install it

#

and the module to import is nacl

fading harness
#

yee thanks

hasty iron
#

and you dont have to import it

fading harness
#

yee thanks. why does the replit doesnt have that???

#

it work.

bitter perch
#

because repl sucks.

valid niche
brazen seal
#

Why my if isn't work when letter is big?

valid niche
#

and python is case sensitive

#

so you need to make your word you want to check also lowercase

fading harness
brazen seal
visual island
#

nah

valid niche
visual island
#

!d str.lower

unkempt canyonBOT
#

str.lower()```
Return a copy of the string with all the cased characters [4](https://docs.python.org/3.10/library/stdtypes.html#id15) converted to lowercase.

The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
brazen seal
#

hm

surreal sierra
#

Does anyone know why it fails opening the JSON file? it prints "Could not load amounts.json" but I have made a json file named to "amounts.json" in the same place as the code it self but it still doesn't find it.

@bot.event
async def on_ready():
    global amounts
    try:
        with open('amounts.json') as f:
            amounts = json.load(f)
    except FileNotFoundError:
        print("Could not load amounts.json")
        amounts = {}
valid niche
brazen seal
valid niche
#

or in this case it 's your own error

visual island
valid niche
#

dpy is extremely complex

valid niche
#

a screenshot

surreal sierra
brazen seal
valid niche
#

so i can see exactly what it's doing?

visual island
valid galleon
#

what db is the best for discord bots? mongodb, or mysql?

visual island
#

idk, i prefer mysql

valid niche
#

in the end it's just personal preference tho

#

postgres is one of the most popular ones, followed by mysql and mongo

#

but it's what you want

visual island
valid galleon
#

what about storage tho?

visual island
#

for big bots it's worth it actually

valid niche
#

sqlite

#

if you care about too complex

valid galleon
#

hmm

#

i was thinking of going with mongo, but i'll try mysql

surreal sierra
visual island
valid galleon
visual island
valid niche
#

mysql and postgres are both just big database servers

#

both are equally complex

surreal sierra
valid galleon
#

i'll use what i find easier

#

mongo seems to be easier

valid niche
#

mongo is nosql

visual island
valid galleon
#

so maybe i'll study that and use it

valid niche
#

where postgres/mysql are relational databases

#

using sql

visual island
#

you need to learn sql also tho

#

for future uses

valid niche
#

sql is very easy and very handy yes

visual island
#

case insensitive

#

wow

valid niche
#

no sql is case sensitive :p

#

you always need to SCREAM

valid galleon
#

can someone post an example of how i would use mongodb to make per server prefixes? youtube tuts are pretty bad, and i cant find relevant docs, so looking at some example code will really help me

valid niche
#

:p

visual island
#

not really

valid niche
visual island
#

I like doing select data from table where condition

valid galleon
#

i'll look at open source bot code then

valid niche
visual island
#

instead of SCREAMING everytime

visual island
valid niche
#

it was literally a joke as seen by the :p

visual island
#

:p

clever wind
#

how do u use cogs

visual island
#

by subclassing commands.Cog

valid galleon
slate swan
#

Is there a stable d.py alternative with cogs support for slash commands yet?

clever wind
#

how?

#
client.add_cog(Lobby)

says Lobby isnt defined

valid galleon
clever wind
#

okay

valid galleon
#

try this

#

and add this in ur main file:

    if cog.endswith(".py"):
        client.load_extension(f"cogs.{cog[:-3]}")

    else:
        print(f'unable to load {cog[:-3]}')```
valid galleon
slate swan
#

it'll be saying unable to load {} for files without .py extensions

valid galleon
clever wind
#

what does this mean: Callback for start command is missing "ctx" parameter.

#

@valid galleon

ionic ledge
#

code for
how to delete a msg done by specific user

clever wind
# valid galleon code pls

its like incredibly long and i have no idea where the error came.. ill the whole error . i might just be blind

#
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 690, in _parse_arguments
    next(iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 979, in on_message
    await self.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 976, in process_commands
    await self.invoke(ctx)
  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 1348, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
    await self.prepare(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 693, in _parse_arguments
    raise discord.ClientException(fmt.format(self))
discord.errors.ClientException: Callback for start command is missing "ctx" parameter.
visual island
#

for cogs, you need (self, ctx) as the first and second argument

clever wind
valid galleon
clever wind
#

aight ill try that thx

valid galleon
#

you need self AND ctx

valid galleon
clever wind
ionic ledge
#

need specific code for this
user A sends hi
then user B sends hellow or other msg
.
whenever use A sends hi
user B sends some random msg
i want to delete user B message everytime when user A sends hi
helping with code would be great

clever wind
#

it says client is a missing positional arg

valid galleon
clever wind
#

yes

valid galleon
#

send the code

clever wind
#

cog loading in main file.

client.add_cog(lobby(client))
#

other file

class lobby(commands.Cog):
  def __init__(self, ctx):
        self.client = client
        self._last_member = None

  @client.group(invoke_without_command=True)
  async def lobby1(ctx):
    await ctx.send("Lobby 1 Online.")

  @lobby1.command()
  async def start(ctx):
      db = sqlite3.connect('my_database.db')
      cursor = db.cursor()
      
      #QUEUE CHANNEL
      queue1 = client.get_channel(883963916915453962)
      queue1_members = queue1.members

      queue1_members_mention = []
      for member in queue1_members:
          queue1_members_mention.append(member.mention)

      queue1_members_id = []
      for member in queue1_members:
          queue1_members_id.append(member.id)

      random.shuffle(queue1_members_mention)

      

      lobby1_team_a = queue1_members[len(queue1_members) // 2:]
      lobby1_team_b = queue1_members[:len(queue1_members) // 2]

      
      lobby1_team_a_mention = []
      for member in lobby1_team_a:
          lobby1_team_a_mention.append(member.mention)
      lobby1_team_b_mention = []
      for member in lobby1_team_b:
          lobby1_team_b_mention.append(member.mention)

      embed_lobby1 = discord.Embed(title="Teams")
      embed_lobby1.add_field(name="Team A",
                            value="\n".join(lobby1_team_a_mention),
                            inline=True)
      embed_lobby1.add_field(name="Team B",
                            value="\n".join(lobby1_team_b_mention),
                            inline=True)
      await ctx.send(embed=embed_lobby1)
#

don't mind the other sh-tty code cuz its weird

valid galleon
clever wind
valid galleon
clever wind
#

okay ill try that

valid galleon
#

so it should be like this:

async def start(self, ctx):```
clever wind
#

ah aight

valid galleon
#

did it work?

clever wind
# valid galleon did it work?

i think that bit worked, but this happened

@lobby1.command()
  async def start(self, ctx):
      db = sqlite3.connect('my_database.db')
      cursor = db.cursor()
      
      #QUEUE CHANNEL
      queue1 = client.get_channel(883963916915453962)
      queue1_members = queue1.members

      queue1_members_mention = []
      for member in queue1_members:
          queue1_members_mention.append(member.mention)

      queue1_members_id = []
      for member in queue1_members:
          queue1_members_id.append(member.id)

error: line 34, in start
queue1_members = queue1.members
AttributeError: 'NoneType' object has no attribute 'members'

#

i dont understand this it literally worked when it wasn't in a cog

valid galleon
#

hmm

#

cogs are a bit different

brazen seal
#

Why this command not work when all it's okay

spring flax
clever wind
#

oh... could u explain whats wrong here?

valid galleon
#

do this:

queue1 = self.client.get_channel(12345689)```
#

when using client in cogs, do self.client

clever wind
lunar grove
valid galleon
#

did you check if get_channel has the members attribute?

#

check it in the docs

clever wind
lunar grove
#

fuckin hate cogs

stark hearth
brisk fiber
#

i like cogs bc you can reload them without restarting your bot

valid galleon
#

How would i convert this line into mongodb code? im referring to some examples to get started, and need to convert this code from sqlite3:

c.execute(f"SELECT prefix FROM prefix WHERE guild_id = {message.guild.id}")```
lunar grove
#

to me they feel overcomplicated for 0 reason :/

valid galleon
lunar grove
#

yeah thats true

valid galleon
#

sorry for reply ping lol

stark hearth
#

idc lol

#

it’s all good

lunar grove
#

its good

boreal ravine
floral jacinth
#

await ctx.member.send(content=msg)
is it right?

#

to send private message

ionic ledge
valid galleon
visual island
#

yeah, but you can have it if you want anyways

ionic ledge
#

now help me peeps

#

need specific code for this
when any user sends hi
then user B sends hellow or other msg
.
whenever any user sends hi
user B sends some random msg
i want to delete user B message everytime when any user sends hi
helping with code would be great

floral jacinth
ionic ledge
clever wind
valid niche
#

it has 0 function

#

it's completely unused

spring flax
#

That is not the issue with the commane

clever wind
#

yeah but it worked for me

#

idfk why

valid niche
#

then you changed something else

clever wind
#

i didnt

valid niche
#

because pass_context doesn't do anything

#

unless this was 5 years ago

spring flax
#

Either his bot instance is bot or thats a cog i guess

valid niche
#

because then it actually did something

clever wind
#

YES IK BUT IT DOES AND I DONT UNDERSTAND WHY

#

its like

slate swan
boreal ravine
valid niche
clever wind
#

coming from personal experience, literally only thing i changed was that and it worked. he might not be using rewrite or smtg idfk but im just saying try it out

slate swan
#

no, it won't fix it

stiff nexus
#

class HelpCommand(commands.HelpCommand):
    def __init__(self):
        super().__init__(
            command_attrs={
                "help": "Shows help about the bot, a command, or a category",
            },
            verify_checks=True,
        )
        
    async def strikethrough_if_invalid(self, command: commands.Command):
        try:
            if await command.can_run(self.context):
                return self.get_command_signature(command)
        except commands.CommandError:
            pass

        return f'~~{self.get_command_signature(command)}~~'

    async def send_bot_help(self, mapping):
        ctx = self.context
        hel = []
        bot = ctx.bot
        owner = bot.get_user(862906093373751337)

        for cog, cmds in mapping.items():
            if cog and await self.filter_commands(cmds, sort=True): #await self.filter_commands(cmds, sort=True)
                hel.append(cog)

        embed = discord.Embed(description=bot.description,color=discord.Color(0xffffff))


        for idx in hel:
            #allowed_cmds = filter(lambda x: not x.hidden, idx.get_commands())
            embed.add_field(
                inline=False,
                name=idx.qualified_name.title(),
                value= ", ".join(map(lambda x: f"`{x}`", await self.strikethrough_if_invalid(command))), #filter(lambda x: not x.hidden, await idx.can_run(ctx))))
            )
        embed.set_author(name=ctx.author,icon_url=ctx.author.display_avatar)
        embed.set_thumbnail(url=bot.user.display_avatar)
        embed.set_footer(text=f"Made with ❤️ by {owner}",icon_url=owner.display_avatar)
        await ctx.send(embed=embed)
clever wind
#

it did for me

stiff nexus
# stiff nexus ```py class HelpCommand(commands.HelpCommand): def __init__(self): ...

error:

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 167, in wrapped
    ret = await coro(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/help.py", line 836, in command_callback
    return await self.send_bot_help(mapping)
  File "/home/runner/help.py", line 43, in send_bot_help
    value= ", ".join(map(lambda x: f"`{x}`", await self.strikethrough_if_invalid(command))), #filter(lambda x: not x.hidden, await idx.can_run(ctx))))
NameError: name 'command' is not defined

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/jishaku/features/invocation.py", line 146, in jsk_debug
    await alt_ctx.command.invoke(alt_ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 894, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 176, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'command' is not defined
clever wind
#

idk why dont ask

stiff nexus
#

help?

boreal ravine
#

@stiff nexus why copy code

stiff nexus
slate swan
#

You did all that?

stiff nexus
# slate swan You did all that?

yes but

    async def strikethrough_if_invalid(self, command: commands.Command):
        try:
            if await command.can_run(self.context):
                return self.get_command_signature(command)
        except commands.CommandError:
            pass

        return f'~~{self.get_command_signature(command)}~~'
``` this was advanced to add by my friend
boreal ravine
ashen gale
#
@client.command(name='play_song', help='To play song')
async def play(ctx,url):
    try :
        server = ctx.message.guild
        voice_channel = server.voice_client

        async with ctx.typing():
            filename = await YTDLSource.from_url(url, loop=bot.loop)
            voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename))
        await ctx.send('**Now playing:** {}'.format(filename))
    except:
        await ctx.send("The bot is not connected to a voice channel.")
stiff nexus
boreal ravine
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
ashen gale
#

getting a discord.ext.commands.errors.CommandNotFound error

slate swan
#

We aren't gonna help

ashen gale
#

damn nvm then

slate swan
boreal ravine
#

👍

ashen gale
stiff nexus
#

also stop this it feels like you are stalking me

slate swan
#

!rule 5

unkempt canyonBOT
#

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

ashen gale
#

jeez

slate swan
#

🤷‍♂️

summer jungle
#
    try:
        event = await self.bot.wait_for("select_option", check=None)

        label = event.component[0].label

        if label =="Option 1":
                await event.respond(
                    type=InteractionType.ChannelMessageWithSource,
                    ephemeral=True,
                    embed=e1

                    )

        elif label =="Option 2":
                await event.respond(
                    type=InteractionType.ChannelMessageWithSource,
                    ephemeral=True,
                    embed=e2

                    )

        elif label =="Option 3":
                await event.respond(
                    type=InteractionType.ChannelMessageWithSource,
                    ephemeral=False,
                    embed=e3

                    )

client.run("TOKEN")```

Apparently, This error is on the LAST line of my code
```    client.run("TOKEN")
IndentationError: unexpected unindent
slate swan
#

Bruh

#

Every Try needs a pairing Except of Finally

#

try -> except/finally

summer jungle
slate swan
#

only working for bot s the unban command

#

?????

#

anyone

floral jacinth
#
.....
 await member.send(content=msg)```
it prints ```<Message id=887341517851729961 channel=<DMChannel id=887334334908989441 recipient=<User id=256524667186184192 name='Hik' discriminator='9778' bot=False>> type=<MessageType.default: 0> author=<User id=256524667186184192 name='Hik' discriminator='9778' bot=False> flags=<MessageFlags value=0>>```

how can i solve?
tulip pawn
#

hey im trying to make a tictactoe command and i want to check if the player argument is a bot or member

@bot.command(aliases=['ttt'])
async def tictactoe(ctx, p1: discord.Member):
    p2 = ctx.author

    if p1 == discord.User.bot:
        await ctx.send('u cant play against a bot')
        return

This wont work and neither does

@bot.command(aliases=['ttt'])
async def tictactoe(ctx, p1: discord.Member):
    p2 = ctx.author

    if discord.User.bot:
        await ctx.send('u cant play against a bot')
        return

Here it just says all users are bots somehow

slate swan
#

!role.permission

#

!e @client.command()
@commands.has_permissions(ban_members=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')

for ban_entry in banned_users:
    user = ban_entry.user
    
if (user.name, user.discriminator) == (member_name, member_discriminator):
     await ctx.guild.unban(user)
     await ctx.send(f"{ctx.author.mention} has unbanned {user} ")
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 'client' is not defined
slate swan
#

Umm

#

!e @commands.has_permissions(ban_members=True)
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')

for ban_entry in banned_users:
    user = ban_entry.user
    
if (user.name, user.discriminator) == (member_name, member_discriminator):
     await ctx.guild.unban(user)
     await ctx.send(f"{ctx.author.mention} has unbanned {user} ")
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 'commands' is not defined
slate swan
#

!e banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')

for ban_entry in banned_users:
    user = ban_entry.user
    
if (user.name, user.discriminator) == (member_name, member_discriminator):
     await ctx.guild.unban(user)
     await ctx.send(f"{ctx.author.mention} has unbanned {user} ")
#

!discord.Member

#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User").

`x == y` Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") instances too.

`x != y` Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") instances too.

`hash(x)` Returns the member’s hash.

`str(x)` Returns the member’s name with the discriminator.
slate swan
#

:l

night onyx
#
@commands.command()
    async def setPrefix(self,ctx,*,prefix):
        id = ctx.guild.id
        sql = "UPDATE SERVERINFORMATION SET Server_Prefix = ? WHERE Server_Id = ?"
        val = (prefix,id)
        async with aiosqlite.connect('pikachubotdb.sqlite') as db:
            async with db.cursor() as cur:
                await cur.execute(sql,val)
        await ctx.send(f"Prefix Has Been Set To {prefix}")

can anyone tell me error in this code because no error is coming but the data in database is not changing

slate swan
ashen gale
#

ok im back with another question

slate swan
ashen gale
#

what do you guys host your bots on?

slate swan
#

So just so msg.content

stuck flare
ashen gale
#

is it free?

stuck flare
lament mesa
ashen gale
#

neat

lament mesa
ashen gale
#

could you slide the link?

stuck flare
stiff nexus
#

how to get total command in the bot

stuck flare
ashen gale
#

what a guy

stuck flare
ashen gale
#

yeah

stuck flare
#

lol

unkempt silo
#

HELP ME PLS - typeerror-not-supported-between-instances-of-str-and-int

rare saddle
#

How to display a bot avatar?

boreal ravine
ashen gale
#

@stuck flare how do i upload my code? im sick of repl.it

unkempt silo
unkempt silo
#

and cant change msg cntent in to int

slate swan
#

len(bot.commands)

stuck flare
ashen gale
#

i see

boreal ravine
#

@stuck flare btw uptimerobot isnt a hosting site

wicked atlas
unkempt silo
#

no body can help me

boreal ravine
#

it just pings stuff so it doesnt go offline

ashen gale
slate swan
boreal ravine
rare saddle
ashen gale
boreal ravine
wicked atlas
slate swan
boreal ravine
#

y use lucas ban

ashen gale
boreal ravine
#

no the lang

slate swan
ashen gale
#

yeah i get the lang

#

how do i upload it as a bot

slate swan
#

then which ban me use??

stuck flare
#

u can use heroku i guess

boreal ravine
wicked atlas
slate swan
#

ohkk i try and dm u @boreal ravine u 1 of my devs

boreal ravine
#

no

slate swan
wicked atlas
stiff nexus
#
    async def send_cog_help(self, cog):
        paginator =  menu.MyMenu(source= menu.MySource(self.context,per_page=14), timeout=180.0, clear_reactions_after=True, delete_message_after=False)
        c = 0
        for cmd in cog.get_commands():
            if not cmd.hidden:
                _brief = "No Information..." if not cmd.short_doc else truncate_string(cmd.short_doc, 60)
                paginator.add_line(f"`{cmd.qualified_name}` : {_brief}")
                c += 1

        paginator.title = f"{cog.qualified_name.title()} ({c})"
        await paginator.start(ctx)
```object of type 'Context' has no len() 

help???
gloomy pewter
#

Excuse me, I want to ask, how do I get my bot to get a verification logo?

slate swan
slate swan
wicked atlas
#

Maybe check what you are supposed to pass to it?

slate swan
#

Perhaps

night onyx
#
async def get_prefix(Pikachu,message):
    async with aiosqlite.connect('pikachubotdb.sqlite') as db:
        async with db.cursor() as cursor:
            await cursor.execute(f"SELECT Server_Prefix FROM SERVERINFORMATION WHERE Server_Id = {message.guild.id}")
            prefix = await cursor.fetchone()
            if not prefix:
                prefix = prefix[0]
            else:
                prefix = "$"
        
    return prefix

can anyone tell me problem with this code because as far as i think when any commands of bot is bieng used value to get_prefix will be returned > from database but commands are not working with prefix > else they are working with $

spring flax
night onyx
#

i did this change right now cause i think that it's problem of commit otherwise commit was not there before

stiff nexus
#
    async def send_cog_help(self, cog):
        ctx = self.context 
        page = []
        c = 0
        for cmd in cog.get_commands():
            if not cmd.hidden:
                _brief = "No Information..." if not cmd.short_doc else truncate_string(cmd.short_doc, 60)
                embed=discord.Embed(title = f"{cog.qualified_name.title()} ({c})")
                embed.add_field(name=f"`{cmd.qualified_name}`",value=f"{_brief}")
                c += 1
                page.append(embed)

        paginator =  menu.MyMenu(source= menu.MySource(page,per_page=14), timeout=180.0, clear_reactions_after=True, delete_message_after=False)
        
        await paginator.start(ctx)
``` it says
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: send() argument after ** must be a mapping, not NoneType
spring flax
#

I didn't get it

spring flax
gloomy pewter
#

Now what's stable is Py-chord or nextcloud

dusky robin
#

how can i install discord.app module?

slate swan
#

Good docs and easy to use

gloomy pewter
night onyx
#

according to code when a bot command is used the prefix which will be returned to get_prefix from database would be like > for xyz id,. for abc etc but the commands are not working with respective prefix of server instead they are working with $ @spring flax

slate swan
gloomy pewter
slate swan
#

!pypi disnake

unkempt canyonBOT
slate swan
#
        # don't respond to ourselves
        if message.author == self.user:
            return
        if message.content == 'hey':
            await message.channel.send('Shalom, how it hanging')``` help me
gloomy pewter
#

Okey

slate swan
#

no help?

#

damn :/

gloomy pewter
maiden fable
#

What's the problem? You never told any error or something

slate swan
#

it doesnt work

maiden fable
#

Error?

slate swan
#

hold up

slate swan
#

PS C:\Users\NAME> & "C:/Users/NAME/AppData/Local/Programs/Python/Python39/python.exe" "c:/Users/NAME/Desktop/Discord bot/Main bot.py"
Traceback (most recent call last):
File "c:\Users\NAME\Desktop\Discord bot\Main bot.py", line 22, in <module>
client.run('bot token here btw')
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 601, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged
intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x00000129BF776AF0>
Traceback (most recent call last):
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\NAME\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

#

@maiden fable

wispy spade
maiden fable
#

Ah ok

maiden fable
slate swan
#
from discord.ext import commands

#discord.Intents.all()
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix='!', intents=intents)

@client.command()
async def clear(ctx, ammount=10):
        await ctx.channel.purge(limit=ammount)

async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'Hey':
            await message.channel.send('Shalom, how is it going?')

client.run('token')```
maiden fable
#

Yea intents.members

maiden fable
#

U need to enable them from discord dev portal

wispy spade
#

The error tells you to go to that link, click on your App, then go to Bot, and enable the privileged intents from there.

slate swan
#

oh lol

high flame
hasty iron
#

none are stable

#

all are bad

high flame
#

yeah pycord has issues

high flame
hasty iron
high flame
#

k

stark bobcat
#

how do i enable intents

high flame
#

there

stark bobcat
#

i did that

lament mesa
#

discord.Intents.all()

stark bobcat
#

do i have to do anything in code?

high flame
#

enable it in your code

stark bobcat
stark bobcat
high flame
#

!d intents

#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

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

from discord import Intents
from discord.ext import commands

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

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

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

high flame
lament mesa
lament mesa
stark bobcat
#

Thanks

high flame
stark bobcat
high flame
#

i want an example pithink

ionic ledge
#

idk
how to implement this thing in code
when any user says hi
user B says hellow to any user who says hi
so i want to delete the user B msg every time when it responds to hi message

ionic ledge
#

bot deleting bot msg

stark bobcat
#

u can use on_message

ionic ledge
#

i have used on msg function

#

just need to implement this thing

slate swan
#

hi guys, im incredibly stupid and even reading the docs i can't figure out how to fix a problem im experiencing. My problem is this: I have a command defined as this

async def slap(ctx, member: discord.Member = None, *, argument="they had no reason!"):
    if member == ctx.author or member is None:
        await ctx.send(ctx.author.mention + ' slapped themselves because *' + argument + '!*')
    else:
        await ctx.send(ctx.author.mention + ' slapped ' + member.mention + ' because *' + argument + '!*')

to use the command you'd type something like ~slap @userpersonmanthingy this is a reasonin the arguments. I tried to make member optional by giving it a default value of None, but since the user is typing a reason afterwards the bot interprets "this" as the user and throws an error because "user" isn't a member. I wanted to use method overloading but then remembered python doesn't let you do that ):

please help i am incredibly stupid and can't for the life of me figure out how to solve this

ionic ledge
#

example code would be great for me

stark bobcat
#
  a = msg.channel.send("hellow")
  a.delete()```
#

smth like that

ionic ledge
ionic ledge
stark bobcat
#

uh

#

wym

ionic ledge
# stark bobcat wym

like if some user say hi
then then a bot responds to hi with different msg every time.
so so i want my bot to delete that random msg

#

also the respondes random msg is in embed form

stark bobcat
#

u can put it in a list and randomly pick one and send

ionic ledge
#

just need that peice of code line which will delete that unique msg

boreal ravine
#

🗿

ionic ledge
#

@stark bobcat can you let a user not msg anything
like when a user sends anything in channel
then my bot deletes that user msg whatever it is

#

for example if you msg anything here
my bot will immediately delete it

valid niche
stark bobcat
#

using for loops u can do that

#

one min

#

wai

valid niche
#

you probably just want to check like the channel/author or whatever before deleting so it doesn't delete everyone's message anywhere

ionic ledge
maiden fable
#

pithink I just came to know I have broken Discord ToS once before

slate swan
#

What does the "Doesnt look like anything to me" mean in the docs for api versions?

maiden fable
#

This happened like 1 month before I started bot making

valid niche
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
ionic ledge
valid niche
#

message is the message object you want to delete

#

it's the entire message, it's one SPECIFIC message

slate swan
ionic ledge
valid niche
#

an on_message event just triggers every time anyone sends a message anywhere

#

so in between these 2 parts you can do your filtering and such

slate swan
slate swan
#

im afraid i might have to resort to methods that make my code look really ugly and hacky

maiden fable
#

Yo seb I need some help

#

I am in the VC still None

stiff nexus
#

send() got an unexpected keyword argument 'embed_perms'

maiden fable
#

there is embed but nothing like embed_perms

slate swan
#

maybe check intents @maiden fable

maiden fable
slate swan
#

btw if your making a music bot i would be carefull - they getting sued and taken down by google

maiden fable
slate swan
#

just use both, either way you would have to get verified for 1 of em. So there isnt a point in only yusing 1

maiden fable
#

both?

#

WYM

slate swan
#

where can i create colors like this?

maiden fable
#

ah got it. I need Intents.voice_states

maiden fable
boreal ravine
boreal ravine
slate swan
#

i know how it called but i want to create one

maiden fable
#

You manually type those bro

#

You cannot "create" colors, if that is what you mean

slate swan
#

there's some website like this but just for 0x code?

boreal ravine
#

yeah hex codes

maiden fable
boreal ravine
#

Remove the # lol

maiden fable
#

Yea

slate swan
#

so like 0x0007b?

maiden fable
#

Indeed

maiden fable
slate swan
#

check reference part

valid niche
maiden fable
stiff nexus
#
    @commands.command()
    async def bans(self, ctx):
      guild = ctx.guild

      banned_user = await guild.bans()
      if not len(banned_user):
        return await ctx.send(f"Found Nothing")
      
      for ba in banned_user:
        paginator = QuoPaginator(ctx, per_page=14)
        paginator.add_line(f"User\n`{ba[1]}` (`{ba[1].id}`)\nReason\n`{ba[0]}`")

        try:
          paginator.set_thumbnail(url=ba[1].display_avatar)
        except:
          pass

      await paginator.start()
```its only sending 1 page also not adding the thumbnail
velvet tinsel
#

How to make a discord.py bot 24/7 like @unkempt canyon? I heard it’s something to do with setting up a server?

final iron
velvet tinsel
#

Cool

#

I used uptime robot before I realised it sucks

final iron
#

What was wrong with it?

valid niche
#

it doesn't actually host anything for you

boreal ravine
#

owo

drifting arrow
#

Whats the command so I can send upload my entire script?

kindred epoch
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

drifting arrow
slate swan
#

simply put it outside your for loop

stiff nexus
#

got it

#

how do i change the button color to white??

slate swan
#

idk if dpy has ButtonStyle.white

#

iirc it doesn't

#

meaning u can't

radiant ermine
#

Does anyone know why my Start.bat file is closing after every command i issue, No error codes or nothing reveald. Yet

warm terrace
#

Is there a way to make the bot online forever instead of manually clicking run on the editor ?

drifting arrow
#

@warm terrace Yes! a virtual private server (VPS)

#

As long as you don't use heroku you are fine

warm terrace
#

Wait I thoguht it was VPN for a second lmao

brisk fiber
#

if it's a small bot you can also host it on a raspberry pi

warm terrace
#

How do I use a VPS tho ?

drifting arrow
warm terrace
brisk fiber
drifting arrow
#

most VPS only have a 1gb ram at the lowest price

#

Which most people go for

brisk fiber
#

what i like about raspberry pis is that you only pay an up-front cost, not a subscription (though obviously you have to pay for power and internet and all that)

#

anyway it's just an option to be aware of as well

stiff nexus
#
    @discord.ui.button(label='Skip to page...', style=discord.ButtonStyle.grey)
    async def numbered_page(self, button: discord.ui.Button, interaction: discord.Interaction):
        """lets you type a page number to go to"""
        if self.input_lock.locked():
            await interaction.response.send_message('Already waiting for your response...', ephemeral=True)
            return

        if self.message is None:
            return

        async with self.input_lock:
            channel = self.message.channel
            author_id = interaction.user and interaction.user.id
            await interaction.response.send_message('What page do you want to go to?', ephemeral=True)

            def message_check(m):
                return m.author.id == author_id and channel == m.channel and m.content.isdigit()

            try:
                msg = await self.ctx.bot.wait_for('message', check=message_check, timeout=30.0)
            except asyncio.TimeoutError:
                await interaction.followup.send('Took too long.', ephemeral=True)
                await asyncio.sleep(5)
            else:
                page = int(msg.content)
                await msg.delete()
                await self.show_checked_page(interaction, page - 1)
#
Ignoring exception in view <PaginatorView timeout=60.0 children=6> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Skip to page...' emoji=None row=None>:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ui/view.py", line 359, in _scheduled_task
    await item.callback(interaction)
  File "/home/runner/paginator.py", line 199, in numbered_page
    if self.input_lock.locked():
AttributeError: 'PaginatorView' object has no attribute 'input_lock'
Ignoring exception in view <PaginatorView timeout=60.0 children=6> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Skip to page...' emoji=None row=None>:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ui/view.py", line 359, in _scheduled_task
    await item.callback(interaction)
  File "/home/runner/paginator.py", line 199, in numbered_page
    if self.input_lock.locked():
AttributeError: 'PaginatorView' object has no attribute 'input_lock'
```help
warm terrace
warm terrace
#

Oh and also is there a queue feature in music discord bot which i can add?

slate swan
#

i mean most free vps are insecure and have terrible connections

#

you can try hosting on the cloud

#

or hosting a bot on a device on your network such as a laptop or a rasberi pi

#

Hey!
anyone know how to change volume from a bot using python?

#

hi

#
@client.command()
async def afk(ctx, reason=None):
    current_nick = ctx.author.nick
    await ctx.author.edit(nick=f"(AFK) {ctx.author.name}")
    embed = discord.Embed(description=f"{ctx.author.mention} is **AFK**: {reason}", color=(0x2E3235))
    await ctx.send(embed=embed)

    counter = 0
    while counter <= int(mins):
        counter += 1
        await asyncio.sleep(60)

        if counter == int(mins):
            await ctx.author.edit(nick=current_nick)
            embed = discord.Embed(description=f"welcome back, {ctx.author.mention} you are no longer **AFK**", color=(0x2E3235))
            await ctx.send(embed=embed)
#

any help?

worthy wagon
slate swan
#

Oh it makes sense now cus im the owner

#

thanks i asked a member to test it for me it worked

#

thank u so much!

worthy wagon
#

Alright bro, good stuff, no problem man!

slate swan
#

:)

dim wing
#

do you know any good library to get youtube videos or audio (to make a music command)

jade jolt
#

!yt-dl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
dim wing
#

okay thx

#

is it high quality?

#

oh my bad

jade jolt
#

we are unable to assist with questions related to youtube-dl

dim wing
#

yeah

#

or do you have good source to play audio with discordpy

#

not related with youtube

jade jolt
#

¯\_(ツ)_/¯

dim wing
#

uh so other question, do i need to download the audio to play it with discordpy?

hasty iron
#

no you dont but its still against tos

dim wing
#

okay but the audio could be mine, so it's in the tos

hasty iron
#

if its yours, you're free to use how ever you like

distant tree
#

how good of an idea is it to run a discord bot on a chomebook.

distant tree
distant tree
valid niche
#

although chromeOS is kinda like hated on and will make it more annoying

distant tree
valid niche
#

API latency is often the worst part

#

which averages around 30-90ms depending on the day and the time

distant tree
#

what really confuses me is any vps i've seen has around 30ms max.

valid niche
#

wut?

#

what you mean 30ms max?

distant tree
#

usually for me it's under 20 most of the time.

valid niche
#

wut?

#

what latency?

#

where?

#

who what where?

distant tree
valid niche
#

where are you looking?

#

what are you seeing?

distant tree
# valid niche where are you looking?

nothing? i'm just trying to figure out if running a bot on a chromebook is a good idea for latency. it confuses me that a vps can get 20ms average but just running it locally gets me 60.

valid niche
#

you literally cannot get faster than the API latency

lament yew
#

umm hasnt python stopped bot developement for discord

#

...

slate phoenix
valid niche
#

it's your PC has to process it, then the connection over the internet, the API has to process it, then the API has to respond over the internet, then that signal comes in to your server and that has to process it again

#

and that's your latency

valid niche
distant tree
valid niche
#

the founder, creator and maintainer of discord.py, danny, stopped with maintaining

lament yew
#

ohh

valid niche
#

but the library still works and is open source so anyone is free to fork it and work on it from there?

valid niche
#

they got the latency from what the API itself reports, which is the same as on https://discordstatus.com/

distant tree
valid niche
#

that is the API latency and not the true latency

distant tree
valid niche
#

right now API response time on average is 63ms

#

it varies from time to time

#

that website just says the current average which can be 200 or 5 or 10 or 50 or whatever in a few seconds

#

it constantly fluctuates

maiden fable
#

It also depends on the physical distance between you and the servers

#

Oopsie, I am late

ivory dome
#

hey

#

how do i add anti spam for my bot with counters?

slate swan
#

how can I get the bot to read a text document that stores the id, and if the text document contains its id, then make it so that the bot simply ignores it
If anything, I use a translator:) if you don't understand please let me know

msg_dump_channel = 886496848196542514
ignoreusers = []

@bot.event
async def on_message(message: discord.Message):
     channel = bot.get_channel(msg_dump_channel)

     if message.author == bot.user or message.author.id in ignoreusers:
          return
     if message.guild is None and not message.author.bot:

          iduser = message.author.id
          nameuser = message.author.name
          text = message.content


          embed = discord.Embed(title = "Личные сообщение бота: ", description = (f"```css\n{ text }```"), color = 0x1f8b4c)
          embed.add_field(name ="ID Автора и ник", value=(iduser, nameuser), inline=False)

          await channel.send(embed = embed)
     await bot.process_commands(message)```
lyric moat
#

how do i make my bot reply to a command

lyric moat
slate swan
#

you can looking in google but take```css
@bot.command()
async def ping(ctx):
await ctx.send('Pong!')

tough bobcat
#

I was looking to see if anybody could help me with doing Custom Statuses. I can set the status to a game just fine with python await client.change_presence( activity=discord.Game(name="test") ) but that always has the prefix Playing (in this case Playing test). When I try to use the custom status type python await client.change_presence( activity=discord.CustomActivity(name="test") ), nothing shows up in the bot's status line. The documentation says that CustomActivity can be used in the same way as Game. https://discordpy.readthedocs.io/en/stable/api.html?highlight=presence#discord.BaseActivity

slate swan
tough bobcat
#

yeah I can get it to work with discord.Game but not discord.CustomActivity

slate swan
#

?

tough bobcat
#

the activity= portion can be set to any BaseActivity which includes Game as well as CustomActivity

#

CustomActivity should display the text without the "Playing" prefix which is included with the game type

slate swan
#

ahhh

tough bobcat
slate swan
#

No, I do not know how to do this, sorry

tough bobcat
#

Alright, i will reask in an actual help channel

#

Thank you

kindred epoch
tough bobcat
#

it looks like the type is a return attribute?

kindred epoch
#

bruh

jade jolt
#

how do i play music with discord.py? not from youtube

hasty iron
#

your only option is youtube

#

no other platform allows it either

jade jolt
#

local files?

pliant gulch
#

Hope you plan on buying licenses for every copyrighted music you are planning on playing then

hasty iron
#

need to be your own music

pliant gulch
#

Or only use noncopyright music

jade jolt
#

its a mix of my own and noncopyright yes

pliant gulch
#

Ok, there should be some examples on voice stuff in the github repo for discord.py

jade jolt
#

could you provide a small example here?

pliant gulch
#

Just take a look at the repo

ruby cosmos
#

With discord tasks loop, is there any way of passing the iterations count as an argument instead of defining it in the decorator

dense thunder
#
days = 0
while (days <= 7):
    bugs = (int(input("Number of bugs collect each day:")))
    days += 1
    bugs_collected =+ bugs

print("The total number of bugs collected was: ",bugs_collected)

im collectin bugs for 7 days and printing out the total number at the end, why isnt this working?

slate swan
#

Hello

#

= import os
import discord
from discord.ext import tasks, commands

TOKEN = os.getenv("TOKEN")

bot = commands.Bot(
command_prefix='-',
intents = discord.Intents.all()
)

== Variable interval ==

guild_id = 886022764618731592#guild id
status_keyword = '.serverlink'#The status keyword
role_id = 886025433303355442#The role id

=======================

@tasks.loop(seconds = 2)
async def statusCheck():
guild = bot.get_guild(guild_id)
role = guild.get_role(role_id)
for member in guild.members:
if status_keyword in str(member.activity) and not role in member.roles:
try: await member.add_roles(role)
except: print(f'Try to give {member.name} role, but fail')
elif status_keyword not in str(member.activity) and role in member.roles:
try: await member.remove_roles(role)
except: print(f'Try to give {member.name} role, but f

#

It won’t run for some reason anyone got tips

#

I’m bad at coding so ye don’t bully me

slate swan
#

how to make a discord button ?

slate swan
#

I put token as secret

#

That’s what env was for I thought

lone lichen
bitter anchor
lone lichen
#

Python-dotenv*

slate swan
#

py cord??

#

And I am dumbass so ye

slate swan
bitter anchor
lone lichen
slate swan
#

OOO

bitter anchor
#

it's a discord.py fork that i'm working on and it supports all the new features include slash commands

lone lichen
slate swan
#

or like y'all got a docs ?

lone lichen
slate swan
#

what i just asked

bitter anchor
slate swan
#

@lone lichen when I try run this happend

#

= import os
import discord
from discord.ext import tasks, commands

TOKEN = os.getenv("TOKEN")

bot = commands.Bot(
command_prefix='-',
intents = discord.Intents.all()
)

== Variable interval ==

guild_id = 886022764618731592#guild id
status_keyword = '.serverlink'#The status keyword
role_id = 886025433303355442#The role id

=======================

@tasks.loop(seconds = 2)
async def statusCheck():
guild = bot.get_guild(guild_id)
role = guild.get_role(role_id)
for member in guild.members:
if status_keyword in str(member.activity) and not role in member.roles:
try: await member.add_roles(role)
except: print(f'Try to give {member.name} role, but fail')
elif status_keyword not in str(member.activity) and role in member.roles:
try: await member.remove_roles(role)
except: print(f'Try to give {member.name} role, but f

lone lichen
lone lichen
slate swan
#

discord components vanity link ?

lone lichen
slate swan
lone lichen
slate swan
#

ik they had a server i was in but i forget there vanity

#

ima jus look up the docs lel

slate swan
wicked atlas
lone lichen
slate swan
lone lichen
#

Code editor that u download

#

Not on web

slate swan
#

Ok

wicked atlas
#

And prefereably don't use a mobile device for coding

lone lichen
#

Like vscode or pycharm

slate swan
#

I cba going on pc rn

slate swan
slate swan
lone lichen
slate swan
lone lichen
#

Download vscode

#

Or pycharm

#

I prefer pycharm

slate swan
#

Ok

lone lichen
#

And download python

#

If u dont have it yet

#

Dont code in web ide

slate swan
#

@lone lichen the code is here

lone lichen
slate swan
wicked atlas
#

You don't need python-dotenv if you're doing it on replit

#

Setting secrets sets them as enviroment variables

lone lichen
slate swan
wicked atlas
#

Can you run it and send the output?

lone lichen
wicked atlas
#

replit is fine for writing code and stuff, it's not good for long term hosting of bots

slate swan
lone lichen
slate swan
wicked atlas
lone lichen
waxen python
#

Is there a way to grab how many Voice channels the bot is in across servers?

lone lichen
wicked atlas
#

I mean, better to see if it errors or anything before going through all that trouble

lone lichen
#

logging.basicConfog(level=logging.DEBUG)

#

Add this^

wicked atlas
#

"Confog" lmao

lone lichen
#

Typo

patent lark
#

confog

slate swan
pliant gulch
unkempt canyonBOT
#
Not likely.

No documentation found for the requested symbol.

lone lichen
pliant gulch
#

!d discord.Client.voice_clients *

unkempt canyonBOT
#

voice_clients```
Represents a list of voice connections.

These are usually [`VoiceClient`](https://discordpy.readthedocs.io/en/stable/api.html#discord.VoiceClient "discord.VoiceClient") instances.
lone lichen
#

Just do that

wicked atlas
slate swan
lone lichen
#

No wait

#

Under bot = commands.Bot

wicked atlas
#

It'll work anywhere before bot.run, but usually people configure logs just after the imports

slate swan
lone lichen
#

So just to be sure

#

Under defining bot

#

I just wanna see what dpy loggs

wicked atlas
#

I've configured logs before creating a bot instance, dosen't really change it up that much

slate swan
wicked atlas
#

Does it give an error?

lone lichen
#

Google dpy loggin

slate swan
#

When I tried to run

wicked atlas
#

How are you running it?

lone lichen
#

Google dpy logging and do what it says in the docs

slate swan
#

what channel do i type in if i need help with selenium? pls mention me

lone lichen
#

Basic logging

slate swan
lone lichen
slate swan
#

Yes

hasty iron
#

why are you using your phone to code

wicked atlas
#

@slate swan try adding a print statement somewhere in your code, maybe right on the first line

#

then we can see if it at least runs your script

lone lichen
slate swan
lone lichen
hasty iron
#

so you dont code and you’re trying to code a discord bot

#

sounds a bit contradictory

wicked atlas
slate swan
hasty iron
#

either way, you shouldn’t use repl further more a phone to code

slate swan
#

Yes

#

But I’m shit at coding so it’s all the one

lone lichen
#

Also u cant just jump into making bots if u cant code

hasty iron
#

what does you being shit at coding do with the fact that you’re using a phone and repl

wicked atlas
#

@slate swan did the print statement work?

wicked atlas