Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import random
- from discord.ext import commands
- from discord.ext.commands import Bot
- import asyncio
- import json
- import os
- # the prefix that will trigger commands
- bot = commands.Bot(command_prefix='.')
- TOKEN = 'hidden sry'
- d = {"warning1": []}
- @bot.event
- async def on_ready():
- print("Ready when you are")
- print(f"I am running on: {bot.user.name}")
- print(f"With the ID: {bot.user.id}")
- print(discord.__version__)
- @bot.command()
- async def userinfo(ctx, user: discord.Member=None): # user: discord.User takes on the person tagged
- alltheroles = ""
- # if ctx.channel.id == 445924221021978624: # check if it's in the right channel
- # await ctx.author.send("test") # for private message
- embed = discord.Embed(title="User info for " + str(user), description="Below you'll find your user info!", color=0xeee657)
- embed.add_field(name="Nickname", value=str(user), inline=False)
- embed.add_field(name="User ID", value=user.id, inline=False)
- for i in range(0, len(user.roles)):
- alltheroles += str(user.roles[i])
- alltheroles += ", "
- embed.add_field(name="Roles", value=alltheroles, inline=False)
- await ctx.send(embed=embed)
- @bot.command()
- async def warn(ctx, user: discord.Member=None):
- with open("test.json", "r") as fp:
- d["warning1"].append(str(user.id))
- await ctx.send(d["warning1"])
- @bot.command()
- async def choose(ctx, *args):
- choices = [*args]
- await ctx.send(random.choice(choices))
- @bot.event
- async def on_message(message):
- if message.channel.id == 445924221021978624 and message.author.id != 444166970380648448:
- await message.channel.send("<@227896738873212929> {0} has requested your assistance!".format(message.author))
- pass
- await bot.process_commands(message)
- @bot.after_invoke
- async def after_any_command(ctx): # if any command is called
- channel = bot.get_channel(445928176624074752)
- await channel.send("User {0} has used command: ".format(ctx.author) + "{0.command}".format(ctx))
- # {0} to pass the name and {0.command} to pass the command used (ctx is the context that triggered command
- pass
- bot.run(TOKEN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement