Skip to content
This repository has been archived by the owner on May 15, 2022. It is now read-only.

Commit

Permalink
yoink
Browse files Browse the repository at this point in the history
Add lots. yey
  • Loading branch information
MrRazamataz committed Oct 28, 2021
1 parent 211f5f9 commit d740509
Show file tree
Hide file tree
Showing 31 changed files with 1,408 additions and 1,552 deletions.
Empty file added bug_data.txt
Empty file.
24 changes: 0 additions & 24 deletions cogs/_kcwelcome.py

This file was deleted.

636 changes: 0 additions & 636 deletions cogs/_main.py

This file was deleted.

80 changes: 78 additions & 2 deletions cogs/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import asyncio
import aiofiles
import datetime
from datetime import datetime
from discord_slash import cog_ext, SlashContext
from time import time, ctime
class automod(commands.Cog):
def __init__(self, client):
self.client = client
Expand All @@ -15,6 +18,40 @@ async def automod(self, ctx):
if ctx.invoked_subcommand is None:
await ctx.send("RazBot AutoMod aims to protect and keep your server clean with ease. \nTo enable it simply run the command: \n`raz!automod on`")

@cog_ext.cog_subcommand(description="AutoMod Information", base_description="AutoMod settings and info", base="automod", name="info")
async def automod_slash_info(self, ctx):
await ctx.send("RazBot AutoMod aims to protect and keep your server clean with ease. \nTo enable it simply run the command: \n`/automod on`")

@cog_ext.cog_subcommand(description="AutoMod on", base="automod", name="on")
async def automod_slash_on(self, ctx):
if self.check_if_string_in_file('automod.txt', f"{ctx.guild.id}\n"):
await ctx.channel.send(
"AutoMod is already enabled in this discord server! You can disable it with: \n`/automod off`")
else:
async with aiofiles.open("automod.txt", mode="a") as file:
await file.write(f"{ctx.guild.id}\n")
await file.close()
await ctx.send("AutoMod has been enabled on this discord server!")
with open("automod.txt", "r") as file:
global discordserverids
discordserverids = file.read().splitlines()
print(discordserverids)
@cog_ext.cog_subcommand(description="AutoMod off", base="automod", name="off")
async def automod_slash_off(self, ctx):
if self.check_if_string_in_file('automod.txt', f"{ctx.guild.id}\n"):
with open("automod.txt", "r") as f:
lines = f.readlines()
with open("automod.txt", "w") as f:
for line in lines:
if line.strip("\n") != f"{ctx.guild.id}":
f.write(line)
await ctx.send("AutoMod has been disabled on this server!")
with open("automod.txt", "r") as file:
global discordserverids
discordserverids = file.read().splitlines()
print(discordserverids)
else:
await ctx.send("AutoMod isn't enabled on this server, you can enable it with: \n`/automod on`")
@automod.command()
@commands.has_permissions(ban_members=True)
async def on(self, ctx):
Expand Down Expand Up @@ -106,6 +143,7 @@ async def on_ready(self):
global banned_words
banned_words = file.read().splitlines()
print(banned_words)
self.client.removing_channels = {}
@commands.Cog.listener()
async def on_message(self, message):
if message.guild is None:
Expand All @@ -130,7 +168,7 @@ async def on_message(self, message):
for word in banned_words:
if not message.author.bot:
if guildid in discordserverids:
if word in message.content:
if word in message.content.lower():
await message.delete()
await message.channel.send(f"Hey <@{message.author.id}>, please refrain from using banned/NSFW words.")
guild = message.guild
Expand All @@ -155,7 +193,7 @@ async def on_message_edit(self, message_before, message_after):
for word in banned_words:
if not message_after.author.bot:
if guildid in discordserverids:
if word in message_after.content:
if word in message_after.content.lower():
await message_after.delete()
await message_after.channel.send(f"Hey <@{message_after.author.id}>, please refrain from using banned/NSFW words. \nTrying to be smart by edting your messages doesn't bypass me, mate.")
guild = message_after.guild
Expand All @@ -173,6 +211,44 @@ async def on_message_edit(self, message_before, message_after):
embed.add_field(name="Action:", value="Message has been deleted.",
inline=True)
await log_channel.send(embed=embed)

@commands.Cog.listener()
async def on_guild_channel_delete(self, channel):
guild = channel.guild
async for event in guild.audit_logs(action=discord.AuditLogAction.channel_delete,
limit=3): # get last 3 incase someone delete at exact time?
if event.user is not self.client.user:
if event.target.id == channel.id:
try:
amount, last = self.client.removing_channels[event.user.id]
if time() - last < 5: # 5 seconds between each creation will be flagged
amount += 1
last = time()

if amount >= 3:
await event.user.ban(reason="For deleting 3 or more channels at once.")
guild = event.guild
log_channel = discord.utils.get(guild.channels, name="razbot-logs")
if log_channel is None:
return
else:
await log_channel.send(f"Successfully banned {event.user.name} for deleting more than 3 channels at once.")
return

else: # otherwise reset the time
amount = 1
last = 0

self.client.removing_channels[event.user.id] = (amount, last)

except KeyError:
self.client.removing_channels[event.user.id] = (1, time())

except Exception as error:
print(guild.id, f"failed at {error} whilst calculating channel deletion amounts.")

finally:
break
def check_if_string_in_file(self, file_name, string_to_search): # string checker
""" Check if any line in the file contains given string """
# Open the file in read only mode
Expand Down
8 changes: 4 additions & 4 deletions cogs/ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def __init__(self, client):

@commands.command(name="ban")
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, arg1, reason=None):
async def ban(self, ctx, member: discord.Member, *, reason=None):
if member.top_role >= ctx.author.top_role:
await ctx.send("This command failed due to role hierarchy! You are below the target user in this ~~pyramid scheme~~ discord server.")
return
else:
await member.send(f"You have been banned from `{member.guild.name}`. Ban reason: `{arg1}`")
await member.ban(reason=arg1)
await ctx.send(f"{member.name} has been banned by `{ctx.author.name}`, with the reason `{arg1}`!")
await member.send(f"You have been banned from `{member.guild.name}`. Ban reason: `{reason}`")
await member.ban(reason=reason)
await ctx.send(f"{member.name} has been banned by `{ctx.author.name}`, with the reason `{reason}`!")
await ctx.message.add_reaction("👍")
await asyncio.sleep(2)
await ctx.message.remove_reaction("👍", ctx.guild.me)
Expand Down
2 changes: 1 addition & 1 deletion cogs/british.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, client):
async def british(self, ctx):
async with ctx.channel.typing():
async with aiohttp.ClientSession() as cs:
async with cs.get('https://www.reddit.com/r/uwotm8/random/.json') as r:
async with cs.get('https://old.reddit.com/r/uwotm8/random/.json') as r:
res = await r.json()

image= res[0]['data']['children'][0]['data']['url']
Expand Down
10 changes: 4 additions & 6 deletions cogs/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ def __init__(self, client):
self.client = client

@commands.command(name="clear")
@commands.has_permissions(manage_messages=True)
async def clear(self, ctx, amount: int = None):
if ctx.author.guild_permissions.administrator:
if amount is None:
await ctx.send("Please specify the amount of messages to delete in this command.")
else:
await ctx.channel.purge(limit=amount + 1)
if amount is None:
await ctx.send("Please specify the amount of messages to delete in this command.")
else:
await ctx.send("Hey! Sorry but you don't have perms for that command. Duh-Doy!")
await ctx.channel.purge(limit=amount + 1)

@clear.error
async def clear_error(self, ctx, error):
Expand Down
96 changes: 87 additions & 9 deletions cogs/cmds.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,98 @@
#MrRazamataz's RazBot
#Help test command

import random
# MrRazamataz's RazBot
# cmds command
import discord
from discord import reaction
from discord.ext import commands
from discord import reaction
import asyncio
import os

import aiofiles
# help pages
page1 = discord.Embed(title="RazBot Help Page 1", description="Use the buttons below to navigate between help pages. If there are no buttons, its because there was no input for 60 seconds, and was timed out. Run the `raz!help` command again to bring up another menu.", colour=discord.Colour.orange())
page2 = discord.Embed(title="RazBot Help Page 2", description="Commands:", colour=discord.Colour.orange())
page2.set_thumbnail(url="https://www.mrrazamataz.ga/archive/RazBot.png")
page2.add_field(name="Moderation:", value="\u200b", inline=False)
page2.add_field(name="Ban:", value="`raz!ban [user-ping] [reason]`, bans the specified user from the server.", inline=True)
page2.add_field(name="Unban: ", value="`raz!unban [user]`, unbans the specified user from the server.", inline=True)
page2.add_field(name="Mute: ", value="`raz!mute [user-ping]`, adds the muted role to the user.", inline=True)
page2.add_field(name="Unmute: ", value="`raz!unmute [user-ping]`, removes the muted role fron the user.", inline=True)
page2.add_field(name="Temp Mute:", value="`raz!tempmute [user-ping] [Number] [s/m/h/d]`, tempmute the user for the amount of time specified. **Note: The space (` `) between `[Number]` and `[s/m/h/d]` is required.**", inline=True)
page2.add_field(name="Kick:", value="`raz!kick [user-ping]`, kicks the specified user from the server.", inline=True)
page2.add_field(name="Clear:", value="`raz!clear [number]`, clears the specified amount of messages.", inline=True)
page2.add_field(name="Lockdown:", value="`raz!lockdown`, locks down the channel for non admins/staff.", inline=True)
page2.add_field(name="Unlock:", value="`raz!unlock`, unlockdowns the channel after a `raz!lockdown`.", inline=True)
page2.add_field(name="Say:", value="`raz!say [message]`, make the bot repeat the message.", inline=True)
page2.add_field(name="Warn: ", value="`raz!warn [user-ping] [reason]`, add a warning to the user in that server.", inline=True)
page2.add_field(name="View Warnings:", value="`raz!warnings [user-ping]`. view the warnings of the user for that server.", inline=True)
page2.add_field(name="Slowmode:", value="`raz!slowmode <seconds>`, puts the channel in slowmode for the specified amount, set to 0 to disable slowmode.", inline=False)
page2.add_field(name="Useful Commands:", value="\u200b", inline=True)
page2.add_field(name="Add Reaction Role:", value="`raz!reactionrole [RoleName] [MessageID] [Emoji]`, adds a reaction which users can react to to give themselves the specifed role (works multiple times on the same message with differnet reactions).", inline=True)
page2.add_field(name="Add Role:", value="`raz!add_role @usermention [role name]`, gives the user the role specifed. ", inline=True)
page2.add_field(name="Suggest:", value="`raz!suggest <text>`, like vote, but for normal users (only adds reactions).", inline=True)
page2.add_field(name="Vote:", value="`raz!vote <text>`, adds vote reactions and explanation. ", inline=True)
page2.add_field(name="Version:", value="`raz!ver`, shows the version of the bot.", inline=True)
page2.add_field(name="Lucky (Giveaway):", value="`raz!lucky`, adds a reaction and after 24hours, picks a random person from the reactions.", inline=True)
page3 = discord.Embed(title="RazBot Help Page 3", description="Music commands:", colour=discord.Colour.orange())
page3.add_field(name="\u200b", value="`raz!p <song name or YouTube song/playlist URL>`, plays the song/playlist.", inline=True)
page3.add_field(name="\u200b", value="`raz!pause` then `raz!p` to unpause.", inline=True)
page3.add_field(name="\u200b", value="`raz!skip`, skip to the next track in queue.", inline=True)
page3.add_field(name="\u200b", value="`raz!back`, go back to the last song in queue.", inline=True)
page3.add_field(name="\u200b", value="`raz!q`, shows the queue.", inline=True)
page3.add_field(name="\u200b", value="`raz!np`, shows info about the currently playing song.", inline=True)
page3.add_field(name="\u200b", value="`raz!shuffle`, shuffles the queue order.", inline=True)
page3.add_field(name="\u200b", value="`raz!vol`, change the volume from 0-150%.", inline=True)
page3.add_field(name="\u200b", value="`raz!replay`, replay the song.", inline=True)
page3.add_field(name="\u200b", value="`raz!jump`, jump to a specific timestamp in the song.", inline=True)
page3.add_field(name="\u200b", value="`raz!stop`, stop the playing track and clear queue.", inline=True)
page3.add_field(name="\u200b", value="`raz!loop`, loop the current queue.", inline=True)
page3.add_field(name="\u200b", value="`raz!lyrics`, attempt to find the lyrics to the playing song.", inline=True)
page3.add_field(name="\u200b", value="`raz!skipto`, skips to a song value that's in the queue.", inline=True)
timeoutpage = discord.Embed(title="RazBot Help Page Timeout", description="This helppage has timed out after no input, please run `raz!cmds` again if you want to use it again", colour=discord.Colour.red())
class cmds(commands.Cog):
def __init__(self, client):
self.client = client

client.help_pages = [page1, page2, page3]
@commands.command(name="cmds")
async def command_help(self, ctx: commands.Context):
await ctx.channel.send("For commands, look on the second page of `raz!help`.")
async def cmds(self, ctx: commands.Context):
try:
buttons = [u"\u23EA", u"\u2B05", u"\u27A1", u"\u23E9"] # skip to start, left, right, skip to end
current = 0
msg = await ctx.send(embed=self.client.help_pages[current])

for button in buttons:
await msg.add_reaction(button)

while True:
try:
reaction, user = await self.client.wait_for("reaction_add", check=lambda reaction, user: user == ctx.author and reaction.emoji in buttons,timeout=60.0)

except asyncio.TimeoutError:
await msg.clear_reactions()
return print("Cmds page timeout!")

else:
previous_page = current
if reaction.emoji == u"\u23EA":
current = 0

elif reaction.emoji == u"\u2B05":
if current > 0:
current -= 1

elif reaction.emoji == u"\u27A1":
if current < len(self.client.help_pages) - 1:
current += 1

elif reaction.emoji == u"\u23E9":
current = len(self.client.help_pages) - 1

for button in buttons:
await msg.remove_reaction(button, ctx.author)

if current != previous_page:
await msg.edit(embed=self.client.help_pages[current])
except Exception as e:
await ctx.send("Hey! I don't currently have permissions to remove reactions and the like, which I *do* need to work correctly, so if you could give me those permissions, that would be lovelaay.")
print(e)
def setup(client):
client.add_cog(cmds(client))
client.add_cog(cmds(client))
83 changes: 83 additions & 0 deletions cogs/customcommands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# MrRazamataz's RazBot
# Custom commands manager
import discord
from discord import reaction
from discord.ext import commands
import asyncio
import os
import aiofiles
import json



class customcommands(commands.Cog):
def __init__(self, client):
self.client = client

@commands.group(name="cc")
async def cc(self, ctx):
if ctx.invoked_subcommand is None:
await ctx.send("You can `create` or `del`.")

@cc.command()
@commands.has_permissions(manage_guild=True)
async def create(self, ctx, name, *, text):
global cc
save = {
"text": f"{text}"
}
with open('customcommands.json', 'r+') as f:
data = json.load(f)
f.seek(0)
f.truncate(0)
data[f'{ctx.guild.id}-{name.lower()}'] = {"text": f"{text}"}
json.dump(data, f, indent=4)
await ctx.send(f"Added custom command with `{name.lower()}` which contains `{text}`.")
with open("customcommands.json") as f:
cc = json.load(f)
@cc.command(name="delete", aliases=["remove", "del"])
@commands.has_permissions(manage_guild=True)
async def delete(self, ctx, name):
global cc
check = f"{ctx.guild.id}-{name.lower()}"
with open('customcommands.json', 'r+') as f:
data = json.load(f)
try:
data.pop(f"{check}")
except Exception as e:
await ctx.send(f"`{name.lower()}` was not found in the server's custom commands.")
return
f.seek(0)
f.truncate(0)
json.dump(data, f, indent=4)
with open("customcommands.json") as f:
cc = json.load(f)
await ctx.send(f"Deleted `{name}`.")
@cc.command()
async def reload(self, ctx):
global cc
with open("customcommands.json") as f:
cc = json.load(f)
await ctx.send("Reloaded custom commands.")
@commands.Cog.listener()
async def on_ready(self):
print("Loading custom commands...")
global cc
with open("customcommands.json") as f:
cc = json.load(f)

@commands.Cog.listener()
async def on_message(self, message):
global cc
if message.guild is None:
return
guildid = str(message.guild.id)
check = f"{guildid}-{message.content.lower()}"
try:
if check in cc:
await message.channel.send(f'{cc[f"{check}"]["text"]}')
#await message.channel.send(f'{cc[f"{check}"]}')
except Exception as e:
print(e)
def setup(client):
client.add_cog(customcommands(client))
Loading

0 comments on commit d740509

Please sign in to comment.