Thursday, December 10, 2020

the entire code for my old discord bot

bot.py

import discord from discord.ext import commands from discord.ext.commands import Bot from util.config import owner_id, owner, token, version, cogs, prefix import datetime import asyncio now = datetime.datetime.now() bot = commands.Bot(command_prefix=prefix) bot.remove_command('help') startup_extensions = cogs # on start print ("Connecting...") @bot.event async def on_ready(): print ("bot online") await asyncio.sleep(0.1) print ("I am " + bot.user.name) print ("id: " + bot.user.id) print ("made by " + owner) print ("running bot version " + version) print ("discord version " + discord.__version__) print ("================================") print(now.strftime('started on %m/%d/%Y at %I:%M %p')) await bot.change_presence(game=discord.Game(name=now.strftime('started on %m/%d/%Y at %I:%M %p'))) @bot.command(pass_context=True) async def load(ctx, extension_name : str): """Loads an extension.""" if ctx.message.author.id == owner_id: try: bot.load_extension(extension_name) except (AttributeError, ImportError) as e: await bot.say("```py\n{}: {}\n```".format(type(e).__name__, str(e))) return await bot.say("{} loaded.".format(extension_name)) print ("loaded {}".format(extension_name)) else: await bot.say("bot owner only") @bot.command(pass_context=True) async def unload(ctx, extension_name : str): """Unloads an extension.""" if ctx.message.author.id == owner_id: bot.unload_extension(extension_name) await bot.say("{} unloaded.".format(extension_name)) print ("unloaded {}".format(extension_name)) else: await bot.say("bot owner only") @bot.command(pass_context=True) async def reload(ctx, extension_name : str): """reloads an extension.""" if ctx.message.author.id == owner_id: try: bot.unload_extension(extension_name) asyncio.sleep(.5) bot.load_extension(extension_name) except (AttributeError, ImportError) as e: await bot.say("```py\n{}: {}\n```".format(type(e).__name__, str(e))) return await bot.say("{} reloaded.".format(extension_name)) print ("reloaded {}".format(extension_name)) else: await bot.say("bot owner only") if __name__ == "__main__": for extension in startup_extensions: try: bot.load_extension(extension) except Exception as e: exc = '{}: {}'.format(type(e).__name__, e) print('Failed to load extension {}\n{}'.format(extension, exc)) bot.run(token) 

fun.py

from discord.ext import commands from cogs.lists import regional_map, eightball_responses import discord import random class Fun(): def __init__(self, bot): self.bot = bot @commands.command(pass_context=True, name="cogs.fun") async def c_fun(self, ctx): embed = discord.Embed(title="cogs.fun active") await self.bot.say(embed=embed) @commands.command(aliases=['indicator']) async def regional(self, *, txt:str): """converts words to regional indicators""" msg = '' for s in txt.lower(): if s in regional_map: msg += u'​'+regional_map[s] else: msg += s embed = discord.Embed(title=msg, color=0x3b88c3) await self.bot.say(embed=embed) @commands.command() async def roll(self, dice : str): """Rolls the dice""" try: rolls, limit = map(int, dice.split('d')) except Exception: await self.bot.say('Format has to be in NdN!') return result = ', '.join(str(random.randint(1, limit)) for r in range(rolls)) embed = discord.Embed(title="you rolled "+dice) embed.add_field(name="and got", value=result, inline=True) await self.bot.say(embed=embed) @commands.command() async def choose(self, *choices : str): """Chooses between multiple choices.""" embed = discord.Embed(title=random.choice(choices)) await self.bot.say(embed=embed) @commands.command(name='8ball') async def eight_ball(self): """uses a magic 8ball""" embed = discord.Embed(title="magic 8ball", color=0x660066) embed.add_field(name="8ball says", value=random.choice(eightball_responses), inline=True) await self.bot.say(embed=embed) @commands.command(name='coinflip') async def coin_flip(self): """flips a coin""" possible_responses = ['tails', 'heads'] outcome = random.choice(possible_responses) embed = discord.Embed(title="you flipped "+outcome, color=0x666666) await self.bot.say(embed=embed) @commands.command() async def say(self, *,content): await self.bot.say(content) def setup(bot): bot.add_cog(Fun(bot)) 

useless.py

from discord.ext import commands import discord class Useless(): def __init__(self, bot): self.bot = bot @commands.command(pass_context=True, name="cogs.useless") async def c_useless(self, ctx): embed = discord.Embed(title="cogs.useless active") await self.bot.say(embed=embed) @commands.command(pass_context=True) async def useless(self, ctx): """shows list of useless stuff""" embed = discord.Embed(title="useless stuff", color=0x00ff00) embed.add_field(name="ur_gay", value="calls the bot gay", inline=True) embed.add_field(name="no_u", value="tells the bot no u", inline=True) embed.add_field(name="k", value="bot says ok", inline=True) embed.add_field(name="s", value="bot says shutup", inline=True) embed.add_field(name="f", value="press f to pay respects", inline=True) embed.add_field(name="np", value="bot says no problem", inline=True) await self.bot.say(embed=embed) @commands.command(pass_context=True) async def ur_gay(self, ctx): await self.bot.say("no u") @commands.command(pass_context=True) async def no_u(self, ctx): await self.bot.say("no u") @commands.command() async def lenny(self): await self.bot.say("( ͡° ͜ʖ ͡°)") @commands.command() async def tableflip(self): await self.bot.say("(╯°□°)╯︵ ┻━┻") @commands.command() async def secret(self): await self.bot.say("OOOooo00") @commands.command(name="@e") async def aut1(self): await self.bot.say("@everyone") @commands.command(name="@h") async def aut2(self): await self.bot.say("@here") @commands.command() async def k(self): await self.bot.say("ok") @commands.command() async def s(self): await self.bot.say("shut up") @commands.command() async def f(self): await self.bot.say("+1 respect") @commands.command() async def np(self): await self.bot.say("no problem") def setup(bot): bot.add_cog(Useless(bot)) 

info.py

from discord.ext import commands from datetime import time from util.config import owner import discord import requests import datetime import time class Info(): def __init__(self, bot): self.bot = bot @commands.command(pass_context=True, name="cogs.info") async def c_info(self, ctx): embed = discord.Embed(title="cogs.info active") await self.bot.say(embed=embed) @commands.command(pass_context=True) async def help(self, ctx): """shows command usage""" embed = discord.Embed(title="Commands usage", description="type cmd for list of commands", color=0x00ff00) embed.add_field(name="info", value="info <username>", inline=True) embed.add_field(name="roll", value="roll 1d20 <1=amount>d<20=sides>", inline=True) embed.add_field(name="choose", value="choose <option> <option>", inline=True) embed.add_field(name="say", value="say <something>", inline=True) embed.add_field(name="add", value="add <number> <number>", inline=True) embed.add_field(name="sub", value="sub/subtract <number> <number>", inline=True) embed.add_field(name="mult", value="mult/multiply <number> <number>", inline=True) embed.add_field(name="regional", value="regional <something>") await self.bot.say(embed=embed) @commands.command(pass_context=True, aliases=['commands']) async def cmd(self, ctx): """shows command list""" embed = discord.Embed(title="Commands", color=0x00ff00) embed.add_field(name="help/help1", value="shows command usages", inline=True) embed.add_field(name="info", value="shows info about user", inline=True) embed.add_field(name="server", value="shows info about server", inline=True) embed.add_field(name="roll", value="rolls the dice", inline=True) embed.add_field(name="choose", value="chooses a random option", inline=True) embed.add_field(name="8ball", value="uses a magic 8ball") embed.add_field(name="regional", value="converts words to regional idicators") embed.add_field(name="say", value="maked bot say stuff") embed.add_field(name="add,sub,mult", value="does math", inline=True) embed.add_field(name="bitcoin", value="shows bitcoin value", inline=True) embed.add_field(name="picture", value="shows picture of the week", inline=True) embed.add_field(name="insults", value="shows a list of insults", inline=True) embed.add_field(name="useless", value="shows useless commands", inline=True) embed.add_field(name="changelog", value="shows bot changelog", inline=True) embed.add_field(name="invite", value="shows bot invite link") embed.add_field(name="craig", value="says a random craig quote", inline=True) embed.add_field(name="five", value="shows 5 craig quotes", inline=True) embed.add_field(name="cmd1", value="shows restricted commands", inline=True) await self.bot.say(embed=embed) @commands.command(pass_context=True) async def server(self, ctx): """gets info about server""" embed = discord.Embed(name="{}'s info".format(ctx.message.server.name), description="Here's what I could find.", color=0x00ff00) embed.add_field(name="Name", value=ctx.message.server.name, inline=True) embed.add_field(name="ID", value=ctx.message.server.id, inline=True) embed.add_field(name="owner", value=ctx.message.server.owner, inline=True) embed.add_field(name="region", value=ctx.message.server.region, inline=True) embed.add_field(name="created", value=ctx.message.server.created_at.__format__('%A, %B %d. %Y'), inline=True) embed.add_field(name="Roles", value=len(ctx.message.server.roles), inline=True) embed.add_field(name="emojis", value=len(ctx.message.server.emojis), inline=True) embed.add_field(name="members", value=len(ctx.message.server.members), inline=True) embed.add_field(name="highest role", value=ctx.message.server.role_hierarchy[0], inline=True) embed.add_field(name="varification level", value=str(ctx.message.server.verification_level), inline=True) embed.set_thumbnail(url=ctx.message.server.icon_url) await self.bot.say(embed=embed) @commands.command(pass_context=True) async def info(self, ctx, user: discord.Member): """gets info about user""" embed = discord.Embed(title="{}'s info".format(user.name), description="Here's what I could find.", color=0x00ff00) embed.add_field(name="Name", value=user.name, inline=True) embed.add_field(name="Status", value=user.status, inline=True) embed.add_field(name="Highest role", value=user.top_role) embed.add_field(name="Joined", value=user.joined_at.__format__('%A, %B %d. %Y')) embed.add_field(name="created", value=user.created_at.__format__('%A, %B %d. %Y')) embed.set_thumbnail(url=user.avatar_url) await self.bot.say(embed=embed) @commands.command(pass_context=True) async def autismo(self, ctx): now = datetime.datetime.now() t1 = time.perf_counter() await self.bot.send_typing(ctx.message.channel) t2 = time.perf_counter() embed = discord.Embed(title=self.bot.user.name, description="made with discord.py and visual studio") embed.set_thumbnail(url=ctx.bot.user.avatar_url) embed.add_field(name="developer", value=owner, inline=False) embed.add_field(name="Servers", value=len(ctx.bot.servers), inline=False) embed.add_field(name="official server", value="https://discord.gg/Reqm2RT", inline=False) embed.add_field(name="code", value="https://github.com/bobthehuman/Autismo", inline=False) embed.add_field(name="latency: {}ms".format(round((t2-t1)*1000)), value=('%s/%s/%s' % (now.month, now.day, now.year)), inline=False) await self.bot.say(embed=embed) @commands.command() async def invite(self): """shows invite link""" await self.bot.say("<insert bot link here>") @commands.command(aliases=['$b']) async def bitcoin(self): """shows current bitcoin value""" url = 'https://api.coindesk.com/v1/bpi/currentprice/BTC.json' response = requests.get(url) value = response.json()['bpi']['USD']['rate'] embed = discord.Embed(title="current bitcoin value is $"+value, color=0xb38600) await self.bot.say(embed=embed) def setup(bot): bot.add_cog(Info(bot)) 

No comments:

Post a Comment