Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Discord;
- using Discord.Commands;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace momiji
- {
- class Mybot
- {
- DiscordClient discord;
- CommandService commands;
- Random rand;
- string[] freshestMeme;
- string[] randomTexts;
- public Mybot()
- {
- rand = new Random();
- freshestMeme = new string[]
- {
- "memes/mem1.jpg", //0
- "memes/mem2.jpg", //1 and so forth.
- };
- randomTexts = new string[]
- {
- "Hello",
- "Hi",
- };
- discord = new DiscordClient(x =>
- {
- x.LogLevel = LogSeverity.Info;
- x.LogHandler = Log;
- });
- discord.UsingCommands(x =>
- {
- x.PrefixChar = '!';
- x.AllowMentionPrefix = true;
- });
- commands = discord.GetService<CommandService>();
- //Logging in
- discord.ExecuteAndWait(async () =>
- {
- await discord.Connect("Bot token"); //not a real token, btw.
- });
- }
- private void RegisterMemeCommand()
- {
- commands.CreateCommand("meme") //Seems not to work. No idea.
- .Do(async (e) =>
- {
- int randomMemeIndex = rand.Next(randomTexts.Length);
- string memeToPost = randomTexts[0];
- await e.Channel.SendMessage(memeToPost);
- });
- }
- private void Log(object sender, LogMessageEventArgs e)
- {
- Console.WriteLine(e.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement