forked from jocadbz/os-release-bot
Compare commits
No commits in common. "cbcdc357df6f108eb6420657b3c9b9aba07eef16" and "7e88486f103811cb62944be5a35a38e359d0b35b" have entirely different histories.
cbcdc357df
...
7e88486f10
23
bot.py
23
bot.py
|
@ -40,7 +40,7 @@ async def on_ready():
|
||||||
print('------')
|
print('------')
|
||||||
|
|
||||||
|
|
||||||
@client.tree.command(name="join_role")
|
@client.tree.command(name="change_hostname")
|
||||||
@app_commands.describe(distro='Assign yourself a role')
|
@app_commands.describe(distro='Assign yourself a role')
|
||||||
async def distro(interaction: discord.Interaction, distro: eval("typing.Literal[\""+ "\", \"".join(config["roles"].keys()) +"\"]")):
|
async def distro(interaction: discord.Interaction, distro: eval("typing.Literal[\""+ "\", \"".join(config["roles"].keys()) +"\"]")):
|
||||||
if not interaction.guild.id==config["guild"]:
|
if not interaction.guild.id==config["guild"]:
|
||||||
|
@ -53,31 +53,12 @@ async def distro(interaction: discord.Interaction, distro: eval("typing.Literal[
|
||||||
try:
|
try:
|
||||||
await user.add_roles(role)
|
await user.add_roles(role)
|
||||||
await interaction.response.send_message(content=f'Added {role}.')
|
await interaction.response.send_message(content=f'Added {role}.')
|
||||||
print("Added role.")
|
prnt("Added role.")
|
||||||
except:
|
except:
|
||||||
await interaction.response.send_message(content='Something went wrong.')
|
await interaction.response.send_message(content='Something went wrong.')
|
||||||
print("Failed to add role. Permissions set correctly?")
|
print("Failed to add role. Permissions set correctly?")
|
||||||
|
|
||||||
|
|
||||||
@client.tree.command(name="leave_role")
|
|
||||||
@app_commands.describe(distro='Unassign yourself a role')
|
|
||||||
async def distro(interaction: discord.Interaction, distro: eval("typing.Literal[\""+ "\", \"".join(config["roles"].keys()) +"\"]")):
|
|
||||||
if not interaction.guild.id==config["guild"]:
|
|
||||||
print("Role assignment attempted from unknown guild.")
|
|
||||||
return
|
|
||||||
|
|
||||||
user = interaction.user
|
|
||||||
role = discord.utils.get(interaction.guild.roles, id=config["roles"][distro])
|
|
||||||
|
|
||||||
try:
|
|
||||||
await user.remove_roles(role)
|
|
||||||
await interaction.response.send_message(content=f'Left {role}.')
|
|
||||||
print("Removed role.")
|
|
||||||
except:
|
|
||||||
await interaction.response.send_message(content='Something went wrong.')
|
|
||||||
print("Failed to remove role. Permissions set correctly?")
|
|
||||||
|
|
||||||
|
|
||||||
# This context menu command only works on messages
|
# This context menu command only works on messages
|
||||||
@client.tree.context_menu(name='Report to Moderators')
|
@client.tree.context_menu(name='Report to Moderators')
|
||||||
async def report_message(interaction: discord.Interaction, message: discord.Message):
|
async def report_message(interaction: discord.Interaction, message: discord.Message):
|
||||||
|
|
Loading…
Reference in New Issue