os-release-bot/bot.py

199 lines
9.2 KiB
Python
Raw Normal View History

2023-01-12 18:12:58 +01:00
# Code written by Jocadbz(madureirajoaquim95@gmail.com)
# Code revised by BodgeMaster
# Code Licensed under GPL 3.0
import discord
from discord import app_commands
import typing
from discord.ext import commands
import discord.utils
import time
2023-01-13 17:47:58 +01:00
import sys
2023-01-12 18:12:58 +01:00
2023-01-13 17:47:23 +01:00
BOOT_TIME = time.time()
2023-01-12 18:12:58 +01:00
def seconds_elapsed():
2023-01-13 17:47:23 +01:00
return time.time() - BOOT_TIME
2023-01-12 18:12:58 +01:00
class MyClient(discord.Client):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
await self.tree.sync()
intents = discord.Intents.default()
client = MyClient(intents=intents)
bot = commands.Bot(command_prefix='lb!', intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
@client.tree.command(guild=discord.Object(id=813127962881818624), name="change_hostname")
2023-01-12 18:12:58 +01:00
@app_commands.describe(distro='Assign yourself a role')
async def distro(interaction: discord.Interaction, distro: typing.Literal['LFS', 'Kiss', 'Gentoo', 'Void', 'NixOS', 'Alpine', 'Arch', 'Arch-based', 'Red Hat', 'Bedrock', 'SuSE Based', 'OpenSuSE',
'Debian', 'Debian based', 'Solus', 'Fedora', 'Ubuntu', 'Ubuntu Based', 'BSD', 'MacOS', 'Windows']):
user = interaction.user
if distro == 'LFS':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813200239778856971)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Kiss':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=884819839212982342)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Gentoo':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=1813139495049232384)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Void':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813139633797988394)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'NixOS':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=827228988585279538)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Alpine':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=932684264967925850)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Arch':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813139868678225991)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Arch-based':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813186782534828043)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Red Hat':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=816823482318979094)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Bedrock':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=825427559604027412)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'SuSE Based':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=1034793985715224587)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'OpenSuSE':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813147179367661589)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Debian':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813142935247388672)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Debian based':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=842882283504926756)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Solus':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=820840553704325160)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Fedora':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=820621219040591884)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Ubuntu':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813139746180038697)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Ubuntu Based':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813581408052183042)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'BSD':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=879444277330055228)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'MacOS':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813147204772167680)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
if distro == 'Windows':
user = interaction.user
role = discord.utils.get(user.guild.roles, id=813147019631788083)
await user.add_roles(role)
await interaction.response.send_message(content=f'`{role}` assigned to {user.mention}.')
print(f"`{role}` assigned to {user.mention}.")
# This context menu command only works on messages
@client.tree.context_menu(guild=discord.Object(id=813127962881818624), name='Report to Moderators')
2023-01-12 18:12:58 +01:00
async def report_message(interaction: discord.Interaction, message: discord.Message):
await interaction.response.send_message(
f'Thanks for reporting this message by {message.author.mention} to our moderators.', ephemeral=True
)
log_channel = interaction.guild.get_channel(929345959501115422) # replace with your channel id
embed = discord.Embed(title='Reported Message')
if message.content:
embed.description = message.content
embed.set_author(name=message.author.display_name, icon_url=message.author.display_avatar.url)
embed.timestamp = message.created_at
url_view = discord.ui.View()
url_view.add_item(discord.ui.Button(label='Go to Message', style=discord.ButtonStyle.url, url=message.jump_url))
await log_channel.send(embed=embed, view=url_view)
@client.tree.command(name="status")
async def status(interaction: discord.Interaction):
embed = discord.Embed(title='System Stats')
embed.description = f"""Uptime: {seconds_elapsed()}
2023-01-13 17:47:58 +01:00
System: {sys.platform}"""
2023-01-12 18:12:58 +01:00
url_view = discord.ui.View()
await interaction.response.send_message(embed=embed, view=url_view)
2023-01-13 17:47:58 +01:00
client.run(sys.argv[1])