#discord-bots

1 messages ยท Page 571 of 1

waxen granite
#

lemm try agan

spiral frigate
#

I 've thought it all out

slate swan
#

?

spiral frigate
#

I made it shorter

slate swan
waxen granite
#
    async def removeserverstats(self, ctx):
        guild = str(ctx.guild.id)
        self.serverstats.pop(guild)
        await ctx.send("Done")```
well no errors now but didnt remove it from json i think
slate swan
#

Because you haven't saved anything

#

You're just editing the dictionary in runtime

waxen granite
#

before

slate swan
waxen granite
slate swan
#

If you don't save it it doesn't matter

#

endomorph , you gotta dump it to the json too

waxen granite
#

after it should be

slate swan
#

Yeah as I said, you never saved it after edition

waxen granite
#

hm

slate swan
#

so you would be assigning a variable for the pop , and
json.dump(variable , file)

slate swan
#

JSON is just a way to represent arrays and dictionaries as a text file

waxen granite
#

done

#

all good

#

ty guys

slate swan
stiff nexus
#

how do i start a task when the task is in a different cog and the cmd to start is in different cog?

slate swan
#

its basically just a function

stiff nexus
#

how do i import it

#

its like:

#
    @tasks.loop(minutes=10)
    async def meme(self):
      ....
slate swan
#

is it inside a class?

#

its just like importing a normal python function

boreal ravine
#

from file import meme

slate swan
#

from filename.classname import functionname

boreal ravine
#

^

slate swan
#

you would be able to import it but i doubt you wont be able to do anything with self

#

๐Ÿ‘€

stiff nexus
slate swan
stiff nexus
boreal ravine
#

y

stiff nexus
#

like self.bot.get_channal() to get the channel where i want to send things

slate swan
#

you can pass the bot object instead ๐Ÿ˜‰

stiff nexus
#

ik

slate swan
#

well , since you want to use it inside a cog , and it would for sure have a self.bot so sure

stiff nexus
#

but how do i make it a class?

boreal ravine
#

make it

stiff nexus
boreal ravine
#

make the function

#

inside the class

#

put the function*

slate swan
#

just cut it / copy it , and paste it inside the class with correct indentations :>

#

How do I kick members?

#

discord.Member.kick

boreal ravine
#

!d discord.Member.kick

unkempt canyonBOT
#

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

Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
slate swan
#

you can give a reason too

#

^

#

async def kick(ctx , user : discord.Member):
await bot.kick(user)

#

nuuuu

#

you can either use py await ctx.guild.kick(user)
or py await user.kick()

boreal ravine
#

^

slate swan
#

btw naming the arg as member is better choice according to pep8 , just saying

boreal ravine
#

maybe

#

he wants to a kick a user

#

๐Ÿ˜‚

maiden fable
#

You can't kick a user....?

slate swan
#

yeah , a User , user above is a discord.Member tho

slate swan
maiden fable
#

Yea, discord.Member is a subclass of discord.User

maiden fable
slate swan
slate swan
#

the role heirachy

maiden fable
maiden fable
slate swan
#

a friend

#

you gave your friend a higher role than your bot mb

#

Alright thanks so much for the help

boreal ravine
#

are discord users

#

not guild members

steady flume
#

how to make all words turn black, not just commas

embed.add_field(name='Aliases:', value=value=f'`` ,'.join(ctx.command.aliases), inline=False)

i tried this

vocal magnet
steady flume
#

how to make a deposit command, where you can specify your value, or you can enter "all" instead of the number, in short, like Dank Memer

boreal ravine
#

check for the args ig

kindred epoch
#

or maybe you can set 2 options

slate swan
#

a command function with an argument with int and str as Union would work

steady flume
#

how to set then 2 options?

kindred epoch
#

1 option as amount and 1 option as all which will be bool

kindred epoch
steady flume
steady flume
#
    async def deposit_bal(self, ctx, amount: int):
        local_collection = collection['coins']
        bank = local_collection.find_one({'_id': ctx.author.id})['bank']
        bank_size = local_collection.find_one({'_id': ctx.author.id})['bank_size']
        balance = local_collection.find_one({"_id": ctx.author.id})["balance"]
        amount2 = bank + amount
        if amount <= 0:
            embed = discord.Embed(
                description=f"{ctx.author.mention}, you cannot increase the bank balance by a ``negative value``",
                color=0xff0000
            )
            await ctx.message.add_reaction("โŒ")
            embed_delete = await ctx.reply(embed=embed, mention_author=True)
            await asyncio.sleep(10)
            await embed_delete.delete()
        elif amount > bank_size:
            await ctx.reply(
                f"You can only hold ``{bank_size:,}``:money: in your bank right now. To hold more, check our shop!",
                mention_author=True)
        elif amount2 > bank_size:
            await ctx.reply(
                f"You can only hold ``{bank_size:,}``:money: in your bank right now. To hold more, check our shop!",
                mention_author=True)
        else:
            local_collection.update_one({"_id": ctx.author.id},
                                        {"$set": {"bank": bank + amount}})
            local_collection.update_one({"_id": ctx.author.id},
                                        {"$set": {"balance": balance - amount}})
            new_bank = local_collection.find_one({"_id": ctx.author.id})['bank']
            await ctx.reply(
                f"``{amount:,}``:money: deposited, current bank balance is ``{new_bank:,}``:money:",
                mention_author=True)
#

too big ig

kindred epoch
#

show ur decorator

#

also what lib are you using

steady flume
#

2nd version

kindred epoch
#

what

#

2.0?

steady flume
#

lol

#
async def deposit_bal(self, ctx, amount: int):
kindred epoch
#

ok, can you show ur decorator for that command

ornate lichen
steady flume
#

@kindred epoch im a bit dumb and idk whats decorator

#

heh

kindred epoch
#

@bot.command

kindred epoch
#

!pypi asyncpraw

unkempt canyonBOT
#

Async PRAW, an abbreviation for `Asynchronous Python Reddit API Wrapper`, is a python package that allows for simple access to reddit's API.

steady flume
#

@kindred epoch

@commands.command(
        name="deposit",
        aliases=["Deposit", "dep", "Dep"],
        brief="Deposit money into your bank account from your pocket! You can also use arguments like 'max' and 'all'. You cannot deposit past your bank space allows, which you can see in balance.",
        usage="deposit <amount>"

    )
    async def deposit_bal(self, ctx, amount: int):
kindred epoch
#

ah ok

ornate lichen
#

from

#

request

kindred epoch
ornate lichen
#

becos idk how to use that

steady flume
rare saddle
#

How do you know member correctly?

steady flume
kindred epoch
steady flume
#

i mean plz dep all

kindred epoch
#

is it a slash command or a normal command?

steady flume
#

bot will work with all

steady flume
#

for my bot

kindred epoch
#

bruh

#

then remove all and set amount as str

ornate lichen
#

since the website u send is using asyncpraw for smth else

#

@kindred epoch

#

??

kindred epoch
# ornate lichen any example?

In this video, we will learn how to get data from Reddit using python for a Discord bot. We will make the meme command in this video.

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

Some Useful Links -

Reddit Applications- https://reddit.com/prefs/apps
My Discord Server- https://discord.gg/TXF3hBj

My Twitter...

โ–ถ Play video
rare saddle
#

Please tell me how to find out a member?

ornate lichen
#

๐Ÿ˜„

kindred epoch
reef shell
rare saddle
# kindred epoch What are you trying to do?

I am creating a ticket system, and when another person clicks the button, information about me is still displayed, because it says ctx.author, and I need information to be displayed about who clicked the button

rare saddle
spring obsidian
#

use py-cord or nextcord

rare saddle
kindred epoch
spring obsidian
spring obsidian
spring obsidian
viscid plover
#

i want bot to add reaction to it's message and store ids of members that react to it in a list

kindred epoch
viscid plover
#

i read the react section of documentation but can't figure out

kindred epoch
#

I'm pretty sure dislash and disnake is better than it

spring obsidian
kindred epoch
#

Pycord only supports slash commands where as disnake and dislash supports slash commands, context menus and apps

kindred epoch
rare saddle
#

Can someone help me with my question?

spring obsidian
kindred epoch
kindred epoch
spring obsidian
rare saddle
slate swan
#

disnake released them long ago

spring obsidian
kindred epoch
slate swan
spring obsidian
kindred epoch
#

Only reason pycord is popular is because of the owner having a yt channel and an already existing large discord server

slate swan
wicked atlas
slate swan
#

( it exists in master branch , beta i.e.)

slate swan
wicked atlas
#

Honestly not sure

slate swan
#

what else would master mean

wicked atlas
#

Yeah, i think it the in-development version

#

it's still on 1.7.3 on pypi

slate swan
#

thats the point , disnake already is stable and released with 2.1.5

kindred epoch
wicked atlas
slate swan
#

the stable release docs are just forked from discord.py's
master branch docs has been curated

#

with the blue&white snake logo

rare saddle
#

Please tell me how to find the channel id?

zenith zinc
#

click settings

#

click Advanced

#

and enable developer mode

cursive pelican
#

How do I get voice input or the loudness of a user in a voice channel

rare saddle
#

@zenith zinc how to find the channel id in discord.py

zenith zinc
#

ouaaaa

slate swan
zenith zinc
#

ou

#

my error sorr

slate swan
#

discord.TextChannel*

zenith zinc
#

bro

steady flume
#

guys, plz help solve this

zenith zinc
#

i need help my bot join in my channel how change to send in message channel nam

slate swan
steady flume
#

jajajajja

rocky rose
#

Hi I have a question. A friend of me programmed a discord bot, but when it gets large numbers, it responses with an e-form. Is there a way to disable this and get the full number displayed?

rare saddle
#

Why is this counter not working?

ornate lichen
#
prawcore.exceptions.ResponseException: received 401 HTTP response```
#

what does this mean

rocky rose
#

And you don't need to say global

#

while number < 5: Number +=1

#

This should work

ornate lichen
#

i think i might have authentication issues

#

praw btw

spiral rune
#

hello can anyone pls help me out?

#

i am using repl to make a bot

#

and the error which is showing up is

#

a type error

#

i've checked the video many times

#

and my code is similar with the one in the video

#

still...

#

pls help

ornate lichen
#

what are you trying to do

#

api?

vagrant topaz
# spiral rune

if you are using .env w/ repl there is something special you have to do. You also shouldn't name your TOKEN variable with your actual token

#

also you shared your bot token so you should probably regenerate it

hollow palm
#

He should use @ client.command rather than events for commands, no?

vagrant topaz
zenith zinc
vagrant topaz
zenith zinc
vagrant topaz
zenith zinc
# vagrant topaz code?
@commands.command()
  async def join(self,ctx,*, channel: discord.VoiceChannel):
   if not ctx.message.author.voice:
    await ctx.send(f"You are not in voice channel {ctx.author.mention}")
   else:
    embed=discord.Embed(title=f"JOIN", color=0x36393e)
    embed.add_field(name=f":succsess: I join  {channel.id}", value="``Type .wp {music name} to play music ``", inline=False)
    await ctx.send(embed=embed)
    channel = ctx.author.voice.channel
    await channel.connect()```
vagrant topaz
#

and his code works fine

spiral rune
zenith zinc
vagrant topaz
kindred epoch
vagrant topaz
spiral rune
#

like example can u pls give me an example? @vagrant topaz

vagrant topaz
kindred epoch
#

and using on_message as a command is just dumb

#

when theres already a a thing for command which makes your life easier

spiral rune
vagrant topaz
#

os.environ should literally say token, not your bot token

#

and specifiy that in the environment variables tab

zenith zinc
vagrant topaz
cloud dawn
#

Use the discord api

vagrant topaz
#

specify on oauth2 authorization

steady flume
#

hepl plz

vagrant topaz
#

"help plz" is not descriptive

steady flume
steady flume
vagrant topaz
#

yeah ik but it annoys me every fucking time

cloud dawn
vagrant topaz
#

make it int('1234')

rigid torrent
vagrant topaz
vagrant topaz
#

no i dont think so with discord.py

#

check api docs before asking, its most likely there

zenith zinc
#

how my bot tag voice channel

#

on join in voice channel

vagrant topaz
#

what

steady flume
# vagrant topaz bruh wtf is your problem

i just want make cmd where i need specify amount (int) or i can type "all" or "max" instead of amount, one guy said me that code, but there is mistake - how to solve this ?

zenith zinc
#

how does my bot tag a channel when it enters a particular channel

steady flume
vagrant topaz
#

like mention?

zenith zinc
#

yes

vagrant topaz
#

<#channel_id>

steady flume
#
    async def deposit_bal(self, ctx, amount: typing.Union[int, str]) -> None:
        local_collection = collection['coins']
        bank = local_collection.find_one({'_id': ctx.author.id})['bank']
        bank_size = local_collection.find_one({'_id': ctx.author.id})['bank_size']
        balance = local_collection.find_one({"_id": ctx.author.id})["balance"]
        amount2 = bank + amount
        if isinstance(amount, str):
            if amount in ("all", "max"):
                await ctx.send("test")
        else:
.....
vagrant topaz
zenith zinc
#
@commands.command()
  async def join(self,ctx,*, channel: discord.VoiceChannel=None:)
   if not ctx.message.author.voice:
    await ctx.send(f"You are not in voice channel {ctx.author.mention}")
   else:
    embed=discord.Embed(title=f"JOIN", color=0x36393e)
    embed.add_field(name=f":succsess: I join (have a code tag this channel)", value="``Type .wp {music name} to play music ``", inline=False)
    await ctx.send(embed=embed)
    channel = ctx.author.voice.channel
    await channel.connect()```
#

read

vagrant topaz
#
                                                             ^```
#

there's your problem

#

@zenith zinc

#

i think you forgot ctx (don't quote me on that)

zenith zinc
#

i know bro

#

but

#

how tag

vagrant topaz
zenith zinc
#

how can my bot tag that channel it entered

vagrant topaz
#

channel.mention

#

oh

#

actually idk sorry

#

rtfm

lament moth
#

async def deposit_bal(self, ctx, amount: typing.Union[int, str]) -> None: local_collection = collection['coins'] bank = local_collection.find_one({'_id': ctx.author.id})['bank'] bank_size = local_collection.find_one({'_id': ctx.author.id})['bank_size'] balance = local_collection.find_one({"_id": ctx.author.id})["balance"] amount2 = bank + amount if isinstance(amount, str): if amount in ("all", "max"): await ctx.send("test") else: .....โ€Š

zenith zinc
#

@vagrant topaz

#

help?

#

me

vagrant topaz
#

can you not

#

i literally fucking told you

zenith zinc
#

BROOOOOOO

#

see

kindred epoch
vagrant topaz
hollow palm
#

Your complicating a join command, you dont have to have a channel arg or self

zenith zinc
#

Join in and channel mention @vagrant topaz

vagrant topaz
vagrant topaz
#

it breaks it

hard trail
vagrant topaz
#

just do {channelname}

kindred epoch
vagrant topaz
#

just prints name

hollow palm
kindred epoch
#

!d discord.VoiceChannel.mention

unkempt canyonBOT
zenith zinc
hard trail
acoustic ermine
#
if not "@everyone" in message.content.lower() and not "@here" in message.content.lower() and not "613752401878450176" in message.content.lower(): 
    rayyanw786 = await self.client.fetch_user(613752401878450176)
    if rayyanw786.mentioned_in(message):
        await message.reply("test")

so i have this on_message
but it seems to reply after 20 seconds

#

i dont understand why it replied after 20 seconds as i have other if statments
and they reply instantly

undone wyvern
acoustic ermine
slate swan
#

Use ...get_user(id) or await ...fetch_user(id)

kindred epoch
#

get_user

slate swan
#

Then it tries to get the user from cache

#

And if it returned None, it automatically uses fetch_

acoustic ermine
#

kk

#

ill try it now

maiden fable
#

Tf

zenith zinc
#
@commands.command()
  async def join(self,ctx,channel: discord.VoiceChannel=None):
   channel = self.client.get_channel(channel)
   if not ctx.message.author.voice:
    await ctx.send(f"You are not in voice channel {ctx.author.mention}")
   else:
    embed=discord.Embed(title=f"JOIN", color=0x36393e)
    embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
    await ctx.send(embed=embed)
    channel = ctx.author.voice.channel
    await channel.connect()```
#

@vagrant topaz

vagrant topaz
zenith zinc
vagrant topaz
#
if channel: ...```
#

use a different variable name

slate swan
#

error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'get_server'

code:

@bot.command()
async def leav(ctx, member : discord.Member = None):

    toleave = bot.get_server("903655554403139657")
    await bot.leave_server(toleave)

why does my bot no out of the server?

zenith zinc
vagrant topaz
vagrant topaz
kindred epoch
zenith zinc
#
@commands.command()
  async def join(self,ctx,channel: discord.VoiceChannel=None):
   channel = if channel:
   if not ctx.message.author.voice:
    await ctx.send(f"You are not in voice channel {ctx.author.mention}")
   else:
    embed=discord.Embed(title=f"JOIN", color=0x36393e)
    embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
    await ctx.send(embed=embed)
    channel = ctx.author.voice.channel
    await channel.connect()``` like this
slate swan
#

I put my commands in a cog and now litrelly every command has a error saying Callback for ping command is missing "ctx" parameter.

kindred epoch
slate swan
#

What's self?

kindred epoch
slate swan
#

Wait now it says, Command raised an exception: AttributeError: 'ccog' object has no attribute 'send'

vagrant topaz
zenith zinc
#
@commands.command()
  async def join(self,ctx,channel: discord.VoiceChannel=None):
   channel = if channel:
   if not ctx.message.author.voice:
    await ctx.send(f"You are not in voice channel {ctx.author.mention}")
   else:
    embed=discord.Embed(title=f"JOIN", color=0x36393e)
    embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
    await ctx.send(embed=embed)
    channel = ctx.author.voice.channel
    await channel.connect()``` like this @vagrant topaz
slate swan
vagrant topaz
#

i said replace

zenith zinc
#

him?

vagrant topaz
#

plz format

slate swan
#

I forgot

#

how

vagrant topaz
#

```py
```

slate swan
#
import discord
from discord import client
from discord.ext import commands

class ccog(commands.Cog):

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


    # Event
    @commands.Cog.listener()
    async def on_ready(self):
        print('Bot Is Running')


    # Commands

    @commands.command()
    async def ping(self, ctx):
        await ctx.send(f'Pong {round(client.latency * 1000)}ms')


    @commands.command()
    async def randomn(self, ctx):
        await ctx.send(client.randint(1, 1000000000))


    @commands.command()
    @commands.has_role("Owner")
    async def kick(self, ctx , user : discord.Member):
        await ctx.guild.kick(user)


    @commands.command()
    @commands.has_role("Owner")
    async def ban(self, ctx , user : discord.Member):
        await ctx.guild.ban(user)

def setup(client):
    client.add_cog(ccog(client))

vagrant topaz
#

why are you using client instead of bot

#

nvm

slate swan
#

i can switch

vagrant topaz
slate swan
#

in my main script im using bot

vagrant topaz
slate swan
#

I did the

vagrant topaz
#

which one

slate swan
#

!ping command

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

slate swan
zenith zinc
#
@commands.command()
  async def join(self,ctx,channel: discord.VoiceChannel=None):
   if channel:
    if not ctx.message.author.voice:
     await ctx.send(f"You are not in voice channel {ctx.author.mention}")
   else:
    embed=discord.Embed(title=f"JOIN", color=0x36393e)
    embed.add_field(name=f":succsess: I join in {channel.id} ", value="``Type .wp {music name} to play music ``", inline=False)
    await ctx.send(embed=embed)
    channel = ctx.author.voice.channel
    await channel.connect()``` like this @vagrant topaz
zenith zinc
#

ok

#

relax sorry im dump

vagrant topaz
#
if channel: channel = self.client.get_channel(channel)```
#

also

#

why are you getting the channel when its already defined as a VoiceChannel in your command args

slate swan
zenith zinc
#

@vagrant topaz bro

#

my error is {channel.id} error 'id'

vagrant topaz
#

unless your bot cannot retreive that guild

vagrant topaz
zenith zinc
#

ok

#

replace in?

vagrant topaz
#

bruh move channel.connnect() to before the embed is sent

vagrant topaz
#

you need self.client.latency instead of client.latency

slate swan
#

Oh yeah.

#

Thanks !

vagrant topaz
#

whenever you mention client, make sure to include self.client to instance the bot

slate swan
#

Alright, does that mean i can delete the import client thing?

#

oh no i cant nvm

vagrant topaz
#

i think thats also fucking with your setup() function

#

you have to remove it

slate swan
#

def init(self, bot):
self.client = client

#

i can change it to bot

zenith zinc
vagrant topaz
#

yes but make sure to change EVERY instance

vagrant topaz
vagrant topaz
# slate swan Ok.

because from discord import client is only for your main file to define and run the client

#

when you load a cog, discord calls setup() and passes in bot

vagrant topaz
#

so you pretty much have to remove it unless you change every instance of client to bot

vagrant topaz
vagrant topaz
zenith zinc
#

nono i say you some

vagrant topaz
slate swan
#

Sooo sad, now the fucking bot doesnt start and it gives no error in terminal

vagrant topaz
#

redact token ofc

slate swan
#

import random
import discord
import os
from discord.ext import commands
from discord.ext.commands.bot import Bot

bot = commands.Bot(command_prefix='!')

for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')

bot.run('')

#

hi

#

how i start ??

slate swan
zenith zinc
vagrant topaz
slate swan
#

tyy

vagrant topaz
#

DO NOT USE YOUTUBE

#

YOUTUBE IS SO TERRIBLE

vagrant topaz
#

define channel and connect before you send that embed

slate swan
#

lol

vagrant topaz
#

you are defining channel AFTER you send that embed and thats why its None

slate swan
zenith zinc
vagrant topaz
#

voice is very difficult

manic wing
vagrant topaz
slate swan
#

Nevermind

#

it works now

vagrant topaz
stiff nexus
#

help?

main.py:88: DeprecationWarning: The object should be created within an async function
  self.session = aiohttp.ClientSession(loop=self.loop)
``` how do i not get this??
zenith zinc
vagrant topaz
vagrant topaz
manic wing
slate swan
#

Thanks for the help @vagrant topaz

manic wing
#

aiohttp is an asynchronous library

stiff nexus
vagrant topaz
stiff nexus
#

ya

vagrant topaz
#

its good u fixed the problem urself

manic wing
#

therefore you await that function

zenith zinc
#

im trying find my problem on google

vagrant topaz
vagrant topaz
stiff nexus
#

bruh how can u await in bot class? @manic wing

manic wing
zenith zinc
#

I cut my veins because of the problem good night everyone ๐Ÿ˜—

hollow palm
#
msg = await ctx.channel.send(f"`Now playing: {var3}` \n{url}")
await msg.add_reaction(u"\u23F8")
await msg.add_reaction(u"\u25B6")
while True:
  try:
    reaction, user = await client.wait_for("reaction_add", check=lambda reaction, user: reaction.emoji in [u"\u23F8", u"\u25B6"], timeout=90.0)
  
  except asyncio.TimeoutError:
    return await msg.clear_reactions()
  
  else:
    if reaction.emoji == u"\u23F8":
      await msg.remove_reaction(reaction.emoji, ctx.author)
      await ctx.voice_client.pause()
    elif reaction.emoji == u"\u25B6":
      await msg.remove_reaction(reaction.emoji, ctx.author)
      await ctx.voice_client.resume()

This code is supposed send a message showing what is playing, and bring up pause and play reactions which will pause and play the audio when reacted to by a user. Right now it only runs once during a run of the whole code, this means it will only respond the first time a user calls the command and does a reaction. For example, if a user plays something then pauses through the pause reaction it will pause, but if he then does the play reaction he will get no response. Likewise, if he plays another song after the first one and tries pausing or playing through the reaction he will get no response.

zenith zinc
#

I'm kidding I'm not "crazy"

slate swan
#

hii

zenith zinc
#

hii

slate swan
#

srry but the prob is i wann start but i dont know how to start someone please help me

undone wyvern
#

Start with what?

zenith zinc
#

lol

manic wing
# zenith zinc life

!ot if you want to talk about anything other than discord bots, go elsewhere.

unkempt canyonBOT
rotund nova
#

some know how fix it?

hollow palm
zenith zinc
manic wing
slate swan
#

needs to be a str

rotund nova
#

thanks

zenith zinc
rotund nova
zenith zinc
#

wooooo ๐Ÿ˜Ž

slate swan
manic wing
rotund nova
#

o

manic wing
undone wyvern
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.

rotund nova
#

working, can i add too hour and date?

zenith zinc
#

hm

slate swan
manic wing
hollow palm
#

Caeden you got any idea how to loop it?

rotund nova
#

wait, what how

#
@client.event
async def on_message(message):
    if message.channel.name != "suggestions":
        return
    
    embed = discord.Embed(title="no c", description=f"cc", colour=discord.Colour.light_gray())
    embed.set_author(name="sex", url="https://google.com/", icon_url=message.author.avatar_url)
    embed.add_field(name=f"Sugestie daล‚ {message.author.name}", value=message.content, inline=False)

    embed.set_footer(icon_url="https://media.discordapp.net/attachments/877151912120696873/902977072408973363/LogoMcForever.png", text="Zareaguj emotkami poniลผej")
    msg = await message.channel.send(embed=embed)
    await msg.add_reaction('โœ…')
    await msg.add_reaction('โŒ')
    await message.delete()
manic wing
slate swan
#

@manic winghi the thing u mentioned me ealier i just dont understand what to click

manic wing
# rotund nova wait, what how

just do embed = discord.Embed(*, timestamp=ctx.message.created_at where * represents what else your arguments might be

manic wing
slate swan
#

alr

hollow palm
#

No

manic wing
#

We all want to learn python, but here isnโ€™t the right place

kindred epoch
hollow palm
#

Yes

kindred epoch
#

and whats wrong?

hollow palm
#

It only works once

#

Like you turn on the bot and use the reaction and then it never works again until you rerun the bot

kindred epoch
#

i dont see why it wont work

hollow palm
#

Yeah ive got no idea

slate swan
#

guys, throw off the command so that the bot exits from a certain server

manic wing
unkempt canyonBOT
#

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

Leaves the guild.

Note

You cannot leave the guild that you own, you must delete it instead via [`delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.delete "discord.Guild.delete").
manic wing
hollow palm
#

Its from the try except

waxen granite
#

Is there a way to send the names of the permissions the bot is missing when an cmd is invoked?

slate swan
#

bruh i can't believe my other account got disabled for trying to sell a vanity i owned and worked for

manic wing
#

!ot sounds pretty ot

unkempt canyonBOT
slate swan
#

ehh nothing else was happening so i don't think it matters that much but do you

slate swan
#

If I have a member object, how can I get the member object of the person who invited the member? (discord.py)

fallen mica
wintry shore
#

Caching

slate swan
#

Uh

wintry shore
#

Save members with the invite in your cache when ever they make an invite then you can just pull it off of your cache

slate swan
#

Yeah, but when someone joins the server, how do I get the member who invited him?

marble pilot
#

Can someone tell me how can i detect if a option has been pressed from a option menu?

magic stump
#

Can i put my bot on google cloud this work?

wintry shore
fallen mica
# slate swan How to record invites?

As I mentioned, you need to setup a data base, log all members on join event with the invite they joined with, then you will have to make a command to read the data base logs with each user's value (value being the person who invited them)

kindred epoch
wintry shore
magic stump
#

v

#

discord bots working 3.9 python?

slate swan
#

Yes why

magic stump
steady flume
#

ik i was asking this, but i still cant understand guys, help me please with this error

#

i just want make cmd where u need put amount (int) and also u can put instead of number "all" or "max"

slate swan
#

you can't do bank + amount

#

bank is an str and amount is an int

#

you prolly mean int(bank) + amount?

#

oh wait I know what u mean

#

check if amount's a string even before you try to add it to bank

magic stump
#

`Author identity unknown

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'Uzytkownik@DESKTOP-FR2F8IS.(none)')`

#

i have problem with heroku

slate swan
#

well that's not with discord bots

vagrant topaz
#

not a discord problem

#

literally do what it says

#

its not that hard

magic stump
#

mhm

magic stump
#

file is good

vagrant topaz
#

go ask somewhere else

#

look it up

kindred epoch
#

?

dapper cobalt
slate swan
#

self-promotion

dapper cobalt
# slate swan self-promotion

Well, not really. I'm just helping them out, and myself at the same time. It's a smart play, nothing more nothing less.

pliant gulch
#

Yikes, changing presence in on_ready and in a while-true loop

dapper cobalt
pliant gulch
#

No, lol this was you

dapper cobalt
#

Crap, I got caught.

kindred epoch
#

cuz i dont have a thing where it needs to update every some amount of seconds

dapper cobalt
#

After a wait_until_ready function.

#

!d discord.ext.commands.Bot.wait_until_ready

unkempt canyonBOT
#

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

Waits until the clientโ€™s internal cache is all ready.
pliant gulch
dapper cobalt
#

It's because on_ready can be called multiple times.

pliant gulch
#

And if you mean not a loop, you can pass activity to the bots constructor

dapper cobalt
#

Though, I still won't bother to set the status outside the on_ready event. Why? Because.

kindred epoch
slate swan
#

how do i @ someone in code forgot

kindred epoch
#

.mention

reef shell
unkempt canyonBOT
#

property mention: str```
Returns a string that allows you to mention the given user.
echo wasp
#

can someone help with this issue on Heroku?

floral jacinth
#

is it possible to delete user message on dm?

echo wasp
echo wasp
echo wasp
floral jacinth
#

oook

#

thx

thick sigil
slate swan
#

!d discord.VoiceClient

unkempt canyonBOT
#

class discord.VoiceClient```
Represents a Discord voice connection.

You do not create these, you typically get them from e.g. [`VoiceChannel.connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceChannel.connect "discord.VoiceChannel.connect").

Warning

In order to use PCM based AudioSources, you must have the opus library installed on your system and loaded through [`opus.load_opus()`](https://discordpy.readthedocs.io/en/master/api.html#discord.opus.load_opus "discord.opus.load_opus"). Otherwise, your AudioSources must be opus encoded (e.g. using [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/master/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio")) or the library will not be able to transmit audio.
slate swan
#

!d discord.VoiceProtocol.cleanup

unkempt canyonBOT
#

cleanup()```
This method *must* be called to ensure proper clean-up during a disconnect.

It is advisable to call this from within [`disconnect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol.disconnect "discord.VoiceProtocol.disconnect") when you are completely done with the voice protocol instance.

This method removes it from the internal state cache that keeps track of currently alive voice clients. Failure to clean-up will cause subsequent connections to report that itโ€™s still connected.
slate swan
#

do i call disconnect inside this?

dapper cobalt
slate swan
reef shell
midnight juniper
#

i just made a bot with some super basic stuff, and nothing happens, i need your brains here

#
import json
import os
import discord
import requests


client = discord.Client()


async def on_message(message):
  if message.content.find('robban'):
      for x in client.get_all_emojis():
          if x.id == ':wine_glass:':
              return await client.add_reaction(message, x)


my_secret = os.environ['TOKEN']
client.run(os.getenv('TOKEN'))```
#

what am i missing, it should react with an emoji when someone types robban, right?

hazy fulcrum
hazy fulcrum
floral jacinth
#

how can i fix if total_request > 5 and str(ctx.author.name) is not in user_on: ?
the broken part is str(ctx.author.name) is not in user_on, i dunno how to write it

#

(user_on is a list)

hazy fulcrum
#

all together

floral jacinth
#

i have to check if name isn't on that list

midnight juniper
kindred epoch
#

@midnight juniper theres nothing called message.content.find and get_all_emoji

#

and id is supposed to be an int not a emoji

midnight juniper
#

no saw that now, im just grabbing stuff from stack overflow to see if i can get anything to happen at all

hazy fulcrum
#

oh..

somber musk
#

I haven't coded a discord bot in python so looong!

#

I've gotten used to js discord bots

hazy fulcrum
#

same

midnight juniper
#
async def on_message(message):
  if message.content == "ping":
    return await client.add_comment("pong")

#

but this should work right?

kindred epoch
midnight juniper
#

no?

kindred epoch
#

then why are you copying code from stackoverflow?

hazy fulcrum
#

wait no

hazy fulcrum
#

add_comment is not a function anymore I think

midnight juniper
#

ok,

#

this is confusing

#

not u but all the depricated stuff

kindred epoch
somber musk
midnight juniper
hazy fulcrum
#

just do

@client.event
async def on_message(message):
  if message.content == 'Give me Drugs':
     await message.reply('Alright here')
midnight juniper
#

cool

#

ill try

somber musk
#

Epic example @hazy fulcrum

hazy fulcrum
#

i know lemon_swag

midnight juniper
#

how darn awesome

#

thanks alot, now i just need to brush up that syntax, but at least i know it works

hazy fulcrum
#

if you dont want it like that, just do await message.send("Something")

#

no problem ๐Ÿ™‚

midnight juniper
#

yeah i understand that ๐Ÿ˜‰

#

thanks a million

hazy fulcrum
#

๐Ÿ‘

somber musk
#

You can also do

if message.content.startswith('give me drugs')
await message.channel.send('alright here')
#

Obviously with indents and shit

midnight juniper
kindred epoch
midnight juniper
#

do i close?

#

!close

#

haha ok no then

hazy fulcrum
#

you cant, its the official channel

somber musk
#

Also it seems like you don't know the basics of a discord bot, so u sure u don't wanna learn a bit of python be4 or are you just new to bots

midnight juniper
#

ive never touched bots

somber musk
#

I recommend just going through some tutorials on yt

midnight juniper
#

but im 3 months away from graduating as an IoT -dev

#

but ill check the youtube stuff

somber musk
#

Ooh really?

kindred epoch
#

yt tutorials are garbage

somber musk
kindred epoch
#

bruh

somber musk
#

They will learn the fundamentals and basic knowledge of the bots

kindred epoch
#

all of them are outdated/will learn dumb stuff

somber musk
#

Not really

kindred epoch
#

made by one of the helpers

#

and former project leads

midnight juniper
#

it seems like most of the examples are depricated stuff, or at least the ones i've found

kindred epoch
somber musk
#

There's these 30 view videos that are the best tutorials

#

Lmaoo

midnight juniper
#

haha

somber musk
#

Do u all have 24/7 bots?

midnight juniper
#

is it juicy?

somber musk
#

Hmm?

kindred epoch
#

and 24/7

somber musk
#

All = y'all referring to you guys
24/7 means always online

midnight juniper
#

ah yeah, replit

#

so its hella hosted'

kindred epoch
#

ew

mortal dove
#

Can I get an example on how to put links with custom display text in a discord.py embed?

kindred forge
#

what hosting are u using?

#

is it free?

pliant gulch
#

Aren't those only valid for 1 year

kindred forge
#

you mean free trial?

mortal dove
#

thanks @slate swan

kindred forge
#

btw is it possible to implement bots on facebook messenger ?

stark hearth
#

^^^

#

also tbh finding a hosting service for a discord bot is one of the hardest things in developing a bot due to the free trials and all

kindred epoch
stark hearth
#

or something

slate swan
kindred epoch
slate swan
valid perch
#

Its for websites

slate swan
valid perch
#

Things that don't need to be up 24/7, but rather spin up on requests generally from what I've seen (heroku wise)

slate swan
stark hearth
#

im using heroku but really want to move out of it :(

pliant gulch
valid perch
#

Idk, I've never used it

stark hearth
kindred epoch
valid perch
#

I pay my few bucks a month for a vps lol

kindred epoch
#

vultr all the way

kindred epoch
#

or oceanblack or something like that

pliant gulch
#

Nah linode

stark hearth
#

anyways, what is a cheap and good vps?

slate swan
#

Was about to ask that

kindred epoch
pliant gulch
#

Linode

slate swan
hazy fulcrum
#

Replit is good, you can just buy hacker plan for 24/7 host. @midnight juniper

stark hearth
valid perch
#

Buy a vps at that point lol

pliant gulch
hazy fulcrum
#

true

pliant gulch
#

Theres no point to waste money on repl.it as a hosting service

#

That's just a waste of money

pliant gulch
hazy fulcrum
#

true, unless your on a chromebook

valid perch
#

$7 a month, could spend half for more on a vps

kindred epoch
pliant gulch
#

Those are dedicated servers

#

Look at the shared ones

slate swan
#

Whats a good vps that has a year plan?

pliant gulch
#

Oh yikes 1gb for 5$?

#

I guess they must've changed their stuff

stark hearth
hazy fulcrum
#

lol

#

replit for the win?

pliant gulch
#

Go for digital ocean then

hazy fulcrum
#

or just selfhost

valid perch
#

Idk, I feel vultr is good as an entry point but imma be jumping from my current provider to contabo soon since I want scale

pliant gulch
#

Has a 100 credit for 6 months

#

Cheap shared servers

pliant gulch
#

Vultr was good as well, I used it before, but I do remember having it go offline for a few hours

slate swan
#

you can use free hacker codes like
techwithtim or
MH

pliant gulch
#

iirc its something about not having ddos protecting or whatever

kindred epoch
pliant gulch
#

But it was a odd situation

kindred epoch
#

they start with $5 but vultr starts with 2.50

stark hearth
pliant gulch
#

Well, 1gb is a lot for a small discord bot

kindred epoch
#

yea

pliant gulch
#

Your only gonna be using like 300mb of memory or 600mb

#

Depending on members cache

valid perch
#

vultr good for the cheapness, and just getting in but when you grow I'd change to paying a bit more for way more

#

personally

pliant gulch
#

Rather just get a dedicated server and host more than just a discord bot

stark hearth
#

how do you deploy code into vultr? github or??

valid perch
#

I host way too much on my vps lol

pliant gulch
#

Seems kinda pointless to me to dedicate one server to hosting a bot after the market is so saturated

slate swan
#

Whats the minimal specs for a discord bot like 2gb? Of ram

valid perch
#

One of the reason I stopped bot dev and moved to making packages for developers and stuff. Better auidence as well, don't have to deal with people as much

kindred epoch
#

i host my db and bot on the same server ๐Ÿ˜ฌ

valid perch
#

Guild wise

pliant gulch
#

Ah making packages are amazing

#

Don't even get me started on contributors though

slate swan
valid perch
#

Dealing with developers vs dealing with people tryna use your bot tho

pliant gulch
#

Competent developers are fine

valid perch
pliant gulch
#

Its the others that drive me insane

#

And I cba to write a code of conduct or contributing

slate swan
valid perch
stark hearth
#

how would do you deploy code into vultr?

valid perch
kindred epoch
pliant gulch
#

You guys FTP?

#

I just clone the repo and run it

stark hearth
slate swan
pliant gulch
#

Memory scales with the amount of members

valid perch
#

Personally I just use docker via portainer, didn't ssh into my server for months outside of updates

pliant gulch
#

As it gets cached

slate swan
kindred epoch
pliant gulch
#

You probably can

valid perch
#

Doesn't get used a lot tho, but members should be cached

kindred epoch
#

cuz i can update files in github from atom

stark hearth
#

like if your bot stores in like mutes, warns, etc., the amount of members can determine how much memory you should get

valid perch
#

So you get aware with the smallest vps your provider offers is all im saying

valid perch
kindred epoch
#

im sure vultr with 3.50 or 2.50 plan can be good for like 200-250 server bot

valid perch
#

You just get the small one and scale when required

#

tbh

kindred epoch
#

the reason i got 3.50 was cuz of the ipv4 adress

pliant gulch
#

That's what I did for one of my production bots

valid perch
#

Yea, could optimize it but why bother personally. If it were bigger then yea but not fussed over ~40mb

pliant gulch
#

That is true

#

But then again discord.py isn't very performance efficient imo

#

The sharding isn't really sharding as well imo

#

Not what it could be at least

valid perch
#

Fair

#

How fair along is your api wrapper btw?

pliant gulch
#

Following the flow chart, only need converters, attach more methods and finish interactions and its off to v1.0.0

#

I started components this morning

#

Sharding is done as well, but I have plans for a cluster manager

#

"True sharding" ig

valid perch
#

Might add it to my list of if I get bored I'll add support for python discord packages ๐Ÿ˜‚

#

If its at the point where people could make proper bots in

#

clustering with ipc, shared state or?

#

*Shared cache

pliant gulch
#

IPC seems more preforment

#

And it should be ready for regular use, at least the commands extension is basically done

#

It just needs permissions checking and its ready

#

I already have Cogs, and the core of it finished

valid perch
#

Soundds good to me then

#

Do you provide an external api method to build embeds from dict's

pliant gulch
#

But can't really say anything about stability for now, still in alpha and I haven't gotten heavy testing on a production bot running it

#

Yes theres an embed builder

#

Oh wait you mean from dictionaries

#

That could be added pretty easily

valid perch
#

Just because internally I need one, saves me writing one if it already exists

pliant gulch
#

The embed class has a to dict method, but I'll take that suggestion

#

I can add from_dict right now

valid perch
#

Alright

#

If it ain't there when I make an impl I'll pr one in

#

I mean, you likely need one internally anyway..?

#

To parse discord's api data into your Embed

#

@pliant gulch

pliant gulch
#

I was not the one who PR'd the embed builder so I don't have it currently

valid perch
#

Ah

pliant gulch
#

Actually, I think I'll revamp the Embed builder

#

This ones way to class based

#

Makes it cumbersome to do stuff

valid perch
#

Aight

#

How stable do you think you general class structure is?

pliant gulch
#

General class structure as in?

#

The clients?

valid perch
#

Stuff like Message and channels but dw

pliant gulch
#

In a limbo state

#

They are semi-implemented

#

We have all HTTP methods done, just haven't attached them to the models

#

Still looking for someone to do them but seems like me and my collaborator will have to do them

valid perch
#

Aight

coral marlin
#

Okay thanks,

So I have

warns = sorted(warns, key=lambda x: x["number"])
        
        pages = []
        for warn in warns:
            description = f"""
            Warn Number: `{warn['number']}`
            Warn Reason: `{warn['reason']}`
            Warned By: <@{warn['warned_by']}>
            Warn Date: {warn['timestamp'].strftime("%I:%M %p %B %d, %Y")}
            """
            pages.append(description)
        
        await Pag(
            title=f"Warns for `{member.display_name}`",
            colour=0xCE2029,
            entries=pages,
            length=1
        ).start(ctx)

where it says await pag, how could I replace that to make pages with nextcord? (Since nextcord already has pagination built it)

valid perch
#

Using menus?

valid perch
spring verge
#

Is nextcord better or hikari?

valid perch
#

define better

spring verge
#

Easier to implement imo

coral marlin
#

I'd probably say nextcord

valid perch
#

Nextcord is discord.py, so if you currently use dpy it'll be 10x easier since its the same

coral marlin
valid perch
#

Otherwise your learning something new either way

spring verge
#

Ohh well I never used discord.py and I have been learning hikari/lightbulb for a few weeks so ig I will stick to it?

valid perch
spring verge
#

Because there are so many libraries that I get confused lol

valid perch
valid perch
spring verge
#

Btw I had a doubt.. I am currently using postgres to store data like prefixes etc.. should I also use it to store experience or ranks of people through user IDs?

#

Or I should migrate to a better rdbms

valid perch
#

Not sure how true this is anymore, but I think the only thing hikari lacks compared to dpy is voice stuff. Although there are no doubt extensions for it like yaru (I think its called that)

valid perch
#

postgres is nice yes, just make a user table for people by id as well

#

Not sure what would be better then postgres

spring verge
#

Oh well I recently learned sql

#

So I am not sure which is the best free rdbms

#

and I started with postgres

valid perch
#

Good choice tbh, I'd stick with it

spring verge
#

Okay ๐Ÿ‘

valid perch
#

You can look at nextcord.ext.commands.help.py for examples on how to use it since its what the help command uses

patent lark
valid perch
#

Fair enough, I wanna make a mobile app over summer actually lol

spring verge
#

Nice

patent lark
#

nothing.

slate swan
#

Unless your not using bot

vagrant topaz
#

full code?

slate swan
#

maybe can raise a error of the bot not being defined or a eol scanning string error but thats just discord i think

vagrant topaz
#

error?

#

ok then why ask

slate swan
vagrant topaz
slate swan
#

kinda useless when people have years of experience

vagrant topaz
#

^^

slate swan
#

here

#

not me cuz ive only been coding for 5months but im not a beginner either

vagrant topaz
slate swan
#

thats pog

#

ducky_dave how is dat a flex

vagrant topaz
#

feels like i know more than ppl (not true)

slate swan
#

just a cool fact about him you know

#

is it possible to make tests for a discord bot? since it uses the discord api, not the code to create responses

slate swan
slate swan
slate swan
slate swan
vagrant topaz
#

i fucking hate when ppl say "HELLLO @near ospreyNNNN SOLVE MY PROBLEMS::: await fuckyou()"

slate swan
vagrant topaz
#

w h o o p s

#

please dont name yourself that or any other common word

slate swan
vagrant topaz
slate swan
#

but if it helps you out go for it

slate swan
slate swan
vagrant topaz
#

@quaint axle

slate swan
#

they dont even check what versions the code is for

vagrant topaz
#

@bot

vagrant topaz
slate swan
slate swan
slate swan
#

ok i gtg, sorry

#

im in class now

#

alr

slate swan
slate swan
slate swan
#

if you want to test something without really adding it to your bot , use jishaku

#

@vagrant topaz they probably dont state their errors right for the fear of getting humiliated here but i dont blame them theres lots of people here who know their stuff

pliant gulch
pliant gulch
#

Skelmis mind taking a look at my revamp of embeds?

#

Not sure if it looks alright

valid perch
#

link?

pliant gulch
valid perch
#

interesting

#

Have you thought about slotting it

#

also maybe hiding the data variable

pliant gulch
#

Hmm having slotted any of my models yet

#

Does slotting really matter here

#

And yea Ill make data a "private" variable

valid perch
#

What do you stand to lose by slotting?

pliant gulch
#

Nothing just wonder about it

#

I know theres a performance boost

valid perch
#

Given its not a dynamic class end users need to modify theres not a point to not doing it imo. Besides, they can just add to your data if they really want

pliant gulch
#

Wait but if I use slots wont I be unable to use @property

valid perch
#

Should be fine