D
Deleted member 1442
Guest
Hello, I wanted to make a public discord bot when I started discord. I have the bot setup in my server, but I want to expand. I created another python file for the public bot, because I wanted there to be commands for my server. I want to save all the data for one server put it on a JSON file and use that for each server.
I'm not familiar with discord.py. Here's what data I need to save for each server:
Prefix.
Server id & server name (I already can get the server id with ctx.guild.id, but I don't know how to get the name of it and store it.)
Permissions for roles.
Role IDs and name for auto-role.
Channel id and name for !announcement.
I want this data to work like im in blank server and their prefix for my bot is '$' and cool server and their prefix for my bot is '>' and both would still work with different prefixs & data in different servers.
Here's my code already for the PUBLIC BOT.
I'm not familiar with discord.py. Here's what data I need to save for each server:
Prefix.
Server id & server name (I already can get the server id with ctx.guild.id, but I don't know how to get the name of it and store it.)
Permissions for roles.
Role IDs and name for auto-role.
Channel id and name for !announcement.
I want this data to work like im in blank server and their prefix for my bot is '$' and cool server and their prefix for my bot is '>' and both would still work with different prefixs & data in different servers.
Here's my code already for the PUBLIC BOT.
Python:
Import discord.py
import discord
from discord.ext import commands
from db import *
#Client
client = commands.Bot(command_prefix='!') #default
TOKEN = 'my token'
#startup
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="discord.gg/mydiscordserver | !"))
@client.event
async def on_member_join():
'''Some Code'''
class all_commands:
@client.command(brief='Will send a message called "Pong!', description='Will send a message called "Pong!')
async def ping(ctx):
await ctx.send(f'Pong! {ctx.message.author.mention}')
@client.command(brief='Will say what every after the command.', description='This command will print in the command line.')
@commands.has_any_role("Administrator")
async def say(ctx, *, message):
#await ctx.message.delete()
await ctx.send(f'{message}' .format(message))
@client.command(brief='Will change the prefix of the bot, until restarted. (Developer Only)', description='Will change the prefix of the bot, until restarted.')
@commands.has_any_role("Administrator")
async def prefix(ctx, prefix):
client.command_prefix = prefix
await ctx.send(f"Prefix changed to ``{prefix}``")
@client.command(brief='Will clear chat.', description='Will clear chat.')
@commands.has_any_role("Administrator")
async def clear(ctx, amount = 1000):
await ctx.message.delete()
await ctx.channel.purge(limit = amount)
#run
client.run(TOKEN)