#discord-bots

1 messages · Page 760 of 1

final iron
#

Option 1, 2 or 3

#

Would I use 3?

fervent shard
#

i coded them in blocks and the command doesnt work

slate swan
#

why the heck do people ask for pay jobs for just an easy issue when theres many people who can solve the issue for** FREE**pithink

#

save your money kidspithink

tiny ibex
#

Anyone?

slate swan
#

youll need to update the view

#

with new buttons

final iron
#

gn yall. Tmr I think ill make a info command with ping, uptime, cpu usage, ram usage the system specs and how many commands have been run

tiny ibex
slate swan
tiny ibex
potent spear
slate swan
#

but your asking on how to?

tiny ibex
#

Why?

#

I don't wanna update buttons

slate swan
#

^

tiny ibex
slate swan
slate swan
#

and i gaved it

tiny ibex
#

That it will listen even after restart?

slate swan
#

nope

tiny ibex
#

Oh well imma try editing the message then with new buttons

slate swan
#

with new buttons thats all you have to do

#

yes

tiny ibex
slate swan
tiny ibex
slate swan
edgy finch
#

hi

#

!resourses

ancient whale
#

hi

#

i am new to python

edgy finch
#

same here

#

here

#

!resoures

final iron
#

.topic

lament depotBOT
#
**Do you think there's a way in which Discord could handle bots better?**

Suggest more topics here!

final iron
#

I feel like a lot of people would have some opinions on this

#

Imo, either not force slash commands or add a higher/no cap to the amount of commands you can have

fervent shard
#

what does await member.warn(embed=em) do?

potent spear
#

where did you get it from?

tiny ibex
#

Can someone explain this error
disnake.errors.ClientException: Callback for prepare command is missing "ctx" parameter.

tiny ibex
final iron
#

^

final iron
slate swan
final iron
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

tiny ibex
#

Me dumb forgot it is in a cog

fervent shard
final iron
#

You would log the warn and DM the user

#

Also check if they have reached the amount of warns you want to punish then at

slate swan
#

save the warns in a db

final iron
#

That's what I mean log

fervent shard
final iron
#

Poor choice of words

final iron
slate swan
maiden fable
slate swan
#

that easy

final iron
#

Why use it instead of replace?

fervent shard
# final iron You would log it in to a database

would this one work?

def save_warn(ctx, member: discord.Member):
    with open('warns.json', 'r') as f:
         warns = json.load(f)
 
         warns[str(member.id)] += 1
 
    with open('warns.json', 'w') as f:
         json.dump(warns, f)
 
def remove_warn(ctx, member: discord.Member, amount: int):
    with open('warns.json', 'r') as f:
         warns = json.load(f)
 
         warns[str(member.id)] -= amount
 
    with open('warns.json', 'w') as f:
         json.dump(warns, f)
 
def warns_check(member: discord.Member):
    with open('warns.json', 'r') as f:
         warns = json.load(f)
 
         return warns[str(member.id)]```
slate swan
#

why json smh

slate swan
sage otter
slate swan
slate swan
potent spear
final iron
#

Should I actually learn how to use update?

slate swan
slate swan
potent spear
sage otter
#

Why tf would anyone not use it?

final iron
potent spear
#

only using CR(U)D is not uncommon

final iron
#

I don't have a use case for update yet

#

So it's not going to be high on my priority list

sage otter
potent spear
#

not every command is edit or whatever, I don't use moderation in my private bot

maiden fable
#

how did y'all become DB Experts all of a sudden

potent spear
#

if you wanted to update a value ofc I'd use update lmao, I won't delete and create

final iron
#

Okay so tmr I need to learn how to use run_in_executor, make an info command and then I'll learn update

potent spear
#

run_in_exec is ONLY if you can't find an async wrapper ig

final iron
#

Yup

waxen rose
final iron
#

No async wrapper for psutil

#

Well that I could find

potent spear
final iron
waxen rose
sage otter
#

why do you need an async wrapper for psutil. All it does is collect data about the system smilebutcryinside

waxen rose
#

help

final iron
#

I need it to work for windows, Linux and raspbien (raspberry pi)

maiden fable
potent spear
#

yeah, it's speedy AF

final iron
#

Still

#

Why not use run_in_executor?

potent spear
#

yeah, I know what you think, even if I won't notice, I'd like it async too

waxen rose
maiden fable
waxen rose
#

hellp

maiden fable
#

I don't use repl, sorry

potent spear
#

I guess google will help you on that error the for sure some other users have on that platform

fervent shard
# waxen rose

theres no file called "main.py" you need one called that if you want to host your bot or so that your repl doesnt die.

final iron
maiden fable
#

I mean, psutil is hardly blocking bruv

maiden fable
#

It doesn't do any heavy processing

fervent shard
final iron
#

That's not the point. I just want everything to be actually async

#

I understand it's not going to affect anything

#

Just some primal urge in me to make everything async

maiden fable
#
async def print(*args, **kwargs):
    print(*args, **kwargs) 

async print :DDD

sage otter
#

but why tho. doesn’t run_in_executor spin a new thread up just to run that sync function separately.

sage otter
#

do you even know how much processing power that takes

tiny ibex
#

Can someone point out on what's wrong

import disnake
from disnake.ext import commands
import aiohttp
from disnake.ext.commands.params import Param


class PersistentView(disnake.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @disnake.ui.button(
        label="Green", style=disnake.ButtonStyle.green, custom_id="persistent_view:green"
    )
    async def green(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        await interaction.response.send_message("This is green.", ephemeral=True)

    @disnake.ui.button(label="Red", style=disnake.ButtonStyle.red, custom_id="persistent_view:red")
    async def red(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        await interaction.response.send_message("This is red.", ephemeral=True)

    @disnake.ui.button(
        label="Grey", style=disnake.ButtonStyle.grey, custom_id="persistent_view:grey"
    )
    async def grey(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        await interaction.response.send_message("This is grey.", ephemeral=True)

class button_roles(commands.Cog):

  def __init__(self, bot):
    self.bot = bot
    self.persistent_views_added = False

  @commands.Cog.listener()
  async def on_ready(self):
    if not self.persistent_views_added:
      self.add_view(PersistentView())
      self.persistent_views_added = True
      

  @commands.command()
  @commands.is_owner()
  async def prepare(self, ctx: commands.Context):
      await ctx.send("What's your favourite colour?", view=PersistentView())

def setup(bot):
  bot.add_cog(button_roles(bot))```
maiden fable
#

Too much lol

maiden fable
#

Too much processing power for a thing which is hardly blocking

final iron
#

Okay fine

fervent shard
# waxen rose

when u created the repl, did u tap "python" and not any other language?

final iron
#

I won't add the executor

tiny ibex
# maiden fable U tell us
  File "c:\Users\phoen\OneDrive\Desktop\nox-bot\cogs\button_roles.py", line 36, in on_ready
    self.add_view(PersistentView())
AttributeError: 'button_roles' object has no attribute 'add_view'```
fervent shard
maiden fable
#

@final iron we ain't discouraging u to not use executor, we are just telling u it's useless since the lib isn't that blocking and u r just gonna waste your processing power

fervent shard
final iron
#

Yeah I understand

sage otter
#

why are you guys talking about repl problems in this channel :/

waxen rose
fervent shard
waxen rose
#

?

waxen rose
#

have class

#

bye

fervent shard
tiny ibex
fervent shard
#

get help at that time i aint doing anything

waxen rose
fervent shard
slate swan
#

how do i make a afk cmd?

fervent shard
sage otter
# waxen rose dms

Just a tip. If it’s saying file not found and it’s obviously there. Your working directory probably isn’t right

slate swan
fervent shard
sage otter
# slate swan how do i make a afk cmd?

Scan for messages using on_message() if the message has any mentions(Message.mentions) process them and fetch the mentioned person's afk message from your data storage device and send it.

#

at least that’s what you’d do if you're looking for an afk system like dynos or something.

tiny ibex
#

How to get button's clicker??

#

In dpy 2.0

slate swan
unkempt canyonBOT
tiny ibex
slate swan
tiny ibex
#

Hmm tysm

slate swan
#

Interaction being the discord.Interaction object u get

tiny ibex
#

Interaction.user

tiny ibex
#

And how to get it

slate swan
#

discord.Interaction is a class , the button click response you get is an instance of it

slate swan
#

ur using disnake right?

tiny ibex
slate swan
#

!d disnake.on_button_click

unkempt canyonBOT
#

disnake.on_button_click(interaction)```
Called when a button is clicked.

Warning

Consider using the callbacks associated with the [`View`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.View "disnake.ui.View") instead.

New in version 2.0.
slate swan
#

notice the interaction arg , its a discord.Interaction object

sage otter
#

Heed the warning. Views were made for for a reason. 👌

tiny ibex
#

Sounds Shit NGL

slate swan
#

you either would use that event , or use the view's callback

#

how else are you supposed to get the response?

#

its like saying i want to get who joined a server , but i wont use on_member_join

tiny ibex
slate swan
unkempt canyonBOT
#

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

The callback associated with this UI item.

This can be overriden by subclasses.
slate swan
#

this , its a function you will make

#

not much difference than using on_button_click event but will save u from checking that the button was clicked on what message

tiny ibex
maiden fable
#

Idk why some people hate ui.View implementation, it's just soooo clean

vale wing
#

Ikr

#

Maybe classes look complicated to most of starters

echo wasp
#

Ok on a welcome message do you know how to exclude a server or create a list?

vale wing
#

You need to check the member.guild.id

echo wasp
slate swan
#

!d discord.CategoryChannel.channels

unkempt canyonBOT
#

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

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

^

#

1 moment

tiny ibex
#
    @disnake.ui.button(
        label="Male", style=disnake.ButtonStyle.blurple, custom_id="persistent_view:male"
    )
    async def male(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        guild = interaction.guild
        male = guild.get_role(810264985258164255)
        user = interaction.author
        await user.add_roles(male)
        await interaction.response.send_message("Male role was successfully added!", ephemeral=True)```
#

What's the issue with this??

slate swan
#

!d discord.abc.GuildChannel.set_permissions

unkempt canyonBOT
#

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

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

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

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

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

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

hey when one of your get a chance can you go down to #help-rice ?

slate swan
#

ah

#

well then use permissions_for

tiny ibex
tiny ibex
# slate swan error pls
Ignoring exception in view <PersistentView timeout=None children=4> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label='Male' emoji=None row=None>:
Traceback (most recent call last):
  File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ui\view.py", line 368, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\phoen\OneDrive\Desktop\nox-bot\cogs\button_roles.py", line 20, in male
    await user.add_roles(male)
  File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\member.py", line 944, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'```
slate swan
slate swan
#

welll thats what the error says

tiny ibex
#

duh-

slate swan
#

why not ? channel.permissions_for(role/member) i dont see anything not making sense here

#

whats the difference between Member.premium_since and Profile.premium_since

#

Profile.premium_since is not a thing , Member.premium_since is

maiden fable
#

Yea, the Profile class is depreciated now

#

@slate swan your status BTW

slate swan
#

time to study ig

edgy finch
maiden fable
#

!d discord.Member.permissions_in

#

Wait what

#

Ah, it's a typo

#

permissions_for

#

Not permission_for

steel slate
slate swan
#

permissions , not permission

cloud dawn
maiden fable
#

@slate swan 3373peepoeyes

sage otter
#

Requires a role object.

slate swan
#

triggered I got no self control lol

#

Wrong reply

maiden fable
#

Lol

slate swan
maiden fable
#

Same don't worry

#

!d discord.Guild.get_role use this

unkempt canyonBOT
slate swan
#

loooli The longest break i took from discord was for 13 hrs

cloud dawn
#

I assume the get is the utils function pretty bad naming

maiden fable
#

The longest break I took was, uhh, 3-4 days Or smth

cloud dawn
maiden fable
#

Lol

cloud dawn
#

Been awhile since I really didn't do anything a whole day

#

!d discord.TextChannel.permissions_for

unkempt canyonBOT
#

permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").

This function takes into consideration the following cases...
cloud dawn
#

Some code?

#

Dunno gotta search the syntax for it on the docs

#

I'm on phone rn

boreal ravine
maiden fable
#

For badges and stuff

boreal ravine
#

looking at the error, permissions_for needs a member object

maiden fable
#

Nitro badge, booster and stuff

potent spear
#

alright, wanna know what's off?

boreal ravine
potent spear
boreal ravine
#

what sniper said

potent spear
#

you're on v1.7.3 mate

#

the docs you're looking at are master (v2+)

#

well, now you don't anymore apparently

#

you can verify this by
print(discord.__version__)

#

make sure to read the breaking changes

#

there must be

#

I guess you could just use role.permissions

#

not sure if it's can be changed per channel... I don't do moderation bots

boreal ravine
#

probably isn't

cloud dawn
#

You can

velvet tinsel
#

afaik yes

surreal blade
#

does anyone have a sample piece of code where their bot sends a confirmation message and awaits for a reaction to continue the function, could obv work it out myself if no one has one on hand theyre willing to share

#

but figured someone would have something similar available here

oak warren
#

docs do

surreal blade
#

oh cool, any idea what its listed under

oak warren
#

bruh

surreal blade
#

wait_for,, ill find it

#

ty

#

i can look it up but appreciate trying to wrangle Python to help

oak warren
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
oak warren
#

finally

cloud dawn
#

Ye commands

surreal blade
#

haha nice job

cloud dawn
#

I am typing on my phone ;-;

oak warren
#

this has the example

surreal blade
#

yep it does, thanks

velvet tinsel
cloud dawn
surreal blade
#

would have searched wait_for like i said if i knew an example was listed there

maiden fable
boreal ravine
#

so they got renamed to flags?

maiden fable
#

Yea, for whatever reason

boreal ravine
#

PublicFlags iirc

maiden fable
#

!d discord.UserFlags

unkempt canyonBOT
maiden fable
#

Yea

boreal ravine
#

hm

cloud dawn
#

You could also save aliases of them if they change their name

maiden fable
#

Ngl, I liked the discord.Profile implement

steel slate
#

how do you get a discord bot to create an invite and print it in the termanal

maiden fable
unkempt canyonBOT
#

await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates an instant invite from a text or voice channel.

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

hmmmm i'll have to try it

pine crown
#
@commands.has_permissions(ban_members=True)
@client.slash_command(description="Unbans a user")
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)
    embed=disnake.Embed(color=0x00d60e, title=f"Successfully unbanned {user}", description=f"Unbanned {user} by {ctx.author.mention}")
    await ctx.send(embed=embed)
    return

how to make this so that if they entered a wrong username and tag it will send that it is wrong

maiden fable
#

Lucas Unban

#

Rip

potent spear
#

error says it all?

maiden fable
#

U can't have two cogs with the same name

#

Then u r trying to reload a cog that's already loaded

#

Idk

#

Yea

#

The file named maincogs is causing the error

#

Ah I see the error

#

discord_slash is causing it most probably

#

Ah

#

told u, no two cogs with the same name

#

(:

#

BTW a fork like disnake or pycord or smth would be preferred instead of dpy 2.0

shadow wraith
#

as a disnake user, its good

#

disnake has timeouts 😍

#

uh

#

this thing

#

yeah but i dont think it was "new" but sure you can call it new

placid skiff
#

disnake is a really good fork, d.py is not maintained anymore so more API's are updated more it will became useless

steel slate
#

how would you make a create invite and send it to your dms?

shadow wraith
#

no, but don't do import disnake as discord just search replace it

#

just tell us if you get any errors whilst switching

maiden fable
#

Yea... They gonna get updated with new features

shadow wraith
#

np

steel slate
shadow wraith
maiden fable
#

Yea

steel slate
#

how would you make a create invite and send it to your dms?

placid skiff
#

it's a fork based on d.py, it has all his features

quick gust
placid skiff
#

Of course

#

it's because disnake has slash commands

quick gust
#

disnake has built in slash commands, you don't need the package to work with disnake (as tvrsier said)

green bluff
#

how do i find the unicode of certain emojis

quick gust
#

you can put a backslash before an emoji (on discord) and get the unicode

#

or copy it from google

green bluff
#

oh cool thanks

quick gust
#

Yes

green bluff
#

wait so can i just do

#

await msg.add_reaction(':tada:)

quick gust
#

\👍

#

you could (u didnt close the string lol)

green bluff
#

yeh oops

quick gust
green bluff
#

wait can i not add u before the string

#

or do i have to is the u necessary

quick gust
#

I thought you were talking about that only

fervent shard
green bluff
#

(u':tada:')

#

do i have to add the u

quick gust
green bluff
#

thanks

quick gust
#

i dont even know what the "u" does

green bluff
#

oh i think its for unicodes idk

fervent shard
# quick gust

now tap enter and copy the thing that the message changes to

quick gust
#

uh not too sure, I haven't worked with slash commands much

fervent shard
steel slate
#

so I am in a server on another account with my bot in it i want it to create an invite into the server and send it to me is that possible

#

i can't run a command from it

fervent shard
steel slate
fervent shard
#

thats the whole point of this channel.

#

discord bots

steel slate
#

that my bot is in

fervent shard
slate swan
#

!d discord.abc.GuildChannel.create_invite

unkempt canyonBOT
#

await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates an instant invite from a text or voice channel.

You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to do this.
fervent shard
steel slate
fervent shard
steel slate
#

the dm one gives you an invite from where you sent the command

steel slate
fervent shard
honest vessel
#

make command in bot dm

#

create invites from all servers its in n return to u in dm

fervent shard
# steel slate umm let me get it

so if u want ur bot to dm u a server invite its like this

@bot.command()
async def dm (ctx,member : discord.Member):
  await member.send('put in the server invite here')```
i think, not 100%
the way u use it is "{prefix}dm {user}"
steel slate
#

right

steel slate
fervent shard
cloud dawn
#

ctx and inter are different things..?

fervent shard
cloud dawn
#
@bot.slash_command()
async def hello(inter):
    """ Responds with 'World' """
    await inter.send("World")
``` shortest way, docstring will still apply as description.
#

inter is for slash commands, ctx is not

steel slate
maiden fable
#

@cedar smelt the name can by anything, what matters is the class instance it's from

fervent shard
cloud dawn
#

You are using Disnake?

haughty oxide
#

!voice verify

unkempt canyonBOT
#

Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

cloud dawn
#

Then both methods work

fervent shard
haughty oxide
fervent shard
haughty oxide
#

this channel is for bots right?

fervent shard
haughty oxide
fervent shard
slate swan
#

can anyone please help me figure out how to have main.py run the bot and have my commands written and "stored" in Commands.py?

steel slate
fervent shard
steel slate
green bluff
#

whats wrong

fervent shard
fervent shard
#

await member.send dms the user an invite link

green bluff
#

can someone help me

slate swan
#

wat

fervent shard
slate swan
#

cogs?

green bluff
fervent shard
slate swan
#

what are cogs

potent spear
green bluff
#

oh thank u

fervent shard
slate swan
#

:^(

green bluff
#

can someone help me with this

steel slate
#

how do i start it

fervent shard
green bluff
#

fvindi can u help me what does it mean by list index out of range

tawdry perch
fervent shard
honest vessel
fervent shard
# steel slate how do i start it

just copy and paste this

@bot.command()
async def invite (ctx,member : discord.Member):
 invite = await ctx.channel.create_invite()
 await member.send(invite)```
thick sigil
green bluff
steel slate
honest vessel
#

its like list = [1, 2] print(list[3])

fervent shard
green bluff
#

do i delete the +1

tawdry perch
green bluff
#

so just print(variable)

#

right

tawdry perch
#

ye

steel slate
fervent shard
steel slate
green bluff
#

i cant print it if i dont call it and when i call it i get this error

fervent shard
honest vessel
#

prob that -1?

green bluff
#

what do i change that to or do i remove it

fervent shard
honest vessel
#

well 0 is minimal

green bluff
#
Traceback (most recent call last):
  File "C:\Users\notvi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\notvi\OneDrive\Desktop\Ace Tickets\main.py", line 44, in on_raw_reaction_add
    ticket_num = 1 if len(category.channels) == 0 else int(category.channels[-1].name.split('-')[1]) + 1
IndexError: list index out of range```
green bluff
tawdry perch
green bluff
#

oh

#

so it goes from 0

potent spear
steel slate
green bluff
#

so instead of listing 3 list 2

tawdry perch
#

0 = first item from list

fervent shard
green bluff
#

so how would i call less

tawdry perch
#

call less..?

green bluff
#

oh wait

#

sorry

honest vessel
#

0 is first object

green bluff
#

do i do print([0])

honest vessel
#

category.channel[0] will select first channel

green bluff
#

ye

potent spear
#

problem is, the channels have a stinky order
better would be to get a channel via discord utils based on name

honest vessel
#

u can try print category.channels[0].name

green bluff
#

lemme try

heavy radish
steel slate
green bluff
#

lemme try

tawdry perch
heavy radish
#

yes

tawdry perch
#

does not exist?

green bluff
heavy radish
fervent shard
heavy radish
#

COG's don't work

fervent shard
#

did it say and error?

#

in the console

tawdry perch
honest vessel
#

@steel slatecodes pretty self-described too but i guess he lacking basic knowledge

steel slate
# honest vessel <@!834517319543685191>codes pretty self-described too but i guess he lacking bas...

i know that here is the thing i use these not the other way around

async def Help(ctx):
  embed=discord.Embed(title='Help Page!', description=f"%Ping (To tell you if I am online or not) \n %Purge (To purge mass messages) \n %Invite (Opens the invite page to invite me!) \n %Help (To open this page to tell you what commands I have)", color=0x206694)

  await ctx.channel.send(embed=embed)
@bot.command()
async def serverinvite (ctx,member : discord.Member):
 invite = await ctx.channel.create_invite()
 await member.send(invite)```
pine crown
#
@commands.has_permissions(kick_members=True)
@client.slash_command(description="Mutes a user")
async def mute(ctx, member: disnake.Member=None, *, reason="The reason was not entered"):
  guild = ctx.guild
  muted = disnake.utils.get(guild.roles, name="Muted")

  if not muted:
    muted = await guild.create_role(name="Muted")
    for channel in guild.channels:
      await channel.set_permissions(muted, speak=False, send_messages=False)

  await member.add_roles(muted, reason=reason)
  await member.send(f"You have been muted in {member.guild.name} for **{reason}** by {ctx.author.mention}")
  embed=disnake.Embed(color=0x00d60e, title=f"Successfully muted {member.mention}", description=f"Muted {member.mention} for {reason}")
  await ctx.send(embed=embed)

why does this no work

steel slate
potent spear
honest vessel
#

!serverinvite @raw wyvern @steel slate

#

or what ever prefix u have

honest vessel
unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
echo wasp
#

is this for a cog or does it work normally aswell not in a cog

honest vessel
#

that should work in main

echo wasp
#

so i use client or bot do i replace commands with that or just copy and pasta

cloud dawn
#

@echo wasp idk what he wrote pithink

green bluff
honest vessel
#

you should edit it to bot.command if thats what u have

cloud dawn
honest vessel
#

@cloud dawnit was but i assume he dont use cogs why i removed all self

#

so he has to change decoration

steel slate
fervent shard
#

error:
raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: choice() takes 2 positional arguments but 3 were given
code:

@bot.command()
@commands.has_permissions(administrator=True)
async def invites (ctx):
  em1=discord.Embed(description="invite link", colour=0x1f8b4c)
  em2=discord.Embed(description="invite link", colour=0x1f8b4c)
  await ctx.send(random.choice(em1, em2))```
honest vessel
#

@echo waspshow the codes u have rn

honest vessel
#

the indentation is pretty screwed tho what i can see

steel slate
#

here

quick gust
#

why do you have bot and client

#

keep one

steel slate
#

because of reasons

quick gust
#

ok

green bluff
#

can someone help me

steel slate
runic ridge
#

where can i learn python to start making a discord bot? i want a good source to learn pls

honest vessel
#

@steel slatefix all ur codes, it all functions has diffrent indentations

steel slate
green bluff
runic ridge
#

uh anyone?

echo wasp
quick gust
honest vessel
green bluff
#

ye its vscode can u help me on it

unkempt canyonBOT
#
Resources

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

runic ridge
#

they are all paid lmfao

honest vessel
quick gust
quick gust
#

Yeah they aren't

steel slate
#

i follow close

#

i fixed it all now

honest vessel
#

not really

#

cant belive u dont get indentation errors

#

its still diffrent in all functions

#

sum has 2 space some has too many tabs

echo wasp
quick gust
#

In that case I'd suggest online vsc

echo wasp
#

gitpod

quick gust
#

sure

#

have u tried that?

echo wasp
#

ye

#

let me login

quick gust
#

I'm pretty sure it won't give u so many indentation errors

#

Use that

steel slate
#

ok

honest vessel
#

explains why chromebooks so cheap, pure crap 😄

steel slate
#

now wut

honest vessel
#

ok so i ran this on my bot it worked in dm n dm:ed back invites from server

#

but this is inside a cog

steel slate
#

how do you make a cog i haven't experimented with them very much

cloud dawn
#

I'm sorry but this doesn't really seem appropriate.

honest vessel
#

@cloud dawnwhat u mean?

steel slate
cloud dawn
#

That this is not really appropriate code to place here.

honest vessel
#

why not ?

steel slate
#

wdym it is discord-bots

honest vessel
#

he wants bot to give him invites to servers his bot are in

steel slate
#

and that is what we are working on

#

so how do i make a cog for it?

cloud dawn
#

This raises a lot of privacy concerns for me.

steel slate
quick gust
#

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

honest vessel
#

@cloud dawnnot for me i had a reason make it cause i did a server throu bot and needed bot to give invites to my discord account to access bots created server

#

nothing sketchy

#

and i dont selfbot so

cloud dawn
honest vessel
#

await self.bot.create_guild() how else u join ur servers

#

ofc u need bot to send u invites

steel slate
#

right i think i'll be talking to a modmail

cloud dawn
#

Still doesn't make it appropriate to create invite for every guild your bot is in.

honest vessel
#

its only in 1 guild, but i get it its bad code for a selfbotter

cloud dawn
#

There was a whole discussion on this yesterday as well.

#

selfbot or not, still raises concerns for me.

honest vessel
cloud dawn
steel slate
# cloud dawn Here is the discussion if interested -> https://discordapp.com/channels/26762433...

ok with that i want to know my bot is etup for small not large and it does this every boot up ```@bot.event
async def on_ready():
for guild in client.guilds:
print(guild.name)
print(
f'{client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})\n'
)

    members = '\n - '.join([member.name for member in guild.members])
    print(f'Guild Members:\n - {members}')``` it is a thing to make sure the bot sees them all so i don't get it
honest vessel
#

@cloud dawnoh well i see what u mean if lets say u have a public bot that peoples are using in their servers

#

for me its only 1 guild and my bot is private

#

but ofc i cant know what others bot are

cloud dawn
echo wasp
#

mine is small aswell and usally in heroku so i never get the guilds

honest vessel
#

@cloud dawnight i remove code then so no kids abuse it

cloud dawn
#

@echo wasp Sorry for the intrusion, thanks for understanding and being patient about contacting modmail

echo wasp
echo wasp
honest vessel
#

u have the code already lol

echo wasp
honest vessel
#

play around learn how to make commands 😄

#

code is very simple

cloud dawn
#

Some of the others also had some issues with this in the past.

echo wasp
#

I do now and then it is just some of these i don't get

tawdry perch
green bluff
#

ill dm u tmr

tawdry perch
#

If I happen to be online at x time

#

Sorry, I don't accept DMs

green bluff
#

ye

heavy radish
#

I'm pinging a member. But I get this error

green bluff
#

oh k

#

can i ping u

heavy radish
tawdry perch
#

Sure you can, but I don't promise anything

green bluff
#

ye ik

tawdry perch
#

Gn

green bluff
#

byeee

honest vessel
#

@heavy radishoh u use member, but u named parameter user

heavy radish
#

Yea, I just figured

honest vessel
#

😄

heavy radish
#

Thank You, tho

#

🤦‍♂️

honest vessel
#

sometimes u get blind for a second

heavy radish
#

Lmao

honest vessel
#

well time for me to grab ☕ and wakeup

fervent shard
#

code: ```py
@bot.command(aliases=['ub'])
@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):
em1=discord.Embed(desciption=f"{member.mention} has been unbanned")
em2=discord.Embed(desciption=f"{member.mention}, you have been unbanned")
await ctx.guild.unban(user)
await ctx.send(embed=em1)
await member.send(embed=em2)
return```error:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'mention'```
tawdry perch
#

member is just string, you can't mention it in this case

honest vessel
#

pretty selfexplained error

fervent shard
tawdry perch
cloud dawn
#

!e ```py
print("hello".mention)

unkempt canyonBOT
#

@cloud dawn :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | AttributeError: 'str' object has no attribute 'mention'
honest vessel
#

member: discord.Member

tawdry perch
#

But that user would be in guild?

honest vessel
#

u can post the discordID i think

tawdry perch
#

Wouldn't the typehint be discord.User instead

fervent shard
tawdry perch
#

But in those cases the user is in guild, both should work tho

honest vessel
#

@tawdry perchwell u can keep it as a string if u want - but then you need to fetch that member object

tawdry perch
#

But that member is not in guild?

honest vessel
#

user = await self.bot.fetch_user(user_discord_id)

#

and have discord id as parameter?

#

await ctx.guild.unban(user)

fervent shard
#
discord.ext.commands.errors.MemberNotFound: Member "fvndi#7450" not found.```
#

got another error

cloud dawn
#

I think fvndi#7450 cannot be found

#

Professional educated guess

fervent shard
potent spear
honest vessel
#
@commands.command(aliases=["ub"])
    @commands.has_permissions(ban_members=True)
    async def unban(self, ctx, member:discord.User, *, reason="No reason provided"):
        user = await self.bot.fetch_user(member.id)
        try:
            await user.send(f"You have been **un-banned** from the {ctx.guild.name}\nreason: {reason}")    
        except:
            pass
        await ctx.send(f"{user.mention} **has been un-banned.**\n*reason: {reason}*")
        await ctx.guild.unban(user, reason=reason)
``` here is my old unban code
potent spear
#

damn, that's useless

cloud dawn
potent spear
#

also sending that the user has been unbanned before he's actually unbanned is quite funny

honest vessel
#

i said its old n i dont use it 😄

cloud dawn
potent spear
#

do you really need to typehint every single parameter tho? seems obvious sometimes, I'd only want a typehint if it needs to be converted

cloud dawn
#

member:discord.User calling member a user, then re-fetching the user ;-;

honest vessel
#

😄

#

i know

cloud dawn
potent spear
#

Pandabweer be like I'm about to end this man's whole career

potent spear
honest vessel
#

yes very shitty code 🥲

potent spear
#

nah, you were already using cogs at that time, can't complain

honest vessel
#

lmao

#

thanks for morninglaughs

cloud dawn
#

How long have you guys been coding for?

honest vessel
#

just on n off sometimes

candid maple
lyric flint
#

I want the bot to send a message for every new member, but it doesn't work. ``` import os

import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client()

@client.event
async def on_ready():
print(f'{client.user.name} has connected to Discord!')

@client.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(
f'Hello {member.name}, welcome to my Discord server!'
)

client.run(TOKEN)```

heavy radish
#

The second part of the code doesn't work

  @commands.Cog.listener()
  async def on_message(self, message):
    Unlock = discord.PermissionOverwrite(send_messages=True)
    Lock = discord.PermissionOverwrite(send_messages=False)
    Role = message.guild.default_role
    if message.channel.id == 814207750342705164 and message.content.lower().startswith("rpg miniboss"):
      await message.channel.set_permissions(Role, overwrite=Unlock)
      await message.channel.send(f":white_check_mark: Unlocked {message.channel.name}")
      await asyncio.sleep(10.0)
    if Role == Unlock:
      await message.channel.set_permissions(Role, overwrite=Lock)
      await message.channel.send(f":white_check_mark: Locked Down {message.channel.name}")
``` After if role == unlock
heavy radish
#

none

honest vessel
#

shouldt await member.send("hi") be enough?

heavy radish
#

just doesn't work

#

true

cloud dawn
heavy radish
royal oar
#

does anyone know how to hide cogs from custom help commands?

cloud dawn
royal oar
#

do i put that at the start?

lyric flint
honest vessel
#

old as it used to be

cloud dawn
cloud dawn
#

Like 3 years ago

maiden fable
steel slate
#

@honest vessel can you dm me the cog version please for secutry reasons as why we had to halt

cloud dawn
lyric flint
#

@cloud dawn oh k

potent spear
maiden fable
royal oar
potent spear
boreal ravine
#

doesn't make sense

maiden fable
cloud dawn
#
import os
import discord

from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client(intents=discord.Intents.all())

@client.event
async def on_ready():
    print(f'{client.user.name} has connected to Discord!')

@client.event
async def on_member_join(member):
    await member.send(
        f'Hello {member.name}, welcome to my Discord server!'
    )

client.run(TOKEN)
#

!d typing.Any

unkempt canyonBOT
#

typing.Any```
Special type indicating an unconstrained type.

• Every type is compatible with [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "typing.Any").

• [`Any`](https://docs.python.org/3/library/typing.html#typing.Any "typing.Any") is compatible with every type.
maiden fable
#

!d discord.ClientUser

#

Yea thought so

maiden fable
potent spear
#

I see it in docs all the time

cloud dawn
potent spear
lyric flint
#

@cloud dawn is still doesn't work

cloud dawn
#

If you then "release" your bot you turn off intents and debug your bot for the last time.

honest vessel
potent spear
cloud dawn
honest vessel
#

^

lyric flint
lyric flint
honest vessel
#

in portal

cloud dawn
#

Could you provide the current code you got?

lyric flint
cloud dawn
lyric flint
potent spear
steel slate
#

mine is in an .env file still

cloud dawn
#

So you sended code that isn't yours?

steel slate
#

never made one before

cloud dawn
steel slate
# cloud dawn Try this https://vcokltfre.dev/

In this video, we learn about cogs and how to implement them in a discord bot.

If you have any suggestions for future videos, leave it in the comments below.

GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/

OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY HELP SERVER: https:...

▶ Play video
potent spear
potent spear
cloud dawn
honest vessel
#
import discord
from discord.ext import commands

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

def setup(bot):
    bot.add_cog(Mycog(bot))
``` minimal cog
cloud dawn
#

Even for 2019 that is not really good code.

potent spear
echo wasp
lyric flint
#

@cloud dawn now im getting this error: discord.errors.PrivilegedIntentsRequired

cloud dawn
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.

cloud dawn
cloud dawn
honest vessel
#

typehintPanda

potent spear
cloud dawn
cloud dawn
potent spear
#

nvm, typehinting bot even? lol

#

can be a discord.Client too tho, not per se, but yeah

honest vessel
cloud dawn
#

Or disnake.ext.commands.AutoShardedInteractionBot

#

Or disnake.AutoShardedClient

potent spear
#

that's what I'm saying abt the typehint stuff

#

"obvious shit" doesn't need to be imo

#

like I won't pass a string if it says bot or client lol

cloud dawn
vale wing
cloud dawn
#

Union[disnake.ui.ActionRow, disnake.ui.Item, List[Union[disnake.ui.ActionRow, disnake.ui.Item, List[disnake.ui.Item]]]]) Disnake typehint for objects

#

art

lyric flint
#

@cloud dawn It's working, thanx for your help 🙂

cloud dawn
#

😉

nimble plume
maiden fable
#

Behold AP_pepePray

slate swan
#

description=""

#

Your option would look to something like that

Option(
    name="opt1",
    description="Description here",
    ...
)
#

You need to provide the option in the decorator for the description.

#

hmm well, bot doesn't do its job

unkempt canyonBOT
#

cogs/slash/owner-slash.py lines 50 to 57

options=[
    Option(
        name="message",
        description="The message you want me to repeat.",
        type=OptionType.string,
        required=True
    )
],```
slate swan
#

Here is an example for an option.

modest plover
#

How do I change data in an SQLite3 database with a discord command

#

/leaderboard update header: points update to: 1
Is what I want to do

#

I have the actual command, but it doesn't interact with the db

tawdry perch
# modest plover

what app is that you use to view this? (sorry non relevant to your question)

final iron
#

Check it out

tawdry perch
#

could you give the link?

final iron
tawdry perch
#

thank you 😄

final iron
#

That's is not it

tawdry perch
#

oh

final iron
#

There

#

I made a typo

#

It's fixed now

tawdry perch
#

np, thx!

slate swan
tawdry perch
#

then do sql statements inside execute

final iron
#

You can just create a bot var so you don't have to open it all the time

tawdry perch
#

Ye, but that was just example. I made the mistake and didn't use botvar 😔

heavy radish
#
  @commands.Cog.listener()
  async def on_message(self, message):
    Unlock = discord.PermissionOverwrite(send_messages=True)
    Lock = discord.PermissionOverwrite(send_messages=False)
    Role = message.guild.default_role
    if message.channel.id == 814207750342705164 and message.content.lower().startswith("rpg miniboss"):
      await message.channel.set_permissions(Role, overwrite=Unlock)
      await message.channel.send(f":white_check_mark: Unlocked {message.channel.name}")
      await asyncio.sleep(10.0)
    if Role == Unlock:
      await message.channel.set_permissions(Role, overwrite=Lock)
      await message.channel.send(f":white_check_mark: Locked Down {message.channel.name}")
``` The second part of the code doesn't work (after if role == unlock:)
tawdry perch
#

oh

heavy radish
tawdry perch
#

¯_(ツ)_/¯

#

ask away

tawdry perch
heavy radish
#

yes

tawdry perch
#

that should never be True

heavy radish
#

I'm trying to overwrite a role

tawdry perch
#

discord.Role is not same as discord.PermissionsOverwrite

heavy radish
#

ok

slate swan
heavy radish
#

How do I fix it?

tawdry perch
# heavy radish yes

you are comparing 2 different objects to see if they are equal to, which they never be

heavy radish
#

Ahhhhh

heavy radish
#

How do I fix it? Is there a discord.permission way

boreal ravine
#

thats the role I was talking about

heavy radish
#

i understand now

tawdry perch
heavy radish
#

Well

tawdry perch
#

I mean in if statement

slate swan
#

any help?

heavy radish
#

When someone does a command (for another bot) which starts with RPG miniboss, i'm opening the channel, after 1min, i'm closing it. Some times, people manually close the channel, for that instance, i'm using the if statement to check if its open, and if it is, close it

tawdry perch
#

and when you check if role == discord.PermissionsOverwrites. Are you trying to check if role has specific permission?

heavy radish
#

yes

tawdry perch
#

there should be method for it

heavy radish
#

Hmmm

tawdry perch
#

!d discord.Role | just for me to read the docs

unkempt canyonBOT
#

class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild")...
tawdry perch
#

!d discord.Role.permissions perhaps this could work

unkempt canyonBOT
heavy radish
slate swan
#

Exactly

tawdry perch
#

ye

heavy radish
#

How will i use it?

heavy radish
tawdry perch
#

no I mean, use that to get role permissions and then see if role has some specific perms

heavy radish
#

Umm

tawdry perch
#

sorry, I can't really explain it

royal oar
#

can someone help me with a cooldown on a command?

@commands.command()
    @commands.cooldown(1,20, commands.user)
    async def beg(self, ctx):
        await open_account(ctx.author)
        user = ctx.author
        users = await get_bank_data()

        earnings = random.randrange(1000)

        mbed = nextcord.Embed(title="**BEGGING?**", description=f"Someone gave you ${earnings}. Hope your grateful")
        mbed.set_footer(text="My child was begging, hope it was worth it")

        await ctx.send(embed=mbed)

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

        with open("bank.json", 'w') as f:
            json.dump(users,f)
heavy radish
#

yea, i think i figured it

slim ibex
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

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

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

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

A command can only have a single cooldown.
royal oar
#

Thank you

hasty herald
#

Hi guys, which one is prohibit send api?

final iron
hasty herald
#

for user

hasty herald
final iron
#

You want to know how to time someone out?

hasty herald
final iron
#

What lib are you using?

hasty herald
final iron
#

The timeout feature is not support on discord.py irrc

maiden fable
#

U gotta change the internals

final iron
#

Nope

hasty herald
final iron
#

So you either need to use a fork or fuck with the internals

#

If you decide to go down the fork route I would suggest disnake

#

!pypi disnake

unkempt canyonBOT
maiden fable
final iron
hasty herald
#

let me think..

slate swan
maiden fable
modest plover
tawdry perch
#

Well my example used aiosqlite

#

!pypi aiosqlite

unkempt canyonBOT
modest plover
#

Ok

#

Does aiosqlite have the same syntax and all that to SQLite3?

honest vessel
#

yes

#

i think so tho

tawdry perch
#

It does

modest plover
#

@tawdry perch can I have two tables in one database file?

tawdry perch
#

Sure, multiple ones

modest plover
#

Ok

haughty quartz
#

how can i have per server settings? (i wanna link a channel to the bot)

dreamy sluice
#

I am trying to make a sell command, and I want to make it such that, the user can input the item name (with spaces), along with the quantity in the same line. How do I go about separating both?

slate swan
#

how do i get a channel by its id?

haughty quartz
slate swan
#

i mean message sorry

haughty quartz
slate swan
#

like ctx.guild.get_message(id)

slate swan
haughty quartz
#

what do you want it to return?

dreamy sluice
slate swan
#

well, i wanted a message not channel

dreamy sluice
#

You mean the actual message object?

slate swan
#

yes

dreamy sluice
#

Oh

haughty quartz
#

u wanna get message id?

dreamy sluice
#

You can just do ctx.message

slate swan
#

well, i dont want to get the ctx message

dreamy sluice
#

it returns the message object of the message which has the command

slate swan
#

i want to get a specific message with its ID

dreamy sluice
#

using it's ID?

slate swan
#

yes

haughty quartz
#

ahh

#

idk lol

slate swan
slate swan
#
async def(ctx, item, price):```
#

if the items names have spaces in them, that's a little bit more trouble

#

he told us that the price and item strings will be a few words conceted with spaces

#

because the way discord.py and it's forks parse arguments it will consider the second part of the name as the price

dreamy sluice
slate swan
#

in that case you could just invert the order and have no more issues

dreamy sluice
#

I implied that the item name would have a space in it

slate swan
#
async def sell(ctx, price, *, item)```
#

as long as you indicate price first, everything else will be considered the item

dreamy sluice
royal oar
#

With a currency bot when i have a nickname it changes the id of the user to someone else is their a way to fix this at all?

slate swan
dreamy sluice
#

Oh ok

slate swan
#
prefix sell 90 Some Cool Thing
#

item = "Some Cool Thing"

#

does that work for you?

dreamy sluice
#

One more question

#

How can I detect if the user has skipped giving the price value?

slate swan
#

well because of the way the example i showed you is defined

#

if the price or the item name is missing

#

it will throw an error called MissingRequiredArgument

dreamy sluice
#

Ah

slate swan
#

do you know what an error handler is?

dreamy sluice
#

Yep

slate swan
#

and do you have one?

dreamy sluice
#

I just do commands.MissingRequiredArgument?

dreamy sluice
slate swan
#

yeah just make a case for that then

dreamy sluice
#

Okeh

slate swan
#

commands.MissingRequiredArgument yes

dreamy sluice
#

thanks

slate swan
#

you're welcome

brittle flume
#

So i was makng a command that replies 'wassup' when someone sends a message and it contains hi or hello, but it is not working!
Code:

greet_inputs = ['hello', 'hi', 'wassup']
@bot.event 
async def on_meassage(msg):
  if mgs.user == bot.user:
    return
  for greets in greet_inputs:
    if greets in str(msg.content).lower():
      await msg.channel.send(f'wassup {str(msg.author)[:-5]}!')
      break
    
  await bot.process_commands(msg)

Output:

No errors. Just not working even if the message contains hi or hello
sacred scroll
#

Why iterate?
just

 ...```
brittle flume
#

Greets is the item which I get in each loop

#

From greet_inputs

honest shoal
#

hm

#

and this looks like a typo to me

brittle flume
#

Oh yea lol

#

Ty

brittle flume