<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hazrat Ummar Shaikh</title>
    <description>The latest articles on Forem by Hazrat Ummar Shaikh (@ihazratummar).</description>
    <link>https://forem.com/ihazratummar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1537142%2Fb9d026bd-8dd6-4a3a-b8ed-093c5c736062.jpeg</url>
      <title>Forem: Hazrat Ummar Shaikh</title>
      <link>https://forem.com/ihazratummar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ihazratummar"/>
    <language>en</language>
    <item>
      <title>Need help with App language | Android Compose</title>
      <dc:creator>Hazrat Ummar Shaikh</dc:creator>
      <pubDate>Sat, 10 Aug 2024 06:11:02 +0000</pubDate>
      <link>https://forem.com/ihazratummar/need-help-with-app-language-android-compose-22ni</link>
      <guid>https://forem.com/ihazratummar/need-help-with-app-language-android-compose-22ni</guid>
      <description>&lt;p&gt;This code working fine for android 13 and later but not for below android 13&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fun changeLanguage(context: Context, language: Languages) {
    val languageString = when (language) {
        Languages.ENGLISH -&amp;gt; "en"
        Languages.BENGALI -&amp;gt; "bn"
    }
    if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.TIRAMISU) {
        // Use LocaleManager for Android 13 and later
        val localManager = context.getSystemService(LocaleManager::class.java)
        localManager?.applicationLocales = LocaleList.forLanguageTags(languageString)
    } else {
        AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(languageString))
    }
}

enum class Languages {
    ENGLISH,
    BENGALI
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>android</category>
      <category>kotlin</category>
      <category>jetpackcompose</category>
      <category>androidkotlin</category>
    </item>
    <item>
      <title>Discord.py commands for cat image with breed information</title>
      <dc:creator>Hazrat Ummar Shaikh</dc:creator>
      <pubDate>Sun, 02 Jun 2024 17:00:42 +0000</pubDate>
      <link>https://forem.com/ihazratummar/discordpy-commands-for-cat-image-with-breed-information-46p1</link>
      <guid>https://forem.com/ihazratummar/discordpy-commands-for-cat-image-with-breed-information-46p1</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@commands.hybrid_command(name="cat", description = "Get a random cat image with description")
    @commands.cooldown(4, 20, commands.BucketType.guild)
    async def cat(self, ctx: commands.Context, user: discord.Member = None):
        api_key = os.getenv("CAT_API_KEY")
        url = "https://api.thecatapi.com/v1/images/search?has_breeds=1"
        reponse = requests.get(url, headers={'x-api-key': f"{api_key}"})

        data = reponse.json()

        breed = [breed['breeds'] for breed in data]
        image = [image['url'] for image in data]
        cat = breed[0][0]
        cat_name = cat['name']
        cat_description = cat['description']
        cat_temperament = cat['temperament']

        embed=discord.Embed(title=f"{cat_name}", description=f"&amp;gt;&amp;gt;&amp;gt; {cat_description}", color=0x00FFFF)
        embed.add_field(name="Temperament", value=f"&amp;gt;&amp;gt;&amp;gt; {cat_temperament}", inline=False)
        embed.set_image(url=f"{image[0]}")

        if user:
            await ctx.send(user.mention,embed=embed)
        else:
            await ctx.send(embed=embed)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discord</category>
      <category>python</category>
    </item>
    <item>
      <title>Discord help commands in discord.py</title>
      <dc:creator>Hazrat Ummar Shaikh</dc:creator>
      <pubDate>Sat, 01 Jun 2024 12:22:00 +0000</pubDate>
      <link>https://forem.com/ihazratummar/discord-help-commands-in-discordpy-4mg5</link>
      <guid>https://forem.com/ihazratummar/discord-help-commands-in-discordpy-4mg5</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@commands.hybrid_command(name="help", description= "Get all the commands list")
    async def help(self, interaction: commands.Context):
        embed = discord.Embed(
            title= "Help",
            description= "List of commands all the commands",
            color= 0x00FFFF
        )

        for c in self.bot.cogs:
             cog = self.bot.get_cog(c)
             if any(cog.walk_commands()):
                 embed.add_field(name=cog.qualified_name, value= " , ".join(f"`{i.name}`" for i in cog.walk_commands()), inline= False)
        await interaction.send(embed=embed)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Keep in Mind to disable the default Help command&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if __name__ == "__main__":
    bot = Bot(command_prefix=".", intents=discord.Intents.all(), help_command = None)
    bot.run(token)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Create a simple joke command for discord in python</title>
      <dc:creator>Hazrat Ummar Shaikh</dc:creator>
      <pubDate>Sat, 01 Jun 2024 12:20:00 +0000</pubDate>
      <link>https://forem.com/ihazratummar/create-a-simple-joke-command-for-discord-in-python-1m40</link>
      <guid>https://forem.com/ihazratummar/create-a-simple-joke-command-for-discord-in-python-1m40</guid>
      <description>&lt;p&gt;&lt;strong&gt;Any Suggestions Appreciated I'm Sharing what I'm Learning Right Now&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@commands.hybrid_command(name="joke", descriptio = "Tells a random joke.")
    async def joke(self, ctx: commands.Context):
        url = "https://official-joke-api.appspot.com/random_joke"
        response = requests.get(url)
        data = response.json()
        setup = data["setup"]
        paunch_line = data["punchline"]

        await ctx.send(setup)
        await asyncio.sleep(3)
        await ctx.send(paunch_line)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>discord</category>
      <category>python</category>
      <category>bot</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to create urban discord command in python?</title>
      <dc:creator>Hazrat Ummar Shaikh</dc:creator>
      <pubDate>Fri, 31 May 2024 09:27:55 +0000</pubDate>
      <link>https://forem.com/ihazratummar/how-to-create-urban-discord-command-in-python-18kd</link>
      <guid>https://forem.com/ihazratummar/how-to-create-urban-discord-command-in-python-18kd</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@commands.hybrid_command(name="urban", description = "Get the definition of a term(word) from Urban Dictionary.")
    async def urbun(self, ctx:commands.Context, *, word:str):
        response = requests.get(f"http://api.urbandictionary.com/v0/define?term={word}")
        data = response.json()

        result = [item for item in data["list"]]
        random_choice = random.choice(result)

        embed = discord.Embed(title=f"{word.capitalize()}",
                              description=f"&amp;gt;&amp;gt;&amp;gt; **Definition**: {random_choice["definition"]}", color= 0x00FFFF)
        embed.add_field(name="Example", value=f"{random_choice["example"]}", inline= False)
        embed.add_field(name=f"🖒 {random_choice["thumbs_up"]}", value="", inline=True)
        embed.add_field(name=f"🖓 {random_choice["thumbs_down"]}", value="", inline=True)
        embed.set_footer(text=f"{random_choice["written_on"]}")
        embed.set_author(name=f"Author: {random_choice["author"]}")

        button = discord.ui.Button(
            label= "Check Out",
            url= random_choice["permalink"],
            style= discord.ButtonStyle.link
        )

        view = discord.ui.View()
        view.add_item(button)

        await ctx.send(embed=embed, view= view)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vrhkdhksmlt0ew1aur2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2vrhkdhksmlt0ew1aur2.png" alt="Image description" width="538" height="423"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>discord</category>
      <category>bot</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
