New commands, new quotes, tweaks

This commit is contained in:
archfan 2019-07-12 07:58:23 -04:00 committed by GitHub
parent ccd30aa207
commit d92e4b1970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 28 deletions

55
cogs.py
View File

@ -3,6 +3,7 @@ from discord.ext import commands
import random import random
import settings import settings
import checks import checks
import misc
class Moderation(commands.Cog): class Moderation(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
@ -46,11 +47,12 @@ class Moderation(commands.Cog):
await ctx.send('Kicked '+str(i)+' member(s).') await ctx.send('Kicked '+str(i)+' member(s).')
@commands.command(help = 'Mass-deletes a specified number of messages in the current channel.') @commands.command(help = 'Mass-deletes a specified number of messages in the current channel.')
@commands.check(checks.bot_admin_or_manage_messages)
@commands.check(checks.admin_or_manage_messages) @commands.check(checks.admin_or_manage_messages)
@commands.check(checks.bot_admin_or_manage_messages)
async def clear(self, ctx, amount : int): async def clear(self, ctx, amount : int):
if amount < 1: if amount < 1:
await ctx.send('You need') await ctx.send('You can only clear a positive number of messages!', delete_after=5)
return
await ctx.message.delete() await ctx.message.delete()
i = 0 i = 0
async for message in ctx.channel.history(limit = amount): async for message in ctx.channel.history(limit = amount):
@ -95,15 +97,10 @@ class Fun(commands.Cog):
description = choice, description = choice,
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
choice_embed.set_footer(text=random.choice(settings.quotes_short)) choice_embed.set_footer(text = misc.get_embed_footer(ctx))
choice_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) choice_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await ctx.send(embed=choice_embed) await ctx.send(embed=choice_embed)
@commands.command(help = '"Let Me Google That For You": Returns a link to search the term on Google.')
async def lmgtfy(self, ctx, *, term):
msg = 'https://google.com/search?q=' + term.replace(' ', '+')
await ctx.send(msg)
@commands.command(help = 'Randomly picks an option from a comma-separated list.') @commands.command(help = 'Randomly picks an option from a comma-separated list.')
async def choose(self, ctx, *, options): async def choose(self, ctx, *, options):
picks = options.split(',') picks = options.split(',')
@ -112,7 +109,19 @@ class Fun(commands.Cog):
description = 'I pick '+choice+'.', description = 'I pick '+choice+'.',
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
pick_embed.set_footer(text=random.choice(settings.quotes_short)) pick_embed.set_footer(text = misc.get_embed_footer(ctx))
pick_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await ctx.send(embed=pick_embed)
@commands.command(help = 'Randomly selects a user in the server.')
async def pickuser(self, ctx):
pick = random.choice([member for member in ctx.guild.members if not member.bot])
pick_embed = discord.Embed(
title = 'I pick...',
description = pick.mention+'!',
colour = discord.Colour.gold()
)
pick_embed.set_footer(text = misc.get_embed_footer(ctx))
pick_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) pick_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await ctx.send(embed=pick_embed) await ctx.send(embed=pick_embed)
@ -128,9 +137,35 @@ class Utility(commands.Cog):
@commands.command(help = 'Invite link for the bot.') @commands.command(help = 'Invite link for the bot.')
async def invite(self, ctx): async def invite(self, ctx):
invite_embed = discord.Embed( invite_embed = discord.Embed(
description = '[Invite me!](https://discordapp.com/api/oauth2/authorize?client_id=576776255513296896&permissions=0&scope=bot)\n'+random.choice(settings.quotes), description = '[Invite me!](https://discordapp.com/api/oauth2/authorize?client_id='+str(ctx.bot.user.id)+'&permissions=0&scope=bot)',
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
invite_embed.set_thumbnail(url=ctx.bot.user.avatar_url) invite_embed.set_thumbnail(url=ctx.bot.user.avatar_url)
invite_embed.set_author(name = str(ctx.author), icon_url = ctx.author.avatar_url) invite_embed.set_author(name = str(ctx.author), icon_url = ctx.author.avatar_url)
invite_embed.set_footer(text = misc.get_embed_footer(ctx))
await ctx.send(embed=invite_embed) await ctx.send(embed=invite_embed)
@commands.command(help = 'Shows information about the server.')
async def serverinfo(self, ctx):
guild = ctx.guild
info_embed = discord.Embed(
title = ctx.guild.name,
colour = discord.Colour.gold()
)
info_embed.add_field(
name = 'General',
value = 'Total members: '+str(len(guild.members))+'\nBot users: '+str(len([member for member in guild.members if member.bot]))+'\nTotal Channels: '+str(len(guild.channels)-len(guild.categories))+'\nText Channels: '+str(len(guild.text_channels))+'\nVoice Channels: '+str(len(guild.voice_channels))
)
info_embed.add_field(
name = 'Server',
value = 'Owner: '+ctx.guild.owner.mention+'\nTotal Roles: '+str(len(guild.roles))+'\nServer Region: `'+str(guild.region)+'`\nGuild ID: `'+str(guild.id)+'`'
)
info_embed.set_thumbnail(url = guild.icon_url)
info_embed.set_author(name = str(ctx.author), icon_url = ctx.author.avatar_url)
info_embed.set_footer(text = misc.get_embed_footer(ctx))
await ctx.send(embed=info_embed)
@commands.command(help = '"Let Me Google That For You": Returns a link to search the term on Google.')
async def lmgtfy(self, ctx, *, term):
msg = 'https://google.com/search?q=' + term.replace(' ', '+')
await ctx.send(msg)

36
main.py
View File

@ -3,6 +3,7 @@ from discord.ext import commands
import cogs import cogs
import settings import settings
import random import random
import misc
bot = commands.Bot(command_prefix='=') bot = commands.Bot(command_prefix='=')
@ -14,6 +15,7 @@ bot.add_cog(cogs.Utility(bot))
async def on_ready(): async def on_ready():
activity = discord.Activity(name=bot.command_prefix+'help', type=discord.ActivityType.watching) activity = discord.Activity(name=bot.command_prefix+'help', type=discord.ActivityType.watching)
await bot.change_presence(activity = activity) await bot.change_presence(activity = activity)
bot.appinfo = await bot.application_info()
print('Logged in as '+str(bot.user)+'\n---\nGuilds: '+str(len(bot.guilds))) print('Logged in as '+str(bot.user)+'\n---\nGuilds: '+str(len(bot.guilds)))
@bot.event @bot.event
@ -38,7 +40,7 @@ class AutoArchHelpCommand(commands.MinimalHelpCommand):
description = self.get_opening_note(), description = self.get_opening_note(),
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
help_embed.set_footer(text = random.choice(settings.quotes_short)) help_embed.set_footer(text = misc.get_embed_footer(ctx))
help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
for cog in mapping.keys(): for cog in mapping.keys():
@ -59,7 +61,7 @@ class AutoArchHelpCommand(commands.MinimalHelpCommand):
description = command.help, description = command.help,
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
help_embed.set_footer(text = random.choice(settings.quotes_short)) help_embed.set_footer(text = misc.get_embed_footer(ctx))
help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await self.get_destination().send(embed = help_embed) await self.get_destination().send(embed = help_embed)
@ -72,7 +74,7 @@ class AutoArchHelpCommand(commands.MinimalHelpCommand):
description = commands, description = commands,
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
help_embed.set_footer(text = random.choice(settings.quotes_short)) help_embed.set_footer(ttext = misc.get_embed_footer(ctx))
help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await self.get_destination().send(embed = help_embed) await self.get_destination().send(embed = help_embed)
@ -85,7 +87,7 @@ class AutoArchHelpCommand(commands.MinimalHelpCommand):
description = commands, description = commands,
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
help_embed.set_footer(text = random.choice(settings.quotes_short)) help_embed.set_footer(text = misc.get_embed_footer(ctx))
help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) help_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await self.get_destination().send(embed = help_embed) await self.get_destination().send(embed = help_embed)
@ -98,10 +100,34 @@ async def source(ctx):
colour = discord.Colour.gold() colour = discord.Colour.gold()
) )
source_embed.set_thumbnail(url = ctx.bot.user.avatar_url) source_embed.set_thumbnail(url = ctx.bot.user.avatar_url)
source_embed.set_footer(text = random.choice(settings.quotes_short)) source_embed.set_footer(text = misc.get_embed_footer(ctx))
source_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url) source_embed.set_author(name=str(ctx.author), icon_url=ctx.author.avatar_url)
await ctx.send(embed = source_embed) await ctx.send(embed = source_embed)
@bot.command(help = 'Shows information about the bot.')
async def info(ctx):
info_embed = discord.Embed(
title = 'Bot Info',
description = 'I\'m '+ctx.bot.user.mention+', and I was created by '+str(ctx.bot.appinfo.owner)+'.\nSee `'+ctx.bot.command_prefix+'help` for a list of commands.\nI can see `'+str(len(bot.guilds))+'` servers and have a latency of `'+str(int(bot.latency*1000))+'` ms.',
colour = discord.Colour.gold()
)
info_embed.set_thumbnail(url = ctx.bot.user.avatar_url)
info_embed.set_author(name = str(ctx.author), icon_url = ctx.author.avatar_url)
info_embed.set_footer(text = misc.get_embed_footer(ctx))
await ctx.send(embed = info_embed)
@bot.command(help = 'Shows the bot\'s latency.')
async def ping(ctx):
ping_embed = discord.Embed(
title = 'Pong!',
description = 'Bot latency: `'+str(int(ctx.bot.latency*1000))+' ms`',
colour = discord.Colour.gold()
)
ping_embed.set_thumbnail(url=ctx.bot.user.avatar_url)
ping_embed.set_author(name = str(ctx.author), icon_url = ctx.author.avatar_url)
ping_embed.set_footer(text = misc.get_embed_footer(ctx))
await ctx.send(embed=ping_embed)
bot.help_command = AutoArchHelpCommand() bot.help_command = AutoArchHelpCommand()
bot.run(settings.token) bot.run(settings.token)

10
misc.py Normal file
View File

@ -0,0 +1,10 @@
import discord
from discord.ext import commands
import settings
import random
def get_embed_footer(ctx):
footer = random.choice(settings.quotes_short)
if hasattr(ctx.bot, 'appinfo'):
footer += ' | Created by ' + str(ctx.bot.appinfo.owner)
return footer

View File

@ -1,22 +1,20 @@
token = 'Get your own' token = 'Get your own'
quotes = [
'"All we have to decide is what to do with the time that is given us."',
'"Fly, you fools!"',
'"So it begins, the great battle of our time..."',
'"Fool of a Took! Throw youself in next time and spare us"',
'Fun fact: The Rhorrhim were given the plains of Rohan by one of the early Stewards of Gondor, when they came to Gondor\'s aid.',
'Fun fact: Five wizards set out from the halls of the Valar, and we know the fates of three pretty well. But what happened to the two Blue Wizards during their journeys with Saruman? Tolkien left it a mystery...',
'"Yes, but what about second breakfast?" "I don\'t think he\'s heard of second breakfast, Pip."',
'"A wizard is never late, nor is he early; he arrives precisely when he means to."\n*Later, in Rivendell*\n"Sorry, Frodo, I was... delayed."'
]
quotes_short = [ quotes_short = [
'"For Frodo!"', '"For Frodo!"',
'"I would have followed you, my brother, my captain, my king!"', '"I would have followed you, my brother, my captain, my king!"',
'"Nine there were that set out from Rivendell, but only eight here stand."',
'Far over the misty mountains cold / To dungeons deep and caverns old',
'"I can\'t carry it for you, Mr. Frodo, but I can carry you!"', '"I can\'t carry it for you, Mr. Frodo, but I can carry you!"',
'"Fly, you fools!"', '"Fly, you fools!"',
'"Gondor calls for aid!" "And Rohan will answer!"' '"Gondor calls for aid!" "And Rohan shall answer!"',
'"The road goes ever on..."',
'"You shall not pass!"',
'"To Moria, to Khazad-dum..."',
'"It\'s over. Done."',
'"The eagles are coming!"',
'"Deeds will not be less valiant because they are unpraised."',
'"Bring wood and oil!"',
'"The Ring is mine!"',
'"It is a dangerous business, Frodo, going out your door."',
'"But what about second breakfast?"'
] ]
source = 'https://github.com/archfan7411/AutoArch' source = 'https://github.com/archfan7411/AutoArch'
license = 'MIT' license = 'MIT'