Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
15 kB
1
Indexable
Never
import nextcord
from nextcord import SlashOption, TextInputStyle
import constants
import apis

TOKEN = "MTE1Njk1MjA3MjMyMzg2MjU5OA.GE_2lk.J-8lopKJmEO0NJXwipgaod5oIpPrtTanR0yFH0"

GuildID = 1153375186159153154  # Change this with your guild ID

intents = nextcord.Intents.default()
intents.members = True

bot = nextcord.Client(intents=intents)

channelIDs = {
    "logs" : 1155829751919943690,
    "discordlogs" : 1154155191529111572,
    "robloxlogs" : 1154157472957861969,
    "unbanLogs" : 1160546523176783902,
}

colors = {
    "main" : 0x00ff05, 
    "error" : 0xff0000, 
    "log" : 0xfff500  
}

roleIDs = { # Remember to change in the other bot too
    "staff" : [
        1082385525178122341,
        1154084440826458183,
        1154084439635267847,
        1154089898937167915,
        1154084438087565383,
        1154213666271539320,
        1154213625154785330,
        1154214353172701295
    ]
}

@bot.event
async def on_ready():
    print(f"{bot.user} is now online!")

class discordBanModal(nextcord.ui.Modal):
    def __init__(self):
        super().__init__(
            "Discord Ban.",
            timeout=5 * 60,
        )
        
        self.userid = nextcord.ui.TextInput(
            label="User ID",
            placeholder="Provide the user's ID.",
            required=True,
            min_length=1,
            max_length=100,
            style=TextInputStyle.short
        )
        
        self.reason = nextcord.ui.TextInput(
            label="Reason for ban",
            placeholder="Provide a detailed reason for the ban.",
            required=True,
            min_length=1,
            max_length=4000,
            style=TextInputStyle.paragraph
        )
        
        self.add_item(self.userid)
        self.add_item(self.reason)

    async def callback(self, interaction: nextcord.Interaction) -> None:
        await interaction.response.defer(ephemeral=True)
        guild = bot.get_guild(GuildID)
        user = await bot.fetch_user(int(self.userid.value))
        print(self.userid.value)
        if user:
            await guild.ban(user=user, reason=self.reason.value)
            
            embed = nextcord.Embed(title="User banned", description=f"""
User: <@{user.id}>  
Reason: {self.reason.value}
Moderator:" <@{interaction.user.id}>               
""")        
            logsChannel = guild.get_channel(channelIDs['discordlogs'])
            await logsChannel.send(embed=embed)           
            await interaction.followup.send(embed=embed, ephemeral=True)
        else:
            embed = nextcord.Embed(title="Invalid User ID", description="Please make sure that your user ID is valid and try again.", color=colors['error'])
            await interaction.followup.send(embed=embed, ephemeral=True)

class messageModal(nextcord.ui.Modal):
    def __init__(self,channel):
        self.channel = channel

        super().__init__(
            "Message.",
            timeout=5 * 60,
        )
        self.message = nextcord.ui.TextInput(
            label="Message",
            placeholder="Provide the message you want to send.",
            required=True,
            min_length=1,
            max_length=4000,
            style=TextInputStyle.paragraph
        )

        self.add_item(self.message)

    async def callback(self, interaction: nextcord.Interaction) -> None:
        embed = nextcord.Embed(title="Announcement", description=self.message.value)
        await self.channel.send(embed=embed)
        await interaction.response.send_message(content="Announcment Sent", ephemeral=True)
        


@bot.slash_command(guild_ids=[GuildID], description="Announce a message")
async def announce(interaction: nextcord.Interaction, channel: nextcord.TextChannel):
    hasRole = False
    for item in interaction.user.roles:     
        if item.id in roleIDs['staff']:
            hasRole = True
            break
    if hasRole:
        await interaction.response.send_modal(modal=messageModal(channel))


class robloxBanModal(nextcord.ui.Modal):
    def __init__(self):
        super().__init__(
            "Roblox Ban.",
            timeout=5 * 60,
        )
        
        self.username = nextcord.ui.TextInput(
            label="Username",
            placeholder="Provide the user's username.",
            required=True,
            min_length=1,
            max_length=100,
            style=TextInputStyle.short
        )
        
        self.reason = nextcord.ui.TextInput(
            label="Reason for ban",
            placeholder="Provide a detailed reason for the ban.",
            required=True,
            min_length=1,
            max_length=4000,
            style=TextInputStyle.paragraph
        )
        
        self.add_item(self.username)
        self.add_item(self.reason)

    async def callback(self, interaction: nextcord.Interaction) -> None:
        username = self.username.value
        reason = self.reason.value
        userID = apis.getID(username)
        if userID:
            await interaction.response.defer()
            avatar = apis.avatar(userID)
            userBanned = apis.isUserBanned(userID)
            if userBanned:
                embed = nextcord.Embed(title="User is already banned",
                                       description="That user is already banned.", color=colors['error'])
                await interaction.followup.send(embed=embed)
            else:
                apis.insert(apis.BannedDatastoreName, userID, reason)
                embed = nextcord.Embed(
                    title="User banned", description=f"""
User Banned: {username} 
Reason: {reason}
Banned By: <@{interaction.user.id}>
""", color=colors['main'])
                embed.set_thumbnail(url=avatar)
                apis.kick(userID, "You have been banned from the server.")
                await interaction.followup.send(embed=embed)
                
                guild = bot.get_guild(GuildID)
                logsChannel = guild.get_channel(channelIDs['robloxlogs'])
                
                await logsChannel.send(embed=embed)
        else:
            embed = nextcord.Embed(title="User not found",
                                   description="That user does not exist.", color=colors['error'])
            await interaction.response.send_message(embed=embed)

        

@bot.slash_command(guild_ids=[GuildID], description="Ban someone from the Discord Server ")
async def ban(interaction: nextcord.Interaction, bantype: str = SlashOption(
    name="platform",
    description="Choose the type of ban that you want",
    choices=["Roblox", "Discord"],
    required=True
),
serverrule: str = SlashOption(
    name="serverrule",
    description="What Server Rule did the user break",
    choices=[
"SR-1. You may not spam in any of our server channels.",

"SR-2. You may not bypass the Ro Arenas automatic chat filter.",

"SR-3. You may not spam mention any member within Ro Arenas. ",

"SR-4. Harassment or participating in the harassment of Ro Arenas members is strongly prohibited.",

"SR-5. You may not leak or endorse the leaking of any member within Ro Arenas without their consent.",

"SR-6. Adult content of all kinds and sorts is heavily banned from Ro Arenas.",

"SR-7. Participating in hate speech or endorsing it is heavily barred from Ro Arenas.",

"SR-8. Doxxing/hacking/scamming or participating in any of these actions.",

"SR-9. Sexualizing minors under any context is not allowed.",

"SR-10. You must be atleast 13 years of age to join our discord community.",

"SR-11. You may not ban evade."],    
    required=False
),
gamerule: str = SlashOption(
    name="gamerule",
    description="What Game Rule did the user break",
    choices=[
"GR-1. Exploiting is completely forbidden.",

"GR-2. You may not farm your stats through your friends or an alternative account.",

"GR-3. Glitching on purpose to your advantage is prohibited.",

"GR-4. Do not harass players in game. We do expect a bearable amount of toxicity from our community.",

"GR-5. Participating in DDoS attacks or endorsing them against Ro Arenas or any other Roblox game.",

"GR-6. Do not evade your ban.",

"GR-7. Do not slow down your internet on purpose.",

"GR-8. Framing a user under any circumstance to harass them or get them banned."],
    required=False
),
reason: str = SlashOption(
    name="reason",
    description="Provide the reason for the ban",
    choices = [
        "Some Reason"
    ], required=True,
    
)
):
    
    hasRole = False
    for item in interaction.user.roles:     
        if item.id in roleIDs['staff']:
            hasRole = True
            break
    if hasRole:
        if bantype == "Roblox" and gamerule: 
            await interaction.response.send_modal(modal=robloxBanModal())
        elif bantype == "Discord" and serverrule:
            await interaction.response.send_modal(modal=discordBanModal())
        elif gamerule or serverrule:
            embed = nextcord.Embed(title="Incorrect Paramaters", description=f"You did not input the correct rule with the ban type.", color=colors['error'])
            await interaction.response.send_message(embed=embed, ephemeral=True)
        else:
            embed = nextcord.Embed(title="Incorrect Paramaters", description=f"You did not input the a rule with the ban type.", color=colors['error'])
            await interaction.response.send_message(embed=embed, ephemeral=True)
    else:
        embed = nextcord.Embed(title="Permission denied", description=f"You do not have the correct role to run this command.", color=colors['error'])
        await interaction.response.send_message(embed=embed, ephemeral=True)  
        
@bot.slash_command(guild_ids=[GuildID], description="Kick someone from the Discord server ")
async def kick(interaction: nextcord.Interaction, user: nextcord.Member, reason: str):
    hasRole = False
    for item in interaction.user.roles:     
        if item.id in roleIDs['staff']:
            hasRole = True
            break
    if hasRole:      
        guild = bot.get_guild(GuildID)
        logsChannel = guild.get_channel(channelIDs['discordlogs'])
        
        embed = nextcord.Embed(title="User Kicked", description=f"""
User Kicked: <@{user.id}> 
Reason: {reason}
Kicked By: <@{interaction.user.id}>
""", color=colors['log'])
        await logsChannel.send(embed=embed)
        await user.kick(reason=reason)
    else:
        embed = nextcord.Embed(title="Permission denied", description=f"You do not have the correct role to run this command.", color=colors['error'])
        await interaction.response.send_message(embed=embed, ephemeral=True)
        
@bot.slash_command(guild_ids=[GuildID], description="Unban someone from the Roblox game ")
async def unban(interaction: nextcord.Interaction, username: str):
    hasRole = False
    for item in interaction.user.roles:     
        if item.id in roleIDs['staff']:
            hasRole = True
            break
    if hasRole:
        userID = apis.getID(username)
        if userID:
            apis.delete(constants.BannedDatastoreName, userID)
            
            guild = bot.get_guild(GuildID)
            logsChannel = guild.get_channel(channelIDs['unbanLogs'])
            
            embed = nextcord.Embed(title="Sucessful Unban", description=f"{username} has been sucessfully unbanned", color=colors['main'])
            await interaction.response.send_message(embed=embed)
            
            embed = nextcord.Embed(title="User Unbanned", description=f"""
User: {username}
Moderator: <@{interaction.user.id}>""", color=colors['log'])
            avatar = apis.avatar(userID)
            embed.set_thumbnail(url=avatar)
            await logsChannel.send(embed=embed)
        else:
            embed = nextcord.Embed(title="User not found",
                        description="That user does not exist.", color=colors['error'])
            await interaction.response.send_message(embed=embed)
    else:
        embed = nextcord.Embed(title="Permission denied", description=f"You do not have the correct role to run this command.", color=colors['error'])
        await interaction.response.send_message(embed=embed, ephemeral=True)
   

@bot.slash_command(guild_ids=[GuildID], description="Kick someone from the Roblox game ")
async def gamekick(interaction: nextcord.Interaction, username: str, reason: str):
    hasRole = False
    for item in interaction.user.roles:     
        if item.id in roleIDs['staff']:
            hasRole = True
            break
    if hasRole:        
        userID = apis.getID(username)
        if userID:
            apis.kick(userID, reason)
            
            guild = bot.get_guild(GuildID)
            logsChannel = guild.get_channel(channelIDs['robloxlogs'])
            
            embed = nextcord.Embed(title="User Kicked", description=f"{username} has been kicked by <@{interaction.user.id}>", color=colors['log'])
            await logsChannel.send(embed=embed)
        else:
            embed = nextcord.Embed(title="User not found",
                        description="That user does not exist.", color=colors['error'])
            await interaction.response.send_message(embed=embed)
    else:
        embed = nextcord.Embed(title="Permission denied", description=f"You do not have the correct role to run this command.", color=colors['error'])
        await interaction.response.send_message(embed=embed, ephemeral=True)
            
@bot.slash_command(guild_ids=[GuildID], description="Update your roles")
async def update(interaction: nextcord.Interaction):
    username = interaction.user.nick
    userID = apis.getID(username)
    if userID:
        if apis.isGroupMember(userID):
            rank = apis.getGroupRank(userID)
            roleID = constants.rankIDToRoleID[rank['rank']]
            guild = bot.get_guild(GuildID)
            role = guild.get_role(roleID)
            await interaction.user.add_roles(role)
            embed = nextcord.Embed(title="Update Sucessful!", description=f"Your role has been updated sucessfully to {rank['name']}", color=colors['main'])
            await interaction.response.send_message(embed=embed)
        else:
            embed = nextcord.Embed(title="User Not In Group", description="You aren't in the group.", color=colors['error'])
            await interaction.response.send_message(embed=embed)
        
    else:
        embed = nextcord.Embed(title="User Not Found", description="Your nickname is not a valid username", color=colors['error'])
        await interaction.response.send_messsage(embed=embed)

bot.run(TOKEN)