Last active
May 14, 2019 13:03
-
-
Save waff1es/18d262b3d3089d08be7cb7b13f034832 to your computer and use it in GitHub Desktop.
The meme part does not work for some reason. Discord bot for those who don't know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Discord; | |
| using Discord.Commands; | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication1 | |
| { | |
| class MyBot | |
| { | |
| DiscordClient discord; | |
| CommandService commands; | |
| Random rand; | |
| string[] freshestMemes; | |
| string[] randomJoke; | |
| public MyBot() | |
| { | |
| rand = new Random(); | |
| randomJoke = new string[] | |
| { | |
| }; | |
| freshestMemes = new string[] | |
| { | |
| }; | |
| discord = new DiscordClient(x => | |
| { | |
| x.LogLevel = LogSeverity.Info; | |
| x.LogHandler = Log; | |
| }); | |
| discord.UsingCommands(x => | |
| { | |
| x.PrefixChar = '-'; | |
| x.AllowMentionPrefix = true; | |
| }); | |
| commands = discord.GetService<CommandService>(); | |
| RegisterMemeCommand(); | |
| RegisterJokeCommand(); | |
| discord.ExecuteAndWait(async () => | |
| { | |
| await discord.Connect("<enter token here>", TokenType.Bot); | |
| }); | |
| } | |
| private void RegisterMemeCommand() | |
| { | |
| commands.CreateCommand("meme") | |
| .Do(async (e) => | |
| { | |
| int randomMemeIndex = rand.Next(freshestMemes.Length); | |
| string memeToPost = freshestMemes[randomMemeIndex]; | |
| await e.Channel.SendFile(memeToPost); | |
| }); | |
| } | |
| private void RegisterJokeCommand() | |
| { | |
| commands.CreateCommand("joke") | |
| .Do(async (e) => | |
| { | |
| int randomJokeIndex = rand.Next(randomJoke.Length); | |
| string jokeToPost = randomJoke[randomJokeIndex]; | |
| await e.Channel.SendMessage(jokeToPost); | |
| }); | |
| } | |
| private void Log(object sender, LogMessageEventArgs e) | |
| { | |
| Console.WriteLine(e.Message); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication1 | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| MyBot bot = new MyBot(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment