#discord-bots

1 messages · Page 524 of 1

slate swan
#

need help dm me pls

#

RuntimeError: Event loop is closed

#

https://cdn.upload.systems/uploads/Y8gDUwSp.png
I've got these warnings and I can't seem to get rid of them, I know why it's doing it (because of ComponentsBot), but I need that in my bot (Originally in my main file but I tried to work around it, which didn't work because it requires me to put in bot = commands.ComponentsBot() in my main file, which I can't because I need to have bot = commands.Bot() in it or else the rest of my bot won't work, anyone got an idea on how I can make both of them work (I work with Cog files). Already changed check=lambda inter: to check=lambda i:

tough wagon
#

Info.pypy from Help import Help ... def __init__(self, bot): self.bot = bot bot.help_command = Help(bot) bot.help_command.cog = self ...Help.pypy ... def __init__(self, bot): super().__init__( command_attrs={ 'cooldown': CooldownMapping.from_cooldown(1, 3, BucketType.member), 'description': 'Shows help about the bot, a command, or a category', } ) self.bot = bot ...ErrorFile "/usr/lib/python3.9/asyncio/base_events.py", line 677, in is_closed return self._closed AttributeError: '_UnixSelectorEventLoop' object has no attribute '_closed'
full exception: https://hastebin.com/tadeceguje.sql
Someone?

slate swan
#

client = commands.Bot(command_prefix="!")

#

TypeError: BotBase.init() missing 1 required positional argument: 'command_prefix'

#

wtf

#

someone help me

#

Uh let me open pycharm rq

solar pike
#

how to add webhooks?

slate swan
#

it doesnt work without =

#

@slate swan

slate swan
hasty iron
#

that wont work

slate swan
#

That's the line

#

yeah idk, im too lazy to think and i cba to open pycharm

slate swan
#

Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "c:\Users\bert.vscode\extensions\ms-python.python-2021.10.1317843341\pythonFiles\lib\python\debugpy_main
.py", line 45, in <module>
cli.main()
File "c:\Users\bert.vscode\extensions\ms-python.python-2021.10.1317843341\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\bert.vscode\extensions\ms-python.python-2021.10.1317843341\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("main"))
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 269, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\bert\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 35, in <module>
from .errors import *
ImportError: attempted relative import with no known parent package

slate swan
#

now this being glitching

hasty iron
#

are you doing py -m discord

#

oh nvm

stone palm
#

is there a way i can keep adding 1 to a value of a field that has an integer string

pliant nacelle
#

@client.command() async def id(ctx): await ctx.send("Your ID is" + user.id)

#

where is the problem ?

slate swan
#

you can just use

@client.command()
async def id(ctx):
  await ctx.send(f"Your id is {ctx.author.id}")

slate swan
pliant nacelle
pliant nacelle
#

sorry my language is bad 😦

final iron
#

Also it was probably ctx.user.id

slate swan
#

about the person that sends the message

final iron
#

Yeah thats the issue with tutorials

#

They get outdated

slate swan
#

ye

final iron
#

Yup

slate swan
final iron
#

Also an id command is completely useless

slate swan
#

yes

#

the id can be used on whois command

final iron
#

Or you could just right click then left click

slate swan
#

exactly

#

😂

pliant nacelle
slate swan
#

y

#

must define it

pliant nacelle
slate swan
#

ctx.author is defined because use ctx parameter

final iron
#

Unless you have member: discord.Member in the params member is nothing

slate swan
#

RuntimeError: Event loop is closed SOMEONE TELL ME WTFFF THIS IS

#

ive been stuck with this stupid error for 2 hours

final iron
#

What is it breaking?

slate swan
#

Traceback (most recent call last):
File "c:\Users\bert\Downloads\discord bots\test.py", line 31, in <module>
client.run(token)
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 666, in start
await self.connect(reconnect=reconnect)
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\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 0x0000023873381C60>
Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
self._check_closed()
File "C:\Users\bert\AppData\Local\Programs\Python\Python310\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.

slate swan
#

i did now

slate swan
#

how i set random color to the embed

#

?

boreal ravine
final iron
#

Does anyone have the image from the dpy server where it shows you how to turn on intents?

#

I need it for a friend

slate swan
#

yes

#

@final iron

final iron
#

ty

slate swan
#

!d str.replace

unkempt canyonBOT
#

str.replace(old, new[, count])```
Return a copy of the string with all occurrences of substring *old* replaced by *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced.
slate swan
#

newhex = newhex.replace.....

fast hedge
#

Anyone got a simple python bot.command()
send.message bot? Im in a pinch and need a simple command bot

slate swan
#

that's not how it works

pliant nacelle
#
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
    if reason==None:
      reason=" no reason provided"
    await ctx.guild.ban(member)
    await ctx.send(f'User {member.mention} has been banned for {reason}')
pliant nacelle
#

wherre is the problem

manic wing
pliant nacelle
#

yea

manic wing
#

share it

pliant nacelle
#

@commands.has_permissions(ban_members=True) IndentationError: unexpected unindent

manic wing
#

hint in the name

tough wagon
#

maybe it's because of this space

fast hedge
manic wing
#

ill do it for £500

tough wagon
#

oh ru

fast hedge
dapper cobalt
#

!d discord.Embed

unkempt canyonBOT
#

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

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

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

New in version 2.0.

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

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

Use this to make Discord embeds.

tough wagon
pliant nacelle
tough wagon
#

xd

pliant nacelle
pliant nacelle
tough wagon
#

can someone help me here or in #help-pie ? 😦

dapper cobalt
#

Ah, I didn't see the code you sent.

covert igloo
#

i get this trying to install slash commands

tough wagon
covert igloo
#

its dpy related

dapper cobalt
tough wagon
#

eh okay

dapper cobalt
covert igloo
#

how do i go about doing that

dapper cobalt
#

You'll need to go to the .exe file that you installed Python through, and hit uninstall.

#

Then when installing, before you click install, make sure you check this.

#

That's not just for 3.7, but every version.

tough wagon
#

me an ubuntu user: ok

covert igloo
#

if i hadnt installed python to path, would i also have problems installing other things with 'pip....'

covert igloo
#

i just used it to install nextcord, worked fine

tough wagon
#

problems with pip are always weird (no)

dapper cobalt
covert igloo
#

it just worked a second ago when i used it to install nextcord

waxen granite
#
    @commands.command(help = "Make the bot leave a server", aliases = ['leave', 'lsv'])
    async def leaveserver(self, ctx, *, serverName):
        guild = discord.utils.get(self.bot.guilds, name=serverName)
        if serverName == guild.name or serverName == str(guild.id):
            await guild.system_channel.send(f"Bye bye **{guild.name}**.")
            await ctx.send("Done")
            return await guild.leave()```
how can i make it work for both name and id of the guild?
dapper cobalt
#

You can ask here.

dapper cobalt
slate swan
#

don't pass in a list

waxen granite
slate swan
#

pass in 2 args

dapper cobalt
#

Ah. Well, replace doesn't take arrays.

#

Just 2 arguments.

covert igloo
#

oh it just worked

tough wagon
#

no square brackets

covert igloo
#

i used pip3 instead of pip

dapper cobalt
dapper cobalt
tough wagon
#

[]

covert igloo
#

ty key

tough wagon
#

yes

dapper cobalt
#

It's called lists..

tough wagon
#

NO

dapper cobalt
#

(arg1, arg2).

tough wagon
dapper cobalt
#

!e

string = "s"
string.replace("s", "a")
print(string)
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

s
tough wagon
#

you use newhex.replace('#','0x') @potent jetty

dapper cobalt
#

Oh. I forgot to re-define.

slate swan
#

nice man

dapper cobalt
#

!e

string = "s"
string = string.replace("s", "a")
print(string)
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

a
dapper cobalt
slate swan
dapper cobalt
#

Btw, @potent jetty if you want to convert RGB, he, and other forms of colors. You can use discord.ext.commands.ColourConverter.

#

!d discord.ext.commands.ColourConverter

unkempt canyonBOT
#

class discord.ext.commands.ColourConverter(*args, **kwargs)```
Converts to a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour").

Changed in version 1.5: Add an alias named ColorConverter

The following formats are accepted...
tough wagon
undone aurora
#

Hey guys, I'm having a quite basic issue that I don't remember how to solve it.

client = commands.Bot(command_prefix = 'Alice, ', case_insensitive=True, self_bot=False)

@client.listen()
async def on_message(message):
    msg = message.content.lower()
    ints = predict_class(msg)
    response = get_response(ints, intents)
    await message.channel.send(response)

This code makes the bot correctly detect a message. However, when it answers that message, instead of answering just a single time, it keeps sending messages over and over. Can someone give me a hint on how to fix this?

stark garnet
#

Hello, I am having an error where the display_strikes command in my code is not being recognized, when I run it with my bot on discord.

This is the error I am getting: discord.ext.commands.errors.CommandNotFound: Command "display_strikes" is not found

This is the cog in which the error is occurring: https://pastebin.com/u4rhJNJn

slate swan
stark garnet
final iron
#

When discord forces bots to transition to slash commands next year will it only be verified bots or all of them?

slate swan
#

verified

high flame
tough wagon
high flame
#

bruh?

tough wagon
#

bruh

#

edited

high flame
#

ask your question

#

and never ask to ask

slate swan
#

he has

tough wagon
slate swan
#

he replied to his question

tough wagon
covert igloo
#

i keep getting this error trying to test out slash commands

high flame
#

i can't scroll

slate swan
#

how come

high flame
#

ah ok

covert igloo
#
import discord
from discord.ext import commands
from discord_slash import SlashCommand

bot = commands.Bot(command_prefix = '!')
slash = SlashCommand(bot, sync_commands = True)

@bot.event
async def on_ready():
    print('Ready')

@slash.slash(name = 'Ping', description='sends pong')
async def ping(ctx):
    await ctx.send('pong!')
covert igloo
#

gives me this error

tough wagon
covert igloo
#

What

hasty iron
#

!traceback

unkempt canyonBOT
#

Please provide a full traceback to your exception in order for us to identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / 0
ZeroDivisionError: integer division or modulo by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (e.g. ZeroDivisionError)
• Make note of the line number, and navigate there in your program.
• Try to understand why the error occurred.

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

tough wagon
#

ok traceback

high flame
#

@tough wagon

#

send full traceback

#

and code again

#

your channel is now unavailable

tough wagon
# high flame <@!644260697194233856>

Info.pypy from Help import Help ... def __init__(self, bot): self.bot = bot bot.help_command = Help(bot) bot.help_command.cog = self ...Help.pypy ... def __init__(self, bot): super().__init__( command_attrs={ 'cooldown': CooldownMapping.from_cooldown(1, 3, BucketType.member), 'description': 'Shows help about the bot, a command, or a category', } ) self.bot = bot ...
full traceback: https://hastebin.com/tadeceguje.sql

covert igloo
high flame
#

bruh?

#

92 lines in it

tough wagon
#

i know

high flame
tough wagon
#

bruh

#

that's a real traceback

edgy meadow
#

I've tried;

await reaction.message.set_field_at(0, "Status:", "Approved", inline=True)

And i got this:
AttributeError: 'Message' object has no attribute 'set_field_at'

How can i fix this?

high flame
#

you mean message.embeds[0].set_field_at?

#

!d discord.Embed.set_field_at

unkempt canyonBOT
#

set_field_at(index, *, name, value, inline=True)```
Modifies a field to the embed object.

The index must point to a valid pre-existing field.

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

Yeah i found that on the offical docs

tough wagon
slate swan
#

how make slash commands?

#
future: <Task finished name='Task-1' coro=<SlashCommand.sync_all_commands() done, defined at C:\Users\marva\python\lib\site-packages\discord_slash\client.py:415> exception=Forbidden('403 Forbidden (error code: 50001): Missing Access')>
Traceback (most recent call last):
  File "C:\Users\marva\python\lib\site-packages\discord_slash\client.py", line 439, in sync_all_commands
    existing_cmds = await self.req.get_all_commands(guild_id=scope)
  File "C:\Users\marva\python\lib\site-packages\discord\http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
#
from discord.ext import commands
 
from discord_slash import SlashCommand
from discord_slash.utils.manage_commands import create_option

import config

client = commands.Bot(command_prefix = '.', intents = discord.Intents.all())
slash = SlashCommand(client, sync_commands = True)
 
 
@slash.slash(name = 'hi', description = 'поприветствовать', options = [{"name": "member", "description": "пользователь", "type": 6, "requied": False}], guild_ids = [680754330022051890])
@client.command(aliase = ['hi'])
 
async def hi(ctx, member: discord.Member = None):
    await ctx.send(f"Передаю привет, {member}!")
 
client.run(config.TOKEN)```
#

im need help

tough wagon
#

first it is aliases not aliase

#

second all is alright idk maybe your bot just dont have perms to slash commands

stone palm
#

how do i edit the value of a specific field in an embed

tough wagon
#

!d discord.Embed

unkempt canyonBOT
#

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

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

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

New in version 2.0.

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

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

how do i edit a specific field

slate swan
#

error:

    ticket_channel = await interaction.author.guild.category.create_text_channel(f"ticket-{interaction.author.name}",
AttributeError: 'Guild' object has no attribute 'category'

Code:

    @commands.Cog.listener()
    async def on_button_click(self, interaction):
        if interaction.custom_id == "support":
            guild = interaction.guild
            for category in guild.categories:
                if category.id == 883942826222686259:
                    break

            if discord.utils.get(guild.channels, name=f"ticket-{interaction.author.name}") is None:
                ticket_channel = await interaction.author.guild.category.create_text_channel(f"ticket-{interaction.author.name}",
                                                                          topic=f"Support ticket for {interaction.author.name}.",
                                                                          permission_synced=True)

                await ticket_channel.set_permissions(interaction.author, read_messages=True, send_messages=True)
                await ticket_channel.set_permissions(guild.default_role, read_messages=False, send_messages=False)
slate swan
#

Everything is in the error

#

Guild object doesn't have category attribute

#

You need to get the category differently

#

Well I tried every other way

#

Keep getting the error

#

Ever tried get_channel

#

And save it in a variable

final iron
#

Anyone know a good async YouTube library to get things like views/likes off a video? Ideally it would have a search function for videos but its not needed

slate swan
#

That will get your account locked by YouTube

final iron
#

Youtube doesn't allow scraping?

slate swan
#

They don't

#

Sub botting, like botting, view botting can get your YouTube channel deleted.

final iron
#

Not what im planning on doing lmao

slate swan
#

Oh you mean

#

Getting information

final iron
#

Yes

slate swan
#

Simply use their API

final iron
#

They have one?

covert igloo
slate swan
#
@bot.command(aliases = ["gamble"])
@commands.cooldown(1, 1, commands.BucketType.user)
async def lottery(ctx):

    def check(message:str):
        return message.author == ctx.author and message.channel == ctx.channel
    await ctx.send(f"how many {random.choice(bananalist)} gamble???")
    message=await bot.wait_for('message', check=check)

    await open_account(ctx.author)

    users = await get_bank_data()

    user= ctx.author

    lotterywin = message.content * random.randrange(1, 3)

    await ctx.send(f"you have won {lotterywin} {random.choice(bananalist)}")

    users[str(user.id)]["wallet"] += lotterywin```

How can I fix this?
#

I know str can't += int, so i changed the last line to

users[str(user.id)]["wallet"] += int(lotterywin)```
#

that gave no error, but didn't actually add the 'lotterywin' to the wallet

#

what am i doing wrong?

slate swan
#

how to make a cogs file but for custom emojis?

slate swan
#

ohhh oops lmfao

slate swan
slate swan
stark garnet
#

Anybody know where I can find a list of all discord.py events?

covert igloo
#

whats the error

tulip oracle
#

what would be the best method to iterate through a list using tasks loop to change the status. and on each task loop go down each element of the list, rather than what i imagine is start from the first element over and over

tulip oracle
# covert igloo

idn if that space between startswith and your ("CLICK") was intended?

unkempt canyonBOT
#

itertools.cycle(iterable)```
Make an iterator returning elements from the iterable and saving a copy of each. When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely. Roughly equivalent to:

```py
def cycle(iterable):
    # cycle('ABCD') --> A B C D A B C D A B C D ...
    saved = []
    for element in iterable:
        yield element
        saved.append(element)
    while saved:
        for element in saved:
              yield element
```...
hasty iron
#

or if that’s not what you want, you can just pop from the list

runic jackal
#

when I send an array there are still the square brackets, the quotes and the commas.
how do i get that away?

final iron
#

Google documentation

#

You would create a variable with the characters you don't want

#

Then loop through the message replacing the blacklisted characters with ""

slate swan
#

or just use strip

#

or join

runic jackal
final iron
slate swan
#

msg = " ".join(list)

final iron
#

Also probably not the best solution

dapper cobalt
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

a
runic jackal
covert igloo
#

i get this error trying to add slash command

dapper cobalt
runic jackal
dapper cobalt
#

!e

names = ["Seif", "Wessam"]
print(" - ".join(names))
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

Seif - Wessam
dapper cobalt
#

This made a - join in-between the items in the list names.

runic jackal
dapper cobalt
#

No problem.

dusk dust
#

how do i can create an embed with a button? and this button do something

final iron
dusk dust
final iron
#

You would need to find a lib that supports them

dusk dust
#

the discord.components don't work more?

final iron
#

I have no idea tbh

pliant gulch
#

Where are you trying to mention them in?

dapper cobalt
#

@slate swan = @slate swan

#

And also, if you're trying to achieve that in an embed's title, footer, field name or author name, it will not work.

pliant gulch
#

It will render the ping

#

but it won't actually send a notifcation

#

in embeds

dapper cobalt
#

No problem. a_thumbsup

dusk dust
#

try

authorid = f"<@{ctx.author.id}"

embed = discord.Embed(
  title = "title's here",
  description = "description's here",
  color = colour here
)

embed.add_field(name="pinging you", value="authorid")
``` i think that this works
dusk dust
dapper cobalt
#

Why authorid = f"<@{ctx.author.id}"?

#

Just ctx.author.mention.

#

And also, you used the variable inside strings in the value kwarg.

dusk dust
#

gives the same

dapper cobalt
#

No?

dusk dust
#

this work's with me

dapper cobalt
unkempt canyonBOT
#

@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.

value
dapper cobalt
#

You used the variable in strings, how would it work?

dusk dust
#

authorid = f"<@{ctx.author.id}"

embed.add_field(name="pinging you", value="authorid")

the "<@>" is a string that will help me make the code work, and the id stay on middle @dusk dust

dapper cobalt
dusk dust
#

ah

#

sorry

#

value=authorid

#

i didn't see this

dapper cobalt
#

And also discord.Member.mention returns <@user-id>, so no need for this hassle.

#

!d discord.Member.mention

unkempt canyonBOT
dapper cobalt
#

Try value=ctx.author.mention.

dusk dust
#

there are several ways, I do it this way because I think more didactic

honest wing
#

How could I make a command that stores how much of a item someone bought

Example

add @honest wing 100
check @honest wing | returns 100

add @honest wing 1042
check @honest wing | returns 1142

  • I know I would need to use a dict, but I suck with them so if you could help me out, I would appreciate it.
slate swan
#

you wouldn't have to use a dict

#

that's the exact opposite of what we tell people...

#

use a database

honest wing
vague grove
#

why am i getting repeated people in my json leaderboard?
code here:

@client.command(aliases = ["lb"])
async def leaderbard(ctx):
    users = await get_bank_data()
    leader_board = {}
    total = []
    for user in users:
        name = int(user)
        total_amount = users[user]["wallet"]
        leader_board[total_amount] = name
        total.append(total_amount)

    total = sorted(total,reverse=True)

    em = discord.Embed(title = ftop 5 leaderboard: " , description = "Top 5 credit leaderboard",color = discord.Color(0xfa43ee))
    index = 1
    for amt in total:
        id_ = leader_board[amt]
        member = client.get_user(id_)
        name = member.name
        em.add_field(name = f"{index}. {name}" , value = f"{amt}",  inline = False)
        if index == 5:
            break
        else:
            index += 1

    await ctx.send(embed = em)

and in the json, there are no repeats there
in the ids or anything

final iron
#

Btw you spelt leaderboard wrong

slate swan
#

It says: Command raised an exception: AttributeError: 'Bot' object has no attribute 'open_account'My Code: py @commands.command() async def balance(self, ctx): await self.client.open_account(self, ctx.author) user = ctx.author users = await get_bank_data() wallet_amt = users[str(user.id)]["wallet"] bank_amt = users[str(user.id)]["bank"] em = discord.Embed(title = f"{ctx.author.name}'s balance",color = discord.Color.red()) em.add_field(name = "Wallet",value = wallet_amt) em.add_field(name = "Bank balance",value = bank_amt) await ctx.send(embed = em)

vague grove
#

got any clue for the repeated people?

final iron
#

On phone atm so incredibly hard to read

somber musk
#

!e

print('hi')
unkempt canyonBOT
#

@somber musk :warning: Your eval job has completed with return code 0.

[No output]
somber musk
#

!e

unkempt canyonBOT
#

@somber musk :white_check_mark: Your eval job has completed with return code 0.

hi
somber musk
#

How you can code on the bot

slate swan
somber musk
slate swan
#

That's basic python

#

yes

somber musk
#

To code a discord bot?

slate swan
#

No, to make the eval command

#

The solution I told you is beginner knowledge

somber musk
#

I'm talking about the discord bot @unkempt canyon Development

slate swan
#

U asked about coding on the bot which is what the !e command does

somber musk
#

I never asked a question I just said "that's so cool How you can code on a bot"

slate swan
#

I- that's exactly why y'all people should put every sentence and word that's in the same context in the same message instead of sending one message for each sentence

#

The way you did it seemed as if you asked how it's done 🤷‍♂️

somber musk
#

But I understand how u got confused

slate swan
somber musk
#

Yea probably aren't fluent in English which is ok

final iron
#

@somber musk rephrase your question

somber musk
#

What?

final iron
#

Please

#

What was your question

somber musk
#

My sentence makes sense and even @slate swan understands now

#

It wasn't a question

slate swan
#

😂

somber musk
#

I never asked a question I just said "that's so cool How you can code on a bot"

final iron
#

It wasn't on the same line but okay

slate swan
#

i didn't just say that earlier

somber musk
#

GOD DAMN I don't understand you guys "how you can code a bot" isn't even a question

final iron
#

English isn't everyone's first language

#

Some people come here with bad grammar

slate swan
#

^

somber musk
slate swan
#

Does anyone know how to make a discord bot that sends messages to people promoting their server?

final iron
#

Chill with the passive aggressive shit dude

somber musk
#

That's why I put a ":)"

somber musk
final iron
#

You wouldn't want to check for that

#

You would want to check for an actual invite

slate swan
#

Use regex and check for discord invite

slate swan
slate swan
#

yeah

somber musk
final iron
slate swan
#

^

final iron
slate swan
final iron
somber musk
slate swan
#

this type of bot

#

Message got deleted

final iron
somber musk
hot sparrow
#

Someone knows about telegram bots?

final iron
hot sparrow
final iron
hot sparrow
#

I'm still learning python tho

final iron
#

Are you talking about the messaging service

hot sparrow
#

I'm creating a bot for telegram

#

I want my bot to send a message in an specific chat every X time

final iron
hot sparrow
#

Mb

#

What's the chat for this type of question?

final iron
hot sparrow
#

Thanks you 😊

slate swan
#

Anyone know why this won't work?


with open("characters.txt", encoding="utf8") as file:
    letters = file.read().split('\n')

letters = tuple(letters)




@bot.listen()
async def on_member_update(before, after):
    if before.nick.startswith(letters):
        await after.edit(nick=f'Inaproprite Name')```
#

I don't have any errors

pliant gulch
#

Do you have member intents enabled?

#

Since this event requires that in order to properly dispatch

lilac latch
slate swan
slate swan
#

And I didn't notice the spelling mistake lol

lilac latch
lilac latch
odd walrus
#

is it possible if i were want to send out whole list content into
list = ["a","b","b"}
^ adding this list into an embed making it become
a
b
c

slate swan
#

use py "\n".join(listname)

#

help how to fix?!?!?

#

you miss a : after a if/elif/else statement or a function

#

ok

#

and the variables are not defined....

dapper cobalt
final iron
odd walrus
gaunt herald
gaunt herald
dapper cobalt
final iron
gaunt herald
gaunt herald
dapper cobalt
gaunt herald
#

Ok

gaunt herald
atomic topaz
#

how to check if someone joins a specific guild?

#

having the guild's ID

graceful gulch
atomic topaz
gaunt herald
slate swan
#

do you get a [] in the console?

gaunt herald
#

this is error

paper fern
#

?

#

Go to a help channel if you want a fix for an error

gaunt herald
#

ok

paper fern
#

It’s a big error

gaunt herald
slate swan
#

!Paste if its a long one

unkempt canyonBOT
#

Pasting large amounts of code

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

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

gaunt herald
#
IndexError: list index out of range

#

this is error

slate swan
#

i asked , what does print(search_results) print

gaunt herald
#

search_results = re.findall('href=\"\\/watch\\?v=(.{11})', htm_content.read().decode())

gaunt herald
slate swan
#

i dont think so

gaunt herald
#

wait

#
UnboundLocalError: local variable 'search_results' referenced before assignment```
#

i did it this error coming

gaunt herald
slate swan
gaunt herald
#

oh

gaunt herald
boreal ravine
#

whats a code camp discord bot

gaunt herald
crystal wind
#

I’m out of ideas for custom commands for my bot. Does anyone have ideas? I’ve already made a fake nitro command. Perhaps games?

brisk fiber
crystal wind
#

Oh god

#

I was thinking more of like fun commands that I could make for entertainment, since my bot’s purpose is to entertain.

vernal osprey
#

How do I do live timer?

hollow agate
#

Could someone give me an example of storing a user's ID to a MySQL database?

vernal osprey
brisk fiber
vernal osprey
boreal ravine
#

i think he means read the documentation

brisk fiber
#

yeah haha

#

discord.ext.tasks

vernal osprey
#

Ok

brisk fiber
#

i think that helps you schedule events

boreal ravine
#

hm

brisk fiber
#

@hollow agate forgot to ping ^

hollow agate
#

MySQL with phpMyAdmin

#

If that's what you mean

slate swan
lilac latch
#

How to get a list of servers my bot is in??

slate swan
#

for guild in bot.guilds:

tough wagon
unkempt canyonBOT
#

set_field_at(index, *, name, value, inline=True)```
Modifies a field to the embed object.

The index must point to a valid pre-existing field.

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

Merged my documentation and now my python discord wrapper turned into an HTML repo 👁️ 👄 👁️

maiden fable
#

Lmfao

#

Imagine a Discord API Wrapper in HTML

tough wagon
stark hearth
#
    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def ban(self, ctx, member : discord.Member=None, reason=None):
        if reason == None: 
            reason = 'No reason provided.'
        
        await member.ban(reason=reason)
        
        embed = discord.Embed(
            title = 'User Banned', 
            description = f'{ctx.message.author.mention} banned {member.mention} from {ctx.guild.name}. Reason: `{reason}`' 
            )
        
        await ctx.send(embed=embed)

i want owners of server able to ban moderators but it pops out an command error

#

what do i add

maiden fable
#

!d discord.ext.commands.check_any

unkempt canyonBOT
#

@discord.ext.commands.check_any(*checks)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if any of the checks passed will pass, i.e. using logical OR.

If all checks fail then [`CheckAnyFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckAnyFailure "discord.ext.commands.CheckAnyFailure") is raised to signal the failure. It inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Note

The `predicate` attribute for this function **is** a coroutine.

New in version 1.3.
maiden fable
pliant gulch
maiden fable
#

Lmao

lilac latch
tough wagon
#

@pliant gulch that's not topic of this channel

pliant gulch
tough wagon
unkempt canyonBOT
lilac latch
tough wagon
lilac latch
#

Wait no

maiden fable
#

wrapper in HTML

lilac latch
#

I want all the guild bot is in

maiden fable
#

Yeaaa

stark hearth
maiden fable
#

bot.guilds bro

#

It returns a list of Guild objects

tough wagon
slate swan
tough wagon
#

cogs/info.py```py
from discord import Embed, Color, Member, Status
import discord
from datetime import datetime
from discord.ext.commands import Cog, command, cooldown, BucketType
from discord.abc import GuildChannel
from typing import Optional

from config import owners
from cogs.help import Help

...

class Info(Cog):
def init(self, bot):
self.bot = bot
self.description = "Information commands"
self.start_time = datetime.utcnow()
self.ver = 1.0
self._original_help_command = bot.help_command
bot.help_command = Help(bot)
bot.help_command.cog = self

...*cogs/help.py*py
from discord.ext.commands import HelpCommand, BucketType, CooldownMapping
from discord import Embed, Color

class Help(HelpCommand):
def init(self, bot):
super().init(
command_attrs={
'cooldown': CooldownMapping.from_cooldown(1, 3, BucketType.member),
'description': 'Shows help about the bot, a command, or a category',
}
)
self.bot = bot

...``` @slate swan

slate swan
#

can you show more?

tough wagon
#

what more?

slate swan
#

cog and help code?

#

that's not enough

slate swan
tough wagon
slate swan
#

yes

#

just call super and you're good

tough wagon
#

okay thank you

tough wagon
#

super.context.bot?

slate swan
#

no

tough wagon
#

self.context.bot?

slate swan
#

super refers to your parent class that you subclass

tough wagon
#

uh okay i will try self

#

thanks, it's working now! @slate swan

slate swan
#

sure

tough wagon
#

me dumb thought ctx.bot returns Bot class xD

slate swan
#

thats fine

gloomy coral
#

hi

#
@bot.event
async def on_message(message):
    db = TinyDB('databases/blacklist.json')
    member = message.author.id
    try:
        query = Query()
        blacklisted_guild = db.search(query['guild_id'] == message.guild.id)
        blacklisted_peeps = None
        for i in range(0, len(blacklisted_guild)):
            if str(member) in str(blacklisted_guild[i]):
                blacklisted_peeps = blacklisted_guild[i]
        if blacklisted_peeps is not None:
            return
    except:
        print("It's a DM")

    db2 = TinyDB('databases/afk.json')
    query = Query()

    for member in message.mentions:
        if db2.search(query['afk_user'] == member.id):
            value = str(
                list(
                    map(lambda entry: entry["reason"],
                        db2.search(query['afk_user'] == member.id)))[0])
            await message.channel.send(
                embed=discord.Embed(title=f"{member.display_name} is currently afk",
                                    description=f"Afk note is: {value}",
                                    color=discord.Color.random()))

    member = message.author
    if db2.search(query['afk_user'] == member.id):
        await message.channel.send(embed=discord.Embed(
            title=f"{member.display_name} You typed a message!",
            description=f"That means you ain't afk!\nWelcome back buddy.",
            color=discord.Color.random()))

        query = Query()
        db2.remove(query.afk_user == member.id)
    await bot.process_commands(message=message)```
#

This is my old bot.py, on msg code

#

i tried moving it to an events cog

tough wagon
#

and?

gloomy coral
#

it doesnt work......

#

one sec

tough wagon
#

error?

gloomy coral
#

yeah giving

tough wagon
#

what one

gloomy coral
#

Ok so basically, now if i do -afk eating food then it shows....

tough wagon
#

it shows??

gloomy coral
#

It used to work before

#

also now if you blacklist someone...... then the bot considers their commands

#

it would work before i moved it... idk why

boreal ravine
#

How would I go about restricting certain emoji's to certain roles? like if a user has Level 10 role they can use the 🍞 emoji but users without that role cannot.

gloomy coral
#

AFK COMMAND(If you need)

@commands.command()
    async def afk(self,ctx, *, reason=None):
        if reason is None:
            embed = discord.Embed(title="Give ME A REASON",
                                description="You can't be afk for ___",
                                color=discord.Color.random())
            embed.set_footer(text="That's Louis' job")
            await ctx.send(embed=embed)
            return

        if len(reason) > 30:
            embed = discord.Embed(title="I'm sorry.",
                                description="I got bored reading your LONG reason.\nSo I ignored it.",
                                color=discord.Color.random())
            embed.set_footer(text="Nothing more than 30 characters please")
            await ctx.send(embed=embed)
            return

        db = TinyDB('databases/afk.json')
        db.insert({'afk_user': ctx.author.id, 'reason': reason})
        
        await ctx.send(embed=discord.Embed(title=f"Ok {ctx.author.display_name}.",
                                        description=f"I have set your status as afk for {reason}.",
                                        color=discord.Color.random()))```
gloomy coral
#

Unblacklist and blacklist command if you need

gloomy coral
gloomy coral
#

thts rlly cruel tho ngl 😄

boreal ravine
#

i've seen sounds world do this I don't know how

boreal ravine
lament mesa
boreal ravine
tough wagon
#

@gloomy coral when you use afk command it puts you into afk, but it's a message and after executing that command it checks if user is afk in on_message event and makes him, so you need to check if content startswith {prefix}afk

lament mesa
boreal ravine
lament mesa
#

!d discord.Guild.create_custom_emoji

unkempt canyonBOT
#

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

Creates a custom [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji") for the guild.

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

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

There is a roles parameter

gloomy coral
boreal ravine
lament mesa
dim cedar
#

i have a question

tough wagon
dim cedar
#

i made 3 bot.event but only the last one is working

boreal ravine
dim cedar
boreal ravine
gloomy coral
dim cedar
#
async def on_message(message):
  try:
    if message.mentions[0].id ==760010546728402975:
        user = await message.guild.fetch_member(760010546728402975)
        guild = message.guild
        mee6_muted_id = 882886302196957204
        mutedrole = discord.utils.get(guild.roles, id =mee6_muted_id)
        await sleep(1)
        await user.remove_roles(mutedrole)
  except:
    pass    
          
  await bot.process_commands(message)```
maiden fable
boreal ravine
#

@commands.Cog.listener() is for only inside cogs though

gloomy coral
#

and thts the rule

tough wagon
#

if message.content.startswith('{your_bot_prefix}afk'): return @gloomy coral

boreal ravine
boreal ravine
#

u can have multiple events tho

boreal ravine
tough wagon
maiden fable
dim cedar
boreal ravine
gloomy coral
boreal ravine
#

it depends on what event tho

gloomy coral
#

omg

#

im so dumb

#

i thought tht he was using 3 bot.events for on_message

#

sorry dude, have a good day im out

boreal ravine
gloomy coral
dim cedar
#

right?

dim cedar
tough wagon
#

wdymean

#

XDDDDDDDDD

#

read context bruh

#

he has command

#

xd

#

omfg

#

read context bruh

#

he has afk command

#

and on_message with disabling afk users

#

and when he types command

#

it makes afk

#

and on_message disables afk

#

ok

near oyster
#

Is there a better alt to Discord.py?

Pls i need a answer

tough wagon
#

wdym as better alt

near oyster
#

rly?

tough wagon
#

what rly

#

i asked question: what do you mean as better alt?

near oyster
#

yes

#

a better alt

tough wagon
#

ehhhh

near oyster
#

?

#

cuz its development is shutting down soon

tough wagon
#

discord.py is a library for python there is alternative as nextcord but I don't think it's much better (my point of view) or you can use other langs as js (faster then python but harder syntax)

#

@near oyster

near oyster
#

yes

#

buttheres a prblem

#

the porblem is tht my computer is not fast enough for node
it takes 5 hrs just to run a node js program

tough wagon
#

oof, then idk here is python server not nodejs to help you for that...

near oyster
#

oh

#

i guess pycord is a better alt

tough wagon
#

idk, im not good at that, i just use dpy)

outer basalt
#
class Batch(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

        self.dispatcher_cog = bot.get_cog("Dispatcher")

why dispatcher_cog is None?

tough wagon
#

because cog Dispatcher not exists?

slate swan
# near oyster i guess pycord is a better alt

you should choose whichever you like since most have the same capabilities because they are wrappers of the same api (not the same structure or design tho)
however, i would suggest sticking to d.py till it stops working entirely or gets too outdated, because you cant know for sure if the alternative you will switch to will get discontinued after a while or ends up messed up. So that by the time d.py is gone completely there will most likely be other "good" successors with an OK reputation you can transfer to

#

anyways, if you are willing to switch to an alt regardless, I have read some nice things about hikari but I cant say for sure

tough wagon
#

ctrl+F ?

#

but you are using some command

#

and it is replying with this on it

#

right?

#

find in files

stark bobcat
#

hlo

#
 for idx in range(len(total_roles)):
            print(total_roles[idx]) 

        embed.add_field(name=f"Members: {total_members}", value=f"Roles : {index_roles}")```
spring flax
#

you want the roles of a guild and members in a guild?

#

!d discord.Guild.member_count

unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
stark bobcat
spring flax
#

!d discord.Guild.roles

unkempt canyonBOT
#

property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
spring flax
stark bobcat
spring flax
tough wagon
#

[role.name for role in <discord.Guild>.roles]

spring flax
#

^

stark bobcat
#

oh

#

ok thanks

gloomy quest
#

Hi

#

Is there an attribute like

#

discord.channel?

#

Like i want to do this

tough wagon
#

there is a class discord.Channel

gloomy quest
#

ohh nice thx

boreal ravine
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

boreal ravine
#

it's discord.TextChannel

#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
tough wagon
#

ohhh

#

@gloomy quest

#

!d discord.abc.GuildChannel

unkempt canyonBOT
#

class discord.abc.GuildChannel```
An ABC that details the common operations on a Discord guild channel.

The following implement this ABC...
gloomy quest
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

gloomy quest
#

confusion

boreal ravine
#

abstract classes cool

#

!d discord.DMChannel

unkempt canyonBOT
#

class discord.DMChannel```
Represents a Discord direct message channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns a string representation of the channel
tough wagon
#

or this ^

gloomy quest
#

no

#

thats dm channel

tough wagon
#

ye

#

s

gloomy quest
#

It turned out to be discord.TextChannel

tough wagon
#

okay then discord.TextChannel

slate swan
#

where can i go to learn about making an app?

#

👍

#

never knew what they are called lol

#

cool

#

yeah cool, was just curious on where to start since i had no clue on where to search for them ¯_(ツ)_/¯

edgy meadow
#

Does anyone know the max ammount of text channels a server can have?

bright palm
#

IIRC 500 including voice channels

tough wagon
#

TextChannel | MAX
VoiceChannel | LIMIT
StageChannel | =
CategoryChannel | 500

#

like this? @bright palm

#

or not including category or stage channels?

bright palm
#

Not sure if it includes stage channels it won't include categories but you can only have 50 channels per category and there might be other limits

tough wagon
#

ok

vocal plover
#

categories == category channels

tough wagon
#

xd

vocal plover
#

categories are just special channels

tough wagon
#

@bright palm xD

slate swan
#

name is not defined, might want to use args (like in your parameters list)

#

And you realize it will change the name of every single channel right?

tough wagon
#
@bot.command()
async def rename(ctx, *, args):
    await ctx.message.delete()
    for channel in ctx.guild.channels:
        await channel.edit(name=args)``` im just lazy to not spoonfeed
#

@leaden onyx

#

use that code

slate swan
#

Should be punishable like in other servers NotLikeThis

tough wagon
#

idk

river kindle
#

hi guys, i had a question, how do i set this missingpermissions to this command? because if i try to use it, missing permissions doesn't work.

here the code

@ commands.is_owner ()
async def dis (ctx, *, command):
        command = client.get_command (command)

        if command is None:
            await ctx.send ("There is no command with that name.")

        elif ctx.command == command:
            await ctx.send ("You don't have enough permissions.")

        else:
            command.enabled = not command.enabled
            ternary = "enabled" if command.enabled else "disabled"
            await ctx.send (f "The command` {command.qualified_name} `was ** {ternary} **")
@ dis.error
async def dis_error (ctx, error):
    if isinstance (error, MissingPermissions):
        await ctx.send (f'You don't have enough permissions to run this command. ')```
slate swan
unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
slate swan
#

use this decorator , or since you have is_owner() check , you must use NotOwner expception in the isinstance

#

How do I make my bot edit the perms of a channel?

slate swan
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

slate swan
#

wait

unkempt canyonBOT
#
Nope.

No documentation found for the requested symbol.

tough wagon
#

!d discord.TextChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

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

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

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

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

overwrites (Mapping) – A Mapping of target (either a role or a member) to PermissionOverwrite to apply to the channel.

river kindle
#

hi guys, i'm creating a command that is used to disable the commands you don't want, but if i try to disable it the bot disables the command in ALL the servers it is in, i want only the person who disables the command to be disabled only on that server. Does anyone know how to do?

slate swan
#

Use a way to store if the command is disabled or not in the guild, example: a database

tough wagon
slate swan
#

Why checking on each command?

tough wagon
#

or cog_check

tough wagon
slate swan
#

Whatever

#

This exists

#

on_command

#

It's called when a command is found and about to get invoked

#

No it's discord.on_command

#

Like any events

tough wagon
#

nope

#

only this in 2.0

slate swan
#

Yeah like 99.9%

tough wagon
#

no on_command

slate swan
#

Jeez

#

Are we talking about 2.0?

#

No

#

So don't come with the shit 2.0 stuff

#

And on 2.0 it also exists just not discord.on_command

#

!d discord.discord.ext.commands.on_command

unkempt canyonBOT
#

discord.ext.commands.on_command(ctx)```
An event that is called when a command is found and is about to be invoked.

This event is called regardless of whether the command itself succeeds via error or completes.
slate swan
#

There

tough wagon
#

discord.discord wt...

#

uh okay it is ext commands sry my bad

tough wagon
slate swan
#

It's not

#

It's not even stable

tough wagon
#

eh okay...

slate swan
#

Latest is not 2.0

tough wagon
#

1.7.3 then?

cloud dawn
slate swan
#

If you're referring to the word 'shit' and you read the entire sentence you can see it was referring to the 2.0 stuff, which is indeed shit.
And considering 2.0 is not even officially released, 100% of the users who come with basic issues definitely do not have 2.0 so coming and saying something doesn't exist in 2.0 (which even still does exist) makes everything even more irrelevant to the conversation.

#

And let's not mini mod as no servers like it

cloud dawn
#

And why is not having 2.0 an issue?

slate swan
#

My point was

#

Saying that something doesn't exist in 2.0, which even does because you can't search

#

Why come up and say it doesn't even exist and mislead people

#

Even if it's 2.0 or not, doesn't matter

cloud dawn
#

Ah, sorry i kinda misunderstood then.

solar pike
#

can we add a folder in cog? will the cmd run if the the py is in that folder?

lament mesa
#

no, use os.listdir on that folder and use bot.load_extension on each file in that folder

#

!d os.listdir

unkempt canyonBOT
#

os.listdir(path='.')```
Return a list containing the names of the entries in the directory given by *path*. The list is in arbitrary order, and does not include the special entries `'.'` and `'..'` even if they are present in the directory. If a file is removed from or added to the directory during the call of this function, whether a name for that file be included is unspecified.

*path* may be a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object). If *path* is of type `bytes` (directly or indirectly through the [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike "os.PathLike") interface), the filenames returned will also be of type `bytes`; in all other circumstances, they will be of type `str`.

This function can also support [specifying a file descriptor](https://docs.python.org/3/library/os.html#path-fd); the file descriptor must refer to a directory.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `os.listdir` with argument `path`.
solar pike
#

how to make custom help command?

slate swan
solar pike
#

👀

slate swan
#

that really isnt basic

solar pike
#

k

solar pike
slate swan
#

How to use multiple bots in single file without typing whole program again and again?

#

You don't

boreal ravine
#

Is there something to fetch a message then edit it?

manic wing
slate swan
manic wing
#

so you have bot a that runs it and you also want bot b to run the same thing?

slate swan
#

Yea

odd walrus
#

But why do you want that

boreal ravine
manic wing
#

you simply can. easily

odd walrus
slate swan
boreal ravine
#

@slate swan have u at least tried doing it before asking for help?

slate swan
#

Please tell I am going to tution I will check later sorry bye

slate swan
boreal ravine
odd walrus
#

Relax

manic wing
#

a) you can copy and paste the files and replace token and link it to main with os.system and running the other file
b) use some asyncio thing to make the second client.run, its like get_running_loop or smthing
c) make a thread for it @slate swan

slate swan
#
from discord.ext import commands

import json
import os

import config

@bot.command(description="Mutes the specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")

    if not mutedRole:
        mutedRole = await guild.create_role(name="Muted")

        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)

    await member.add_roles(mutedRole, reason=reason)
    await ctx.send(f"Muted {member.mention} for reason {reason}")
    await member.send(f"You were muted in the server {guild.name} for {reason}")

@bot.command(description="Unmutes a specified user.")
@commands.has_permissions(manage_messages=True)
async def unmute(ctx, member: discord.Member):
    mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")

    await member.remove_roles(mutedRole)
    await ctx.send(f"Unmuted {member.mention}")
    await member.send(f"You were unmuted in the server {ctx.guild.name}")

bot.run(config.TOKEN)```
#
Traceback (most recent call last):
  File "C:\Users\marva\Desktop\test\main.py", line 9, in <module>
    @bot.command(description="Mutes the specified user.")
NameError: name 'bot' is not defined
#

im need help

#

Everything is in the error

#

You never created a bot variable

boreal ravine
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

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

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

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
manic silo
slate swan
odd walrus
#

Making a discord bot

async def novaaa(ctx, a, b)

I did it like shown above
It takes in info when i do

!novaaa abc hab

But it doesnt take in info when done like this

!novaaa abc hab
Haj
Jha

I want the b to take everything even in next line any suggestions?

boreal ravine
manic wing
boreal ravine
#

hm

manic wing
#

its like a big while bot_running loop

elder bear
#

You can't run two at once well

slate swan
manic wing
elder bear
#

"well"

slate swan
#

It's useless pain

elder bear
#

If you're going to run two bots, run two scripts.

slate swan
#

Just run the bot with a token argument

#

And run the file twice

elder bear
#

Because then you now have two bots which can only use a single core shared between them and that won't be fun

odd walrus
manic wing
#

so like

boreal ravine
manic wing
#

.split('\n')[0]

odd walrus
#

Yes correct

manic wing
odd walrus
#

issue with is is i want to do

!novaaa abc hab
habc
hah

then maybe i can append the hab habc and hah into a list
But in order for me to do so, i need the bot to somehow get the habc hah

#

Possibility of me saving it as message content then splitting it? Hmm

visual island
boreal ravine
#

you can use an asterisk in the args to make the bot read all the args

boreal ravine
odd walrus
#

Ahh

patent surge
#

Hello I need help

odd walrus
#

Aight will give it a try later

patent surge
#

await bot.process_commands(message)
This code not working
I am giving command in message but command is not working

slate swan
#

Show the entire event code

patent surge
#
async def on_message(message):
    not_restricted_chan = await events.is_not_restricted_channel(message)
    if not_restricted_chan :
        print("Entered")
        if bot.user.mentioned_in(message):
            await message.channel.send("Hello I am Minecord the ultimate Minecraft Discord Bot, my prefix is ```m!```.")
        elif "start" in message.content[2:] or "help" in message.content[2:]:
            print("processing command")
            await bot.process_commands(message)
        elif await events.has_profile(message):
          chance = random.randint(1,3)
          if chance == 1:
              game.xp_manager(message, random.randint(1, 3))
          await bot.process_commands(message)
        else:
          await  message.channel.send(f"{message.author.mention} you haven't created a profile, create a profil  by the ```start``` command and start playing.")```
slate swan
#

What is events.is_not_restricted_channel()

patent surge
#

Checking for if the channel is not set to restricted one

slate swan
#

Does it print Entered

patent surge
#

Yes

slate swan
#

Why do you check if the content has start or help

#

Just process commands normally without checking that

patent surge
#

ok but

slate swan
#

Put the process_commands after the else

patent surge
#

It prints ```processing command``
but after that the command doesn't runs

slate swan
#

yeah, this is only gonna process commands if the start thing is true

#

Just put it at the end

#

Only once

valid perch
#

Wait for it to get approved

serene lynx
solar pike
#

code for keeping inline false
in embed

boreal ravine
#
@bot.event
async def on_message(ctx):
  if len(message.content) > 5:
    await message.channel.send("yes")
``` soo i was doing this then my bot kept spamming the channel. Why?
boreal ravine
solar pike
#

got it

grand anvil
#

which is the right channel to ask something about aiohttp error

manic wing
#

you can ask here if you want

manic wing
grand anvil
manic wing
#

ok, both work as they’re pretty much both asynchronous shit

solar pike
#

is there any pip for reddit memes?

silent summit
boreal ravine
#

what does mean

vale narwhal
#

simple

boreal ravine
#

wait

vale narwhal
boreal ravine
#

OH ok i didnt think of that

#

brb

slate swan
#

buttons dont seem to work?

#

it always says Interaction failed

vale narwhal
#

button for python little bit buggy idk why fh_yikes

slate swan
#

😦 so sad

boreal ravine
vale narwhal
solar pike
#

what is the footer code? for embed?

vale narwhal
#

Which button you're using

slate swan
#

I dont have nitro so its a lil hard to send

#

hold on.

vale narwhal
solar pike
vale narwhal
#

Big at the bottom or right top

solar pike
#

in footer the small one

unkempt canyonBOT
#

Hey @slate swan!

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

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

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

https://paste.pythondiscord.com

vale narwhal
#

Hmm

slate swan
#

:/

vale narwhal
#

@slate swan go paste it in pastebin or any paste service

slate swan
#

Hey guys

#

What's embeds?

vale narwhal
vale narwhal
vale narwhal
solar pike
slate swan
#

heres the pastedbin

#

password is password ¯_(ツ)_/¯

vale narwhal
#

@solar pikeembed.set_footer(text="whatever", icon_url="https://www.nab.nab/nab")

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @vale narwhal until <t:1633785301:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 115 newlines in 10s).

slate swan
#

uh

#

wot

vale narwhal
slate swan
vale narwhal
vale narwhal
slate swan
#

yep

boreal ravine
unkempt canyonBOT
#

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

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

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

can i add eet in the timezone and no utc

#

?

#

also , did you import Button from discord_components?

slate swan
slate swan
#

from discord_components import *

vale narwhal
slate swan
boreal ravine
#

!d discord.Embed.set_footer @solar pike if u were looking for this

unkempt canyonBOT
#

set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.

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

but Im not using slash commands

#

ye my mistake , just a second

vale narwhal
#

button confusing sometimes 02shrug

slate swan
#

yes

#

reaction pagination feels old..so wanted to ue buttons,but NOPE

#

you must try using type ids instead of ButtonStyle

slate swan
slate swan
#

hmm

#

why would that make buttons not work tho :/

#

the error appears when you click a button right?

slate swan
#

yk that This interaction failed thing

slate swan
slate swan
# slate swan <:lemon_thinking:754441881420562433>
from discord_components import Button
msg = await _ctx.send( embed=discord.Embed(description="hmm"), components= [Button(label="Invite",url="https://google.com",style=5) ])
#you send the embed

#on interaction:
await msg.edit(components= [Button(label="edited",url="https://google.com",style=5) ])```
#

ty! Imma try

bright palm
slate swan
#

What's function for this example:

If there are 2 members in General Voice Channel, Change the Voice limit.

The thing is I don't know how to tell the program when there are 2 members

bright palm
#

Unless whatever you are using handles buttons differently

slate swan
unkempt canyonBOT
slate swan
#

len(voice.members)

slate swan
#

So if there is 2 make it 3 if there is 3 make it 4?

#

oh... that wouldn't work :/

#

Can't we fetch voice members?

#

So...

if len(voice.memberr) == Members:
channel.edit(limit += 1)
else:
    channel.edit(limit -= 1)
#

right?...

slate swan
#

but indents

#

What do you mean

#

except

#

voice is gotta be your channel object

#

How can I tell the program to fetch voice channel members count

#
limit = 2
if len(voice.members) == limit:
    limit += 1
#

exactly like this?

#

Yes

#

But, If there is no body in the channel, the channel limit should be 2

#

How the program will know that?

#

We gotta fetch it right?