๐Ÿค– ๋””์Šค์ฝ”๋“œ ๋ด‡ ๊ฐœ๋ฐœ์ผ์ง€ - 2

3254 ๋‹จ์–ด discorddiscord

๐Ÿ“š ๋ฉ”์„ธ์ง€ ์‚ญ์ œ, ์ธ์ฆ

๋ด‡์„ ํ†ตํ•ด์„œ ์ฑ„ํŒ…๋ฐฉ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์ง€์šธ ์ˆ˜ ์žˆ๋„๋ก ๋ฉ”์„ธ์ง€ ์‚ญ์ œ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด์ฃผ์—ˆ๋‹ค.

์ดˆ๋ฐ˜์—๋Š” ์ด๋Ÿฐ์‹์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์งฐ๋‹ค.

# ๊ถŒํ•œ์„ ํ†ตํ•ด ๋ฉ”์„ธ์ง€ ์‚ญ์ œ ๊ธฐ๋Šฅ
    if message.content.startswith ("!์ฒญ์†Œ"): # '!์ฒญ์†Œ'๋ฅผ ์ž…๋ ฅํ•œ๋‹ค๋ฉด
        if message.author.guild_permissions.administrator: # ์ž…๋ ฅํ•œ ์œ ์ €์˜ ๊ถŒํ•œ์„ ํ™•์ธํ•œ๋‹ค.
            amount = message.content[4:] # '!์ฒญ์†Œ ์ˆซ์ž' ์—์„œ ์ˆซ์ž๋ฅผ ์ธ์‹ํ•˜์—ฌ amount์˜ ๊ฐ’์„ ๋„ฃ๋Š”๋‹ค.
            await message.delete()
            await message.channel.purge(limit=int(amount))

        else: # ์ž…๋ ฅํ•œ ์œ ์ €๊ฐ€ ๊ถŒํ•œ์ด ์—†๋‹ค๋ฉด,
            await message.delete() # ์ž…๋ ฅํ•œ ์ฑ„ํŒ…์„ ์‚ญ์ œํ•˜๊ณ , 
            await message.channel.send("{}, ๋‹น์‹ ์€ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค".format(message.author.mention)) # ๋ฌธ์žฅ์„ ์ถœ๋ ฅํ•œ๋‹ค.

'!์ฒญ์†Œ ์ˆซ์ž' ๋ผ๊ณ  ์ž…๋ ฅ์„ ํ•ด์„œ ์ˆซ์ž๋ฅผ ์ธ์‹ํ•˜๋„๋ก ํ•˜๊ธฐ ์œ„ํ•ด์„œ startswith() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด์ค€๋‹ค.

startsWith() ํ•จ์ˆ˜๋Š” ๋Œ€์ƒ ๋ฌธ์ž์—ด์ด ํŠน์ • ๋ฌธ์ž ๋˜๋Š” ๋ฌธ์ž์—ด๋กœ ์‹œ์ž‘ํ•˜๋Š”์ง€ ์ฒดํฌํ•˜๋Š” ํ•จ์ˆ˜

์ด๋Ÿฐ์‹์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์งœ๋‹ˆ๊น '!์ฒญ์†Œ ์ˆซ์ž'๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ฉ”์„ธ์ง€๋ฅผ ์‚ญ์ œํ•˜๋Š” ๊ธฐ๋Šฅ๋งŒ์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋‚˜์ค‘์— ๋ช‡ ๊ฐœ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ์ง€์› ๋Š”์ง€ ํ™•์ธ์„ ํ•  ์ˆ˜ ์—†์–ด์„œ ๋ถˆํŽธํ•  ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ ์ž„๋ฒ ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ช‡ ๊ฐœ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ์‚ญ์ œํ–ˆ๋Š”์ง€ ๋ณด์—ฌ์ฃผ๊ฒŒ ์ˆ˜์ •ํ•ด์•ผ๊ฒ ๋‹ค๊ณ  ๋Š๊ผˆ๋‹ค.

์ž„๋ฒ ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์–ด๋–ค ์œ ์ €๊ฐ€ ๋ช‡ ๊ฐœ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ์ง€์› ๋Š”์ง€ ์ถœ๋ ฅํ•˜๋„๋ก ์ˆ˜์ •ํ–ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ํŠน์ • ๊ถŒํ•œ์ด ์žˆ๋Š” ์œ ์ €๊ฐ€ ๋‹ค๋ฅธ ์œ ์ €์—๊ฒŒ ์—ญํ• ์„ ์ค„ ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด์คฌ๋‹ค.

 # ์ธ์ฆ ๊ธฐ๋Šฅ
    if message.content.startswith ("!์ธ์ฆ"): # '!์ธ์ฆ'์„ ์ž…๋ ฅํ•œ๋‹ค๋ฉด
        if message.author.guild_permissions.administrator: # ์ž…๋ ฅํ•œ ์œ ์ €์˜ ๊ถŒํ•œ์„ ํ™•์ธํ•œ๋‹ค.
            await message.delete() # ์ž…๋ ฅํ•œ ์ฑ„ํŒ…์„ ์‚ญ์ œํ•œ๋‹ค.
            user = message.mentions[0] # '!์ธ์ฆ @์œ ์ €' ์—์„œ ์œ ์ €์ •๋ณด๋ฅผ user์— ๋‹ด๋Š”๋‹ค.

            # ๊ฐ€๋…์„ฑ์„ ์œ„ํ•œ ์ž„๋ฒ ๋“œ ์ถœ๋ ฅ
            embed = discord.Embed(title="๐Ÿ‘‹ ์ธ์ฆ ์‹œ์Šคํ…œ", description="์ธ์ฆ์ด ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค !",timestamp=datetime.datetime.now(pytz.timezone('UTC')), color=0x4c2896)
            embed.add_field(name="์ธ์ฆ ๋Œ€์ƒ์ž", value=f"{user.name} ( {user.mention} )", inline=False)
            embed.add_field(name="๋‹ด๋‹น ๊ด€๋ฆฌ์ž", value=f"{message.author} ( {message.author.mention} )", inline=False)
            embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/955360993729449987/955392404280737812/99pk9saw36t7q8t3o0gt.jpg")
            embed.set_footer(text="Bot Made by. ๊น€๋™๋ฏผ#0026, , ๋ฌธ์˜๋Š” DM์œผ๋กœ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ’ฌ")
            await message.author.send (embed=embed) # ์œ ์ € ๊ฐœ์ธ DM์œผ๋กœ ์ „์†กํ•œ๋‹ค. ์ฑ„ํŒ…๋ฐฉ์— ์ถœ๋ ฅ๋˜๋„๋ก ํ•˜๋ ค๋ฉด messae.channel.send ๋กœ ๋ฐ”๊พธ๋ฉด ๋œ๋‹ค.
            role = discord.utils.get(message.guild.roles, name = '์œ ์ € ๐Ÿ˜€')
            await user.add_roles(role)

        else: # ๊ถŒํ•œ์ด ์—†๋‹ค๋ฉด
            await message.delete() # ์ž…๋ ฅํ•œ ๋ฉ”์„ธ์ง€๋ฅผ ์‚ญ์ œํ•˜๊ณ ,
            await message.channel.send(embed=discord.Embed(title="๊ถŒํ•œ ๋ถ€์กฑ", description = message.author.mention + "๋‹˜์€ ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค", color = 0x4c2896)) # ํŠน์ • ๋ฌธ๊ตฌ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
            embed.set_footer(text="Bot Made by. ๊น€๋™๋ฏผ#0026, , ๋ฌธ์˜๋Š” DM์œผ๋กœ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค ๐Ÿ’ฌ")
            embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/955360993729449987/955392404280737812/99pk9saw36t7q8t3o0gt.jpg")

์ฒญ์†Œ ๊ธฐ๋Šฅ์—์„œ ์‚ฌ์šฉํ–ˆ๋˜ startswith() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ด์„œ '!์ธ์ฆ @์œ ์ €'์—์„œ @์œ ์ €์˜ ์ •๋ณด๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

๋‚˜๋Š” ์—ญํ• ์„ '์œ ์ € ๐Ÿ˜€' ๋กœ ์ค„ ์ˆ˜ ์žˆ๊ฒŒ ํ–ˆ๋‹ค.

์ •์ƒ์ ์œผ๋กœ '์œ ์ € ๐Ÿ˜€' ์—ญํ• ์„ ๋ฐ›์€ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

๊ธฐ๋Šฅ์ด ๋ช‡ ๊ฐœ ์—†์Œ์—๋„ ์ฝ”๋“œ๊ฐ€ 70์ค„ ์ด์ƒ์ด์—ฌ์„œ ์กฐ๋งŒ๊ฐ„์€ ๊ธฐ๋Šฅ์— ๋”ฐ๋ผ์„œ ํŒŒ์ผ์„ ๋ถ„ํ• ํ•ด์„œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์•ผ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ